提交 cbb26c9a 编写于 作者: M Maciej W. Rozycki 提交者: Leon Alrae

target-mips: gdbstub: Clean up FPU register handling

Rewrite the FPU register access parts of `mips_cpu_gdb_read_register'
and `mips_cpu_gdb_write_register' for consistency between each other.
Signed-off-by: NMaciej W. Rozycki <macro@codesourcery.com>
Reviewed-by: NLeon Alrae <leon.alrae@imgtec.com>
Signed-off-by: NLeon Alrae <leon.alrae@imgtec.com>
上级 c48245f0
...@@ -29,8 +29,13 @@ int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) ...@@ -29,8 +29,13 @@ int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
if (n < 32) { if (n < 32) {
return gdb_get_regl(mem_buf, env->active_tc.gpr[n]); return gdb_get_regl(mem_buf, env->active_tc.gpr[n]);
} }
if (env->CP0_Config1 & (1 << CP0C1_FP)) { if (env->CP0_Config1 & (1 << CP0C1_FP) && n >= 38 && n < 72) {
if (n >= 38 && n < 70) { switch (n) {
case 70:
return gdb_get_regl(mem_buf, (int32_t)env->active_fpu.fcr31);
case 71:
return gdb_get_regl(mem_buf, (int32_t)env->active_fpu.fcr0);
default:
if (env->CP0_Status & (1 << CP0St_FR)) { if (env->CP0_Status & (1 << CP0St_FR)) {
return gdb_get_regl(mem_buf, return gdb_get_regl(mem_buf,
env->active_fpu.fpr[n - 38].d); env->active_fpu.fpr[n - 38].d);
...@@ -39,12 +44,6 @@ int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) ...@@ -39,12 +44,6 @@ int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX]); env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX]);
} }
} }
switch (n) {
case 70:
return gdb_get_regl(mem_buf, (int32_t)env->active_fpu.fcr31);
case 71:
return gdb_get_regl(mem_buf, (int32_t)env->active_fpu.fcr0);
}
} }
switch (n) { switch (n) {
case 32: case 32:
...@@ -64,8 +63,10 @@ int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) ...@@ -64,8 +63,10 @@ int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
return gdb_get_regl(mem_buf, 0); /* fp */ return gdb_get_regl(mem_buf, 0); /* fp */
case 89: case 89:
return gdb_get_regl(mem_buf, (int32_t)env->CP0_PRid); return gdb_get_regl(mem_buf, (int32_t)env->CP0_PRid);
} default:
if (n >= 73 && n <= 88) { if (n > 89) {
return 0;
}
/* 16 embedded regs. */ /* 16 embedded regs. */
return gdb_get_regl(mem_buf, 0); return gdb_get_regl(mem_buf, 0);
} }
...@@ -89,15 +90,7 @@ int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) ...@@ -89,15 +90,7 @@ int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
env->active_tc.gpr[n] = tmp; env->active_tc.gpr[n] = tmp;
return sizeof(target_ulong); return sizeof(target_ulong);
} }
if (env->CP0_Config1 & (1 << CP0C1_FP) if (env->CP0_Config1 & (1 << CP0C1_FP) && n >= 38 && n < 72) {
&& n >= 38 && n < 72) {
if (n < 70) {
if (env->CP0_Status & (1 << CP0St_FR)) {
env->active_fpu.fpr[n - 38].d = tmp;
} else {
env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX] = tmp;
}
}
switch (n) { switch (n) {
case 70: case 70:
env->active_fpu.fcr31 = tmp & 0xFF83FFFF; env->active_fpu.fcr31 = tmp & 0xFF83FFFF;
...@@ -107,6 +100,13 @@ int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) ...@@ -107,6 +100,13 @@ int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
case 71: case 71:
/* FIR is read-only. Ignore writes. */ /* FIR is read-only. Ignore writes. */
break; break;
default:
if (env->CP0_Status & (1 << CP0St_FR)) {
env->active_fpu.fpr[n - 38].d = tmp;
} else {
env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX] = tmp;
}
break;
} }
return sizeof(target_ulong); return sizeof(target_ulong);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册