- implemented video mode setting with the property tags, and once again it only
[rpikern] / src / debug.c
1 #include <stdio.h>
2 #include <ctype.h>
3 #include "debug.h"
4
5
6 void hexdump(void *start, int nbytes)
7 {
8         int i, j, nlines;
9         unsigned char *ptr = start;
10         unsigned char *end = ptr + nbytes;
11
12         nlines = (nbytes + 0xf) >> 4;
13
14         for(i=0; i<nlines; i++) {
15                 printf("%08x  ", (uint32_t)ptr);
16
17                 for(j=0; j<16; j++) {
18                         if(ptr + j < end) {
19                                 printf("%02x ", ptr[j]);
20                         } else {
21                                 printf("   ");
22                         }
23                         if((j & 7) == 7) putchar(' ');
24                 }
25
26                 putchar('|');
27                 for(j=0; j<16; j++) {
28                         if(ptr + j < end) {
29                                 putchar(isprint(ptr[j]) ? ptr[j] : '.');
30                         } else {
31                                 putchar(' ');
32                         }
33                 }
34                 printf("|\n");
35
36                 ptr += 16;
37         }
38 }