提交 5e48dc0a 编写于 作者: D Douglas Miller 提交者: Michael Ellerman

powerpc/xmon: Dump memory in CPU endian format

Extend the dump command to allow display of 2, 4, and 8 byte words in
CPU endian format. Also adds dump command for "1 byte values" for the
sake of symmetry. New commands are:

  d1	dump 1 byte values
  d2	dump 2 byte values
  d4	dump 4 byte values
  d8	dump 8 byte values
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: NDouglas Miller <dougmill@linux.vnet.ibm.com>
Acked-by: NBalbir Singh <bsingharora@gmail.com>
上级 943db62c
...@@ -212,6 +212,10 @@ Commands:\n\ ...@@ -212,6 +212,10 @@ Commands:\n\
"\ "\
C checksum\n\ C checksum\n\
d dump bytes\n\ d dump bytes\n\
d1 dump 1 byte values\n\
d2 dump 2 byte values\n\
d4 dump 4 byte values\n\
d8 dump 8 byte values\n\
di dump instructions\n\ di dump instructions\n\
df dump float values\n\ df dump float values\n\
dd dump double values\n\ dd dump double values\n\
...@@ -2334,9 +2338,42 @@ static void dump_pacas(void) ...@@ -2334,9 +2338,42 @@ static void dump_pacas(void)
} }
#endif #endif
static void dump_by_size(unsigned long addr, long count, int size)
{
unsigned char temp[16];
int i, j;
u64 val;
count = ALIGN(count, 16);
for (i = 0; i < count; i += 16, addr += 16) {
printf(REG, addr);
if (mread(addr, temp, 16) != 16) {
printf("\nFaulted reading %d bytes from 0x"REG"\n", 16, addr);
return;
}
for (j = 0; j < 16; j += size) {
putchar(' ');
switch (size) {
case 1: val = temp[j]; break;
case 2: val = *(u16 *)&temp[j]; break;
case 4: val = *(u32 *)&temp[j]; break;
case 8: val = *(u64 *)&temp[j]; break;
default: val = 0;
}
printf("%0*lx", size * 2, val);
}
printf("\n");
}
}
static void static void
dump(void) dump(void)
{ {
static char last[] = { "d?\n" };
int c; int c;
c = inchar(); c = inchar();
...@@ -2350,8 +2387,9 @@ dump(void) ...@@ -2350,8 +2387,9 @@ dump(void)
} }
#endif #endif
if ((isxdigit(c) && c != 'f' && c != 'd') || c == '\n') if (c == '\n')
termch = c; termch = c;
scanhex((void *)&adrs); scanhex((void *)&adrs);
if (termch != '\n') if (termch != '\n')
termch = 0; termch = 0;
...@@ -2383,10 +2421,24 @@ dump(void) ...@@ -2383,10 +2421,24 @@ dump(void)
ndump = 64; ndump = 64;
else if (ndump > MAX_DUMP) else if (ndump > MAX_DUMP)
ndump = MAX_DUMP; ndump = MAX_DUMP;
switch (c) {
case '8':
case '4':
case '2':
case '1':
ndump = ALIGN(ndump, 16);
dump_by_size(adrs, ndump, c - '0');
last[1] = c;
last_cmd = last;
break;
default:
prdump(adrs, ndump); prdump(adrs, ndump);
adrs += ndump;
last_cmd = "d\n"; last_cmd = "d\n";
} }
adrs += ndump;
}
} }
static void static void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册