Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36020 )
Change subject: x86 gdb: Extend GDB stub memory access with 64 bit access ......................................................................
x86 gdb: Extend GDB stub memory access with 64 bit access
Add "q" for the width field n memory read and write which enables 64 bit access to memory.
NOT FOR MERGE!!!
Change-Id: I899dec25d3d6bf0658c491e5e71b64d5b9dd09fd Signed-off-by: Werner Zeh werner.zeh@siemens.com --- M src/arch/x86/exception.c 1 file changed, 97 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/20/36020/1
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index 71d96fc..646e962 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -282,6 +282,31 @@ return start != *ptr; }
+static void gdb_read64(void *addr, unsigned long *hi, unsigned long *lo) +{ + __asm__ volatile( + "movq (%%eax), %%xmm0;" + "movd %%xmm0, %%ebx;" + "pextrd $1, %%xmm0, %%ecx" + : "=b" (*lo), + "=c" (*hi) + : "a" (addr) + ); +} + +static void gdb_write64(void *addr, unsigned long hi, unsigned long lo) +{ + __asm__ volatile( + "movd %%ebx, %%xmm0;" + "pinsrd $1, %%ecx, %%xmm0;" + "movq %%xmm0, (%%eax);" + : + : "a" (addr), + "b" (lo), + "c" (hi) + ); +} + /* convert the memory pointed to by mem into hex, placing result in buf */ /* return a pointer to the last char put in buf (null) */ static void copy_to_hex(char *buf, void *addr, unsigned long count) @@ -337,6 +362,38 @@ *buf = 0; }
+/* convert the memory pointed to by mem into hex, placing result in buf */ +/* return a pointer to the last char put in buf (null) */ +/* Use 32 bit wide memory access. */ +static void copy_to_hex_64(char *buf, void *addr, unsigned long count) +{ + unsigned long hi, lo; + long long *mem = addr; + + while (count--) { + hi = 0; + lo = 0; + gdb_read64(mem++, &hi, &lo); + *buf++ = hexchars[(hi >> 28) & 0x0f]; + *buf++ = hexchars[(hi >> 24) & 0x0f]; + *buf++ = hexchars[(hi >> 20) & 0x0f]; + *buf++ = hexchars[(hi >> 16) & 0x0f]; + *buf++ = hexchars[(hi >> 12) & 0x0f]; + *buf++ = hexchars[(hi >> 8) & 0x0f]; + *buf++ = hexchars[(hi >> 4) & 0x0f]; + *buf++ = hexchars[(hi >> 0) & 0x0f]; + *buf++ = hexchars[(lo >> 28) & 0x0f]; + *buf++ = hexchars[(lo >> 24) & 0x0f]; + *buf++ = hexchars[(lo >> 20) & 0x0f]; + *buf++ = hexchars[(lo >> 16) & 0x0f]; + *buf++ = hexchars[(lo >> 12) & 0x0f]; + *buf++ = hexchars[(lo >> 8) & 0x0f]; + *buf++ = hexchars[(lo >> 4) & 0x0f]; + *buf++ = hexchars[(lo >> 0) & 0x0f]; + } + *buf = 0; +} +
/* convert the hex array pointed to by buf into binary to be placed in mem */ /* return a pointer to the character AFTER the last byte written */ @@ -392,6 +449,38 @@ } }
+/* convert the hex array pointed to by buf into binary to be placed in mem */ +/* return a pointer to the character AFTER the last byte written */ +/* Use 64 bit wide memory access */ +static void copy_from_hex_64(void *addr, char *buf, unsigned long count) +{ + unsigned long hi, lo; + long long *mem = addr; + + while (count--) { + hi = 0; + lo = 0; + hi |= hex(*buf++) << 28; + hi |= hex(*buf++) << 24; + hi |= hex(*buf++) << 20; + hi |= hex(*buf++) << 16; + hi |= hex(*buf++) << 12; + hi |= hex(*buf++) << 8; + hi |= hex(*buf++) << 4; + hi |= hex(*buf++) << 0; + + lo |= hex(*buf++) << 28; + lo |= hex(*buf++) << 24; + lo |= hex(*buf++) << 20; + lo |= hex(*buf++) << 16; + lo |= hex(*buf++) << 12; + lo |= hex(*buf++) << 8; + lo |= hex(*buf++) << 4; + lo |= hex(*buf++); + gdb_write64(mem++, hi, lo); + } +} +
/* scan for the sequence $<data>#<checksum> */
@@ -575,6 +664,10 @@ copy_to_hex_word(out_buffer, (void *)addr, length); + } else if (width == 'q') { + copy_to_hex_64(out_buffer, + (void *)addr, + length); } else { memcpy(out_buffer, "E01", 4); } @@ -608,6 +701,10 @@ copy_from_hex_word((void *)addr, ptr, length); + } else if (width == 'q') { + copy_from_hex_64((void *)addr, + ptr, + length); } else { memcpy(out_buffer, "E02", 4); }
Werner Zeh has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/36020 )
Change subject: x86 gdb: Extend GDB stub memory access with 64 bit access ......................................................................
Abandoned