|
|
7d975d |
From: Greg Kurz <gkurz@linux.vnet.ibm.com>
|
|
|
7d975d |
Date: Fri, 15 Jan 2016 16:00:31 +0100
|
|
|
7d975d |
Subject: [PATCH] target-ppc: gdbstub: introduce avr_need_swap()
|
|
|
7d975d |
|
|
|
7d975d |
This helper will be used to support Altivec registers in little-endian guests.
|
|
|
7d975d |
This patch does not change functionnality.
|
|
|
7d975d |
|
|
|
7d975d |
Note: I had to put the helper some lines away from the gdb_*_avr_reg()
|
|
|
7d975d |
routines to get a more readable patch.
|
|
|
7d975d |
|
|
|
7d975d |
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
|
|
|
7d975d |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
7d975d |
(cherry picked from commit 87601e2d5c22d9c1fef0e09978d377f46336c1db)
|
|
|
7d975d |
---
|
|
|
7d975d |
target-ppc/translate_init.c | 37 +++++++++++++++++++++++--------------
|
|
|
7d975d |
1 file changed, 23 insertions(+), 14 deletions(-)
|
|
|
7d975d |
|
|
|
7d975d |
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
|
|
|
7d975d |
index d31d7f6..18e9e56 100644
|
|
|
7d975d |
--- a/target-ppc/translate_init.c
|
|
|
7d975d |
+++ b/target-ppc/translate_init.c
|
|
|
7d975d |
@@ -8751,6 +8751,15 @@ static void dump_ppc_insns (CPUPPCState *env)
|
|
|
7d975d |
}
|
|
|
7d975d |
#endif
|
|
|
7d975d |
|
|
|
7d975d |
+static bool avr_need_swap(CPUPPCState *env)
|
|
|
7d975d |
+{
|
|
|
7d975d |
+#ifdef HOST_WORDS_BIGENDIAN
|
|
|
7d975d |
+ return false;
|
|
|
7d975d |
+#else
|
|
|
7d975d |
+ return true;
|
|
|
7d975d |
+#endif
|
|
|
7d975d |
+}
|
|
|
7d975d |
+
|
|
|
7d975d |
static int gdb_get_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
|
|
|
7d975d |
{
|
|
|
7d975d |
if (n < 32) {
|
|
|
7d975d |
@@ -8784,13 +8793,13 @@ static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
|
|
|
7d975d |
static int gdb_get_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
|
|
|
7d975d |
{
|
|
|
7d975d |
if (n < 32) {
|
|
|
7d975d |
-#ifdef HOST_WORDS_BIGENDIAN
|
|
|
7d975d |
- stq_p(mem_buf, env->avr[n].u64[0]);
|
|
|
7d975d |
- stq_p(mem_buf+8, env->avr[n].u64[1]);
|
|
|
7d975d |
-#else
|
|
|
7d975d |
- stq_p(mem_buf, env->avr[n].u64[1]);
|
|
|
7d975d |
- stq_p(mem_buf+8, env->avr[n].u64[0]);
|
|
|
7d975d |
-#endif
|
|
|
7d975d |
+ if (!avr_need_swap(env)) {
|
|
|
7d975d |
+ stq_p(mem_buf, env->avr[n].u64[0]);
|
|
|
7d975d |
+ stq_p(mem_buf+8, env->avr[n].u64[1]);
|
|
|
7d975d |
+ } else {
|
|
|
7d975d |
+ stq_p(mem_buf, env->avr[n].u64[1]);
|
|
|
7d975d |
+ stq_p(mem_buf+8, env->avr[n].u64[0]);
|
|
|
7d975d |
+ }
|
|
|
7d975d |
return 16;
|
|
|
7d975d |
}
|
|
|
7d975d |
if (n == 32) {
|
|
|
7d975d |
@@ -8807,13 +8816,13 @@ static int gdb_get_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
|
|
|
7d975d |
static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
|
|
|
7d975d |
{
|
|
|
7d975d |
if (n < 32) {
|
|
|
7d975d |
-#ifdef HOST_WORDS_BIGENDIAN
|
|
|
7d975d |
- env->avr[n].u64[0] = ldq_p(mem_buf);
|
|
|
7d975d |
- env->avr[n].u64[1] = ldq_p(mem_buf+8);
|
|
|
7d975d |
-#else
|
|
|
7d975d |
- env->avr[n].u64[1] = ldq_p(mem_buf);
|
|
|
7d975d |
- env->avr[n].u64[0] = ldq_p(mem_buf+8);
|
|
|
7d975d |
-#endif
|
|
|
7d975d |
+ if (!avr_need_swap(env)) {
|
|
|
7d975d |
+ env->avr[n].u64[0] = ldq_p(mem_buf);
|
|
|
7d975d |
+ env->avr[n].u64[1] = ldq_p(mem_buf+8);
|
|
|
7d975d |
+ } else {
|
|
|
7d975d |
+ env->avr[n].u64[1] = ldq_p(mem_buf);
|
|
|
7d975d |
+ env->avr[n].u64[0] = ldq_p(mem_buf+8);
|
|
|
7d975d |
+ }
|
|
|
7d975d |
return 16;
|
|
|
7d975d |
}
|
|
|
7d975d |
if (n == 32) {
|