@@ -250,4 +250,7 @@ static inline int insn_len(uint16_t first_word)
return (first_word & 3) == 3 ? 4 : 2;
}
+int riscv_monitor_get_register_legacy(CPUState *cs, const char *name,
+ int64_t *pval);
+
#endif
@@ -2733,6 +2733,7 @@ static const struct SysemuCPUOps riscv_sysemu_ops = {
.get_phys_page_debug = riscv_cpu_get_phys_page_debug,
.write_elf64_note = riscv_cpu_write_elf64_note,
.write_elf32_note = riscv_cpu_write_elf32_note,
+ .monitor_get_register = riscv_monitor_get_register_legacy,
.legacy_vmsd = &vmstate_riscv_cpu,
};
#endif
@@ -27,6 +27,7 @@
#include "monitor/hmp.h"
#include "monitor/hmp-target.h"
#include "system/memory.h"
+#include "internals.h"
#ifdef TARGET_RISCV64
#define PTE_HEADER_FIELDS "vaddr paddr "\
@@ -311,16 +312,18 @@ static bool reg_is_vreg(const char *name)
return false;
}
-int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval)
+int riscv_monitor_get_register_legacy(CPUState *cs, const char *name,
+ int64_t *pval)
{
- CPURISCVState *env = &RISCV_CPU(cs)->env;
+ RISCVCPU *hart = RISCV_CPU(cs);
+ CPURISCVState *env = cpu_env(cs);
target_ulong val = 0;
uint64_t val64 = 0;
int i;
if (reg_is_ulong_integer(env, name, &val, false) ||
reg_is_ulong_integer(env, name, &val, true)) {
- *pval = val;
+ *pval = riscv_cpu_is_32bit(hart) ? (int32_t)val : val;
return 0;
}
@@ -369,7 +372,7 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval)
* to do the filtering of the registers that are present.
*/
if (res == RISCV_EXCP_NONE) {
- *pval = val;
+ *pval = riscv_cpu_is_32bit(hart) ? (int32_t)val : val;
return 0;
}
}