bios: mem_read: reduce number of reads on mapped registers (only supports 32-bit aligned addresses)
Instead of reading each individual byte, causing multiple 4-byte requests to each address, this change results in a single read for each address. Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
This commit is contained in:
parent
03a0a6fd9b
commit
41b346d141
|
@ -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<line_bytes; i++) {
|
||||
if ((*(data+i) < 0x20) || (*(data+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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue