Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36022 )
Change subject: x86 gdb: Use copy_to_hex_{word, long} for 16 and 32 bit read ......................................................................
x86 gdb: Use copy_to_hex_{word, long} for 16 and 32 bit read
I/O read can be done in 8, 16 and 32 bit. To handle the 16 and 32 bit wide read access right, use copy_to_hex_word() and copy_to_hex_long() respectively. The same applies to MSR read. Here we have two 32 bit values which now printed with copy_to_hex_long().
Change-Id: I1f4ab7a0135baac1fd324ced0e501ac2f096e1c4 Signed-off-by: Werner Zeh werner.zeh@siemens.com --- M src/arch/x86/exception.c 1 file changed, 22 insertions(+), 26 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/36022/1
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index b1689cc..ae7e57e 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -609,9 +609,13 @@ char *out_buf_ptr = out_buffer;
msr = rdmsr(addr); - copy_to_hex(out_buf_ptr, (void *)&(msr.hi), 4); + copy_to_hex_long(out_buf_ptr, + (void *)&(msr.hi), + 1); out_buf_ptr += (4 << 1); - copy_to_hex(out_buf_ptr, (void *)&(msr.lo), 4); + copy_to_hex_long(out_buf_ptr, + (void *)&(msr.lo), + 1); } else memcpy(out_buffer, "E05", 4); break; @@ -726,43 +730,35 @@ (*(ptr++) == ',') && ((*(ptr) == 'b') || (*(ptr) == 'w') || (*(ptr) == 'l'))) { - char width = *(ptr++), len; + char width = *(ptr++); char *out_buf_ptr = out_buffer; - unsigned long i, tmp; + unsigned long i; /* Read desired amount of I/O ports */ for (i = 0; i < length; i++) { switch (width) { case 'l': - tmp = inl(addr); - /* Rotate the byte order as */ - /* copy_to_hex() works on a */ - /* byte stream. */ - val = (((tmp >> 24) & 0xff) | - (((tmp >> 16) & 0xff) << 8) | - (((tmp >> 8) & 0xff) << 16) | - ((tmp & 0xff) << 24)); - len = 4; + val = inl(addr); + copy_to_hex_long(out_buf_ptr, + (void *)&val, 1); + out_buf_ptr += 4 << 1; + addr += 4; break; case 'w': - tmp = inw(addr); - /* Rotate the byte order as */ - /* copy_to_hex() works on a */ - /* byte stream. */ - val = (((tmp >> 8) & 0xff) | - ((tmp & 0xff) << 8)); - len = 2; + val = inw(addr); + copy_to_hex_word(out_buf_ptr, + (void *)&val, 1); + out_buf_ptr += 2 << 1; + addr += 2; break; case 'b': default: val = inb(addr); - len = 1; + copy_to_hex(out_buf_ptr, + (void *)&val, 1); + out_buf_ptr += 1 << 1; + addr += 1; break; - } - copy_to_hex(out_buf_ptr, (void *)&val, - len); - out_buf_ptr += len << 1; - addr += len; } } else memcpy(out_buffer, "E03", 4);