- implemented video mode setting with the property tags, and once again it only
[rpikern] / src / debug.c
diff --git a/src/debug.c b/src/debug.c
new file mode 100644 (file)
index 0000000..241b147
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <ctype.h>
+#include "debug.h"
+
+
+void hexdump(void *start, int nbytes)
+{
+       int i, j, nlines;
+       unsigned char *ptr = start;
+       unsigned char *end = ptr + nbytes;
+
+       nlines = (nbytes + 0xf) >> 4;
+
+       for(i=0; i<nlines; i++) {
+               printf("%08x  ", (uint32_t)ptr);
+
+               for(j=0; j<16; j++) {
+                       if(ptr + j < end) {
+                               printf("%02x ", ptr[j]);
+                       } else {
+                               printf("   ");
+                       }
+                       if((j & 7) == 7) putchar(' ');
+               }
+
+               putchar('|');
+               for(j=0; j<16; j++) {
+                       if(ptr + j < end) {
+                               putchar(isprint(ptr[j]) ? ptr[j] : '.');
+                       } else {
+                               putchar(' ');
+                       }
+               }
+               printf("|\n");
+
+               ptr += 16;
+       }
+}