diff --git a/litex/soc/software/bios/helpers.c b/litex/soc/software/bios/helpers.c index 0f8e9bfab..6b384ec0e 100644 --- a/litex/soc/software/bios/helpers.c +++ b/litex/soc/software/bios/helpers.c @@ -18,18 +18,24 @@ extern unsigned int _ftext, _edata_rom; #define NUMBER_OF_BYTES_ON_A_LINE 16 void dump_bytes(unsigned int *ptr, int count, unsigned long addr) { - char *data = (char *)ptr; + uint32_t *dptr = (uint32_t *)ptr; + char data[NUMBER_OF_BYTES_ON_A_LINE]; int line_bytes = 0, i = 0; + fputs("Memory dump:", stdout); while (count > 0) { line_bytes = (count > NUMBER_OF_BYTES_ON_A_LINE)? NUMBER_OF_BYTES_ON_A_LINE : count; + for (i = 0; i < line_bytes; i+=4){ + *((uint32_t*)&data[i]) = *(dptr++); + } + printf("\n0x%08lx ", addr); for (i = 0; i < line_bytes; i++) - printf("%02x ", *(unsigned char *)(data+i)); + printf("%02x ", (unsigned char)data[i]); for (; i < NUMBER_OF_BYTES_ON_A_LINE; i++) printf(" "); @@ -37,16 +43,15 @@ void dump_bytes(unsigned int *ptr, int count, unsigned long addr) printf(" "); for (i = 0; i 0x7e)) + if ((data[i] < 0x20) || (data[i] > 0x7e)) printf("."); else - printf("%c", *(data+i)); + printf("%c", data[i]); } for (; i < NUMBER_OF_BYTES_ON_A_LINE; i++) printf(" "); - data += (char)line_bytes; count -= line_bytes; addr += line_bytes; }