summaryrefslogtreecommitdiffstats
path: root/target/loongarch
diff options
context:
space:
mode:
authorSong Gao2022-08-05 05:35:23 +0200
committerRichard Henderson2022-08-05 19:02:40 +0200
commit2f149c759ff352399e7a0eca25a62388822d7d13 (patch)
treeaa9b22d5698554a0653cdd102104f94c8e34103c /target/loongarch
parenttarget/loongarch: Update loongarch-fpu.xml (diff)
downloadqemu-2f149c759ff352399e7a0eca25a62388822d7d13.tar.gz
qemu-2f149c759ff352399e7a0eca25a62388822d7d13.tar.xz
qemu-2f149c759ff352399e7a0eca25a62388822d7d13.zip
target/loongarch: Update gdb_set_fpu() and gdb_get_fpu()
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> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Acked-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220805033523.1416837-6-gaosong@loongson.cn>
Diffstat (limited to 'target/loongarch')
-rw-r--r--target/loongarch/gdbstub.c34
-rw-r--r--target/loongarch/internals.h3
2 files changed, 30 insertions, 7 deletions
diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c
index d3a5e404b0..a4d1e28e36 100644
--- a/target/loongarch/gdbstub.c
+++ b/target/loongarch/gdbstub.c
@@ -11,6 +11,24 @@
#include "internals.h"
#include "exec/gdbstub.h"
+uint64_t read_fcc(CPULoongArchState *env)
+{
+ uint64_t ret = 0;
+
+ for (int i = 0; i < 8; ++i) {
+ ret |= (uint64_t)env->cf[i] << (i * 8);
+ }
+
+ return ret;
+}
+
+void write_fcc(CPULoongArchState *env, uint64_t val)
+{
+ for (int i = 0; i < 8; ++i) {
+ env->cf[i] = (val >> (i * 8)) & 1;
+ }
+}
+
int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
{
LoongArchCPU *cpu = LOONGARCH_CPU(cs);
@@ -51,9 +69,10 @@ 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) {
+ uint64_t val = read_fcc(env);
+ return gdb_get_reg64(mem_buf, val);
+ } else if (n == 33) {
return gdb_get_reg32(mem_buf, env->fcsr0);
}
return 0;
@@ -67,10 +86,11 @@ 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) {
+ uint64_t val = ldq_p(mem_buf);
+ write_fcc(env, val);
+ length = 8;
+ } else if (n == 33) {
env->fcsr0 = ldl_p(mem_buf);
length = 4;
}
diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h
index ea227362b6..f01635aed6 100644
--- a/target/loongarch/internals.h
+++ b/target/loongarch/internals.h
@@ -51,6 +51,9 @@ bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
hwaddr loongarch_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
#endif /* !CONFIG_USER_ONLY */
+uint64_t read_fcc(CPULoongArchState *env);
+void write_fcc(CPULoongArchState *env, uint64_t val);
+
int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n);
int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n);
void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs);