]>
git.proxmox.com Git - mirror_qemu.git/blob - target/loongarch/gdbstub.c
2 * LOONGARCH gdb server stub
4 * Copyright (c) 2021 Loongson Technology Corporation Limited
6 * SPDX-License-Identifier: LGPL-2.1+
9 #include "qemu/osdep.h"
11 #include "internals.h"
12 #include "exec/gdbstub.h"
14 uint64_t read_fcc(CPULoongArchState
*env
)
18 for (int i
= 0; i
< 8; ++i
) {
19 ret
|= (uint64_t)env
->cf
[i
] << (i
* 8);
25 void write_fcc(CPULoongArchState
*env
, uint64_t val
)
27 for (int i
= 0; i
< 8; ++i
) {
28 env
->cf
[i
] = (val
>> (i
* 8)) & 1;
32 int loongarch_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
34 LoongArchCPU
*cpu
= LOONGARCH_CPU(cs
);
35 CPULoongArchState
*env
= &cpu
->env
;
37 if (0 <= n
&& n
< 32) {
38 return gdb_get_regl(mem_buf
, env
->gpr
[n
]);
41 return gdb_get_regl(mem_buf
, 0);
43 return gdb_get_regl(mem_buf
, env
->pc
);
45 return gdb_get_regl(mem_buf
, env
->CSR_BADV
);
50 int loongarch_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
52 LoongArchCPU
*cpu
= LOONGARCH_CPU(cs
);
53 CPULoongArchState
*env
= &cpu
->env
;
54 target_ulong tmp
= ldtul_p(mem_buf
);
57 if (0 <= n
&& n
< 32) {
59 length
= sizeof(target_ulong
);
62 length
= sizeof(target_ulong
);
67 static int loongarch_gdb_get_fpu(CPULoongArchState
*env
,
68 GByteArray
*mem_buf
, int n
)
70 if (0 <= n
&& n
< 32) {
71 return gdb_get_reg64(mem_buf
, env
->fpr
[n
]);
73 uint64_t val
= read_fcc(env
);
74 return gdb_get_reg64(mem_buf
, val
);
76 return gdb_get_reg32(mem_buf
, env
->fcsr0
);
81 static int loongarch_gdb_set_fpu(CPULoongArchState
*env
,
82 uint8_t *mem_buf
, int n
)
86 if (0 <= n
&& n
< 32) {
87 env
->fpr
[n
] = ldq_p(mem_buf
);
90 uint64_t val
= ldq_p(mem_buf
);
94 env
->fcsr0
= ldl_p(mem_buf
);
100 void loongarch_cpu_register_gdb_regs_for_features(CPUState
*cs
)
102 gdb_register_coprocessor(cs
, loongarch_gdb_get_fpu
, loongarch_gdb_set_fpu
,
103 41, "loongarch-fpu.xml", 0);