|
@@ -116,8 +116,77 @@ static int loongarch_gdb_set_fpu(CPUState *cs, uint8_t *mem_buf, int n)
|
|
return length;
|
|
return length;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#define VREG_NUM 32
|
|
|
|
+#define REG64_LEN 64
|
|
|
|
+
|
|
|
|
+static int loongarch_gdb_get_vec(CPUState *cs, GByteArray *mem_buf, int n, int vl)
|
|
|
|
+{
|
|
|
|
+ LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
|
|
|
+ CPULoongArchState *env = &cpu->env;
|
|
|
|
+ int i, length = 0;
|
|
|
|
+
|
|
|
|
+ if (0 <= n && n < VREG_NUM) {
|
|
|
|
+ for (i = 0; i < vl / REG64_LEN; i++) {
|
|
|
|
+ length += gdb_get_reg64(mem_buf, env->fpr[n].vreg.D(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return length;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int loongarch_gdb_set_vec(CPUState *cs, uint8_t *mem_buf, int n, int vl)
|
|
|
|
+{
|
|
|
|
+ LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
|
|
|
+ CPULoongArchState *env = &cpu->env;
|
|
|
|
+ int i, length = 0;
|
|
|
|
+
|
|
|
|
+ if (0 <= n && n < VREG_NUM) {
|
|
|
|
+ for (i = 0; i < vl / REG64_LEN; i++) {
|
|
|
|
+ env->fpr[n].vreg.D(i) = ldq_le_p(mem_buf + 8 * i);
|
|
|
|
+ length += 8;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return length;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int loongarch_gdb_get_lsx(CPUState *cs, GByteArray *mem_buf, int n)
|
|
|
|
+{
|
|
|
|
+ return loongarch_gdb_get_vec(cs, mem_buf, n, LSX_LEN);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int loongarch_gdb_set_lsx(CPUState *cs, uint8_t *mem_buf, int n)
|
|
|
|
+{
|
|
|
|
+ return loongarch_gdb_set_vec(cs, mem_buf, n, LSX_LEN);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int loongarch_gdb_get_lasx(CPUState *cs, GByteArray *mem_buf, int n)
|
|
|
|
+{
|
|
|
|
+ return loongarch_gdb_get_vec(cs, mem_buf, n, LASX_LEN);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int loongarch_gdb_set_lasx(CPUState *cs, uint8_t *mem_buf, int n)
|
|
|
|
+{
|
|
|
|
+ return loongarch_gdb_set_vec(cs, mem_buf, n, LASX_LEN);
|
|
|
|
+}
|
|
|
|
+
|
|
void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs)
|
|
void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs)
|
|
{
|
|
{
|
|
- gdb_register_coprocessor(cs, loongarch_gdb_get_fpu, loongarch_gdb_set_fpu,
|
|
|
|
- gdb_find_static_feature("loongarch-fpu.xml"), 0);
|
|
|
|
|
|
+ LoongArchCPU *cpu = LOONGARCH_CPU(cs);
|
|
|
|
+ CPULoongArchState *env = &cpu->env;
|
|
|
|
+
|
|
|
|
+ if (FIELD_EX32(env->cpucfg[2], CPUCFG2, FP)) {
|
|
|
|
+ gdb_register_coprocessor(cs, loongarch_gdb_get_fpu, loongarch_gdb_set_fpu,
|
|
|
|
+ gdb_find_static_feature("loongarch-fpu.xml"), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (FIELD_EX32(env->cpucfg[2], CPUCFG2, LSX)) {
|
|
|
|
+ gdb_register_coprocessor(cs, loongarch_gdb_get_lsx, loongarch_gdb_set_lsx,
|
|
|
|
+ gdb_find_static_feature("loongarch-lsx.xml"), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (FIELD_EX32(env->cpucfg[2], CPUCFG2, LASX)) {
|
|
|
|
+ gdb_register_coprocessor(cs, loongarch_gdb_get_lasx, loongarch_gdb_set_lasx,
|
|
|
|
+ gdb_find_static_feature("loongarch-lasx.xml"), 0);
|
|
|
|
+ }
|
|
}
|
|
}
|