qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-ppc] [Qemu-devel] [PATCH v4] target-ppc: gdbstub allow byte sw


From: Thomas Falcon
Subject: Re: [Qemu-ppc] [Qemu-devel] [PATCH v4] target-ppc: gdbstub allow byte swapping for reading/writing registers
Date: Fri, 28 Feb 2014 13:28:03 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 02/28/2014 11:37 AM, Richard Henderson wrote:
On 02/26/2014 02:51 PM, Thomas Falcon wrote:
+void ppc_cpu_gdb_swap_register(uint8_t *mem_buf, int n)
+{
+    int len = ppc_cpu_gdb_register_len(n);
+    int i = 0;
+    uint8_t tmp;
+    for (i = 0; i < len/2; i++) {
+        tmp = *(mem_buf + i);
+        *(mem_buf+i) = *(mem_buf + len - 1 - i);
+        *(mem_buf + len - 1 - i) = tmp;
+    }
+}
Ew.

The number of register sizes you need to handle is extremely limited.  One can
easily use bswap32 and bswap64 for this.


r~

Thanks for your feedback. Did not realize there were built-in bswap functions for pointers. How about this instead?

int len = ppc_cpu_gdb_register_len(n);
if (len==4) {
    bswap32s((uint32_t *)mem_buf);
} else {
    bswap64s((uint64_t *)mem_buf);
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]