diff options
author | Randy Dunlap <randy.dunlap@oracle.com> | 2007-05-11 01:22:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-11 11:29:34 -0400 |
commit | 99eaf3c45fe806c4a7f39b9be4a1bd0dfc617699 (patch) | |
tree | 9da206b2faaae7dc3804df2adea4cbf7f117208c /include/linux/kernel.h | |
parent | 6eaeeaba39e5fa3d52a0bb8de15e995516ae251a (diff) |
lib/hexdump
Based on ace_dump_mem() from Grant Likely for the Xilinx SystemACE
CompactFlash interface.
Add print_hex_dump() & hex_dumper() to lib/hexdump.c and linux/kernel.h.
This patch adds the functions print_hex_dump() & hex_dumper().
print_hex_dump() can be used to perform a hex + ASCII dump of data to
syslog, in an easily viewable format, thus providing a common text hex dump
format.
hex_dumper() provides a dump-to-memory function. It converts one "line" of
output (16 bytes of input) at a time.
Example usages:
print_hex_dump(KERN_DEBUG, DUMP_PREFIX_ADDRESS, frame->data, frame->len);
hex_dumper(frame->data, frame->len, linebuf, sizeof(linebuf));
Example output using %DUMP_PREFIX_OFFSET:
0009ab42: 40414243 44454647 48494a4b 4c4d4e4f-@ABCDEFG HIJKLMNO
Example output using %DUMP_PREFIX_ADDRESS:
ffffffff88089af0: 70717273 74757677 78797a7b 7c7d7e7f-pqrstuvw xyz{|}~.
[akpm@linux-foundation.org: cleanups, add export]
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 8645181fca0f..eec0d13169a6 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -213,6 +213,17 @@ extern enum system_states { | |||
213 | 213 | ||
214 | extern void dump_stack(void); | 214 | extern void dump_stack(void); |
215 | 215 | ||
216 | enum { | ||
217 | DUMP_PREFIX_NONE, | ||
218 | DUMP_PREFIX_ADDRESS, | ||
219 | DUMP_PREFIX_OFFSET | ||
220 | }; | ||
221 | extern void hex_dump_to_buffer(const void *buf, size_t len, char *linebuf, | ||
222 | size_t linebuflen); | ||
223 | extern void print_hex_dump(const char *level, int prefix_type, | ||
224 | void *buf, size_t len); | ||
225 | #define hex_asc(x) "0123456789abcdef"[x] | ||
226 | |||
216 | #ifdef DEBUG | 227 | #ifdef DEBUG |
217 | /* If you are writing a driver, please use dev_dbg instead */ | 228 | /* If you are writing a driver, please use dev_dbg instead */ |
218 | #define pr_debug(fmt,arg...) \ | 229 | #define pr_debug(fmt,arg...) \ |