qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH for-7.1 5/5] target/loongarch: Update gdb_set_fpu() and gdb_g


From: Richard Henderson
Subject: Re: [PATCH for-7.1 5/5] target/loongarch: Update gdb_set_fpu() and gdb_get_fpu()
Date: Thu, 4 Aug 2022 09:08:08 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 8/4/22 06:02, Song Gao wrote:
GDB LoongArch fpu use fcc register,  update gdb_set_fpu() and gdb_get_fpu() to 
match it.

Signed-off-by: Song Gao <gaosong@loongson.cn>
---
  target/loongarch/gdbstub.c | 23 ++++++++++++++++-------
  1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c
index 7d95b4b11c..265f0f43b6 100644
--- a/target/loongarch/gdbstub.c
+++ b/target/loongarch/gdbstub.c
@@ -51,9 +51,14 @@ static int loongarch_gdb_get_fpu(CPULoongArchState *env,
  {
      if (0 <= n && n < 32) {
          return gdb_get_reg64(mem_buf, env->fpr[n]);
-    } else if (32 <= n && n < 40) {
-        return gdb_get_reg8(mem_buf, env->cf[n - 32]);
-    } else if (n == 40) {
+    } else if (n == 32) {
+        /* fcc */
+        uint64_t val = 0;
+        for (int i = 0; i < 8; ++i) {
+            val |= (uint64_t)env->cf[i] << (i * 8);
+        }
+        return gdb_get_reg64(mem_buf, val);

You've got this function over in linux-user/loongarch/signal.c.
You might as well move it into target/loongarch/ and share it.


+    } else if (n == 33) {
          return gdb_get_reg32(mem_buf, env->fcsr0);
      }
      return 0;
@@ -67,10 +72,14 @@ static int loongarch_gdb_set_fpu(CPULoongArchState *env,
      if (0 <= n && n < 32) {
          env->fpr[n] = ldq_p(mem_buf);
          length = 8;
-    } else if (32 <= n && n < 40) {
-        env->cf[n - 32] = ldub_p(mem_buf);
-        length = 1;
-    } else if (n == 40) {
+    } else if (n == 32) {
+        /* fcc */
+        uint64_t val = ldq_p(mem_buf);
+        for (int i = 0; i < 8; ++i) {
+            env->cf[i] = (val >> (i * 8)) & 1;
+        }
+        length = 8;

Likewise.


r~

+    } else if (n == 33) {
          env->fcsr0 = ldl_p(mem_buf);
          length = 4;
      }




reply via email to

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