4 * Copyright (C) 2009 Liu Aleaxander -- All rights reserved. This file
5 * may be redistributed under the terms of the GNU Public License.
11 void hexdump(const void *data
, int len
)
15 unsigned int base
= 0;
16 unsigned char *p
= data
;
17 unsigned char hex
[16 * 3 + 1] = {0, };
18 unsigned char text
[16 + 1] = {0, };
21 for (i
= 0; i
< len
; i
++) {
23 if (i
&& index
== 0) {
24 /* print the buffer before reset it */
25 printk("%08x %-48s |%-16s|\n", base
, hex
, text
);
27 memset(hex
, 0, sizeof hex
);
28 memset(text
, 0, sizeof text
);
32 sprintk((char *)&hex
[index
* 3], "%02x ", c
);
33 if (c
< 0x20 || c
> 0x7f)
39 /* print the last part */
40 printk("%08x %-48s |%-16s|\n", base
, hex
, text
);