All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Gao <gaosong@loongson.cn>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, peter.maydell@linaro.org,
	gaosong@loongson.cn, f4bug@amsat.org, alex.bennee@linaro.org,
	yangxiaojuan@loongson.cn
Subject: [PATCH for-7.1 5/5] target/loongarch: Update gdb_set_fpu() and gdb_get_fpu()
Date: Thu,  4 Aug 2022 21:02:13 +0800	[thread overview]
Message-ID: <20220804130213.1364164-6-gaosong@loongson.cn> (raw)
In-Reply-To: <20220804130213.1364164-1-gaosong@loongson.cn>

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);
+    } 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;
+    } else if (n == 33) {
         env->fcsr0 = ldl_p(mem_buf);
         length = 4;
     }
-- 
2.31.1



  parent reply	other threads:[~2022-08-04 13:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 13:02 [PATCH for-7.1 0/5] Fix gdb bugs and update gdb-xml Song Gao
2022-08-04 13:02 ` [PATCH for-7.1 1/5] target/loongarch: Fix GDB get the wrong pc Song Gao
2022-08-04 15:56   ` Richard Henderson
2022-08-04 13:02 ` [PATCH for-7.1 2/5] target/loongarch: add gdb_arch_name() Song Gao
2022-08-04 16:02   ` Richard Henderson
2022-08-04 13:02 ` [PATCH for-7.1 3/5] target/loongarch: update loongarch-base64.xml Song Gao
2022-08-04 16:03   ` Richard Henderson
2022-08-04 13:02 ` [PATCH for-7.1 4/5] target/loongarch: Update loongarch-fpu.xml Song Gao
2022-08-04 16:06   ` Richard Henderson
2022-08-04 13:02 ` Song Gao [this message]
2022-08-04 16:08   ` [PATCH for-7.1 5/5] target/loongarch: Update gdb_set_fpu() and gdb_get_fpu() Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220804130213.1364164-6-gaosong@loongson.cn \
    --to=gaosong@loongson.cn \
    --cc=alex.bennee@linaro.org \
    --cc=f4bug@amsat.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=yangxiaojuan@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.