Replaces uses of target_ulong with vaddr/hwaddr/uint64_t where appropriate.
Note: This commit will print all addresses as 64-bit values, even for a 32-bit target. If breaking this interface is not an option we can instead opt for more runtime branching, as done by Joel Stanley in commit 409c7d8682a. Signed-off-by: Anton Johansson <[email protected]> --- target/riscv/monitor.c | 42 ++++++++++++++++++------------------------ target/riscv/meson.build | 2 +- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c index fc61638702..24c5244c36 100644 --- a/target/riscv/monitor.c +++ b/target/riscv/monitor.c @@ -21,35 +21,29 @@ #include "qemu/osdep.h" #include "qemu/ctype.h" #include "qemu/qemu-print.h" -#include "exec/target_long.h" -#include "cpu.h" +#include "target/riscv/cpu.h" +#include "target/riscv/cpu_bits.h" #include "target/riscv/tcg/csr.h" -#include "cpu_bits.h" #include "monitor/monitor.h" #include "monitor/hmp.h" #include "system/memory.h" #include "internals.h" -#ifdef TARGET_RISCV64 #define PTE_HEADER_FIELDS "vaddr paddr "\ "size attr\n" #define PTE_HEADER_DELIMITER "---------------- ---------------- "\ "---------------- -------\n" -#else -#define PTE_HEADER_FIELDS "vaddr paddr size attr\n" -#define PTE_HEADER_DELIMITER "-------- ---------------- -------- -------\n" -#endif #ifdef CONFIG_HMP /* Perform linear address sign extension */ -static target_ulong addr_canonical(int va_bits, target_ulong addr) +static vaddr addr_canonical(int va_bits, vaddr addr) { -#ifdef TARGET_RISCV64 - if (addr & (1UL << (va_bits - 1))) { - addr |= (hwaddr)-(1L << va_bits); + if (target_riscv64()) { + if (addr & (1UL << (va_bits - 1))) { + addr |= (hwaddr)-(1L << va_bits); + } } -#endif return addr; } @@ -60,8 +54,8 @@ static void print_pte_header(MonitorHMP *hmp) monitor_hmp_printf(hmp, PTE_HEADER_DELIMITER); } -static void print_pte(MonitorHMP *hmp, int va_bits, target_ulong vaddr, - hwaddr paddr, target_ulong size, int attr) +static void print_pte(MonitorHMP *hmp, int va_bits, vaddr vaddr, + hwaddr paddr, uint64_t size, int attr) { /* sanity check on vaddr */ if (vaddr >= (1UL << va_bits)) { @@ -72,7 +66,7 @@ static void print_pte(MonitorHMP *hmp, int va_bits, target_ulong vaddr, return; } - monitor_hmp_printf(hmp, TARGET_FMT_lx " " HWADDR_FMT_plx " " TARGET_FMT_lx + monitor_hmp_printf(hmp, "%016" VADDR_PRIx " " HWADDR_FMT_plx " %016" PRIx64 " %c%c%c%c%c%c%c\n", addr_canonical(va_bits, vaddr), paddr, size, @@ -86,17 +80,17 @@ static void print_pte(MonitorHMP *hmp, int va_bits, target_ulong vaddr, } static void walk_pte(MonitorHMP *hmp, AddressSpace *as, - hwaddr base, target_ulong start, + hwaddr base, uint64_t start, int level, int ptidxbits, int ptesize, int va_bits, - target_ulong *vbase, hwaddr *pbase, hwaddr *last_paddr, - target_ulong *last_size, int *last_attr) + vaddr *vbase, hwaddr *pbase, hwaddr *last_paddr, + uint64_t *last_size, int *last_attr) { const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; hwaddr pte_addr; hwaddr paddr; - target_ulong last_start = -1; - target_ulong pgsize; - target_ulong pte; + uint64_t last_start = -1; + uint64_t pgsize; + uint64_t pte; int ptshift; int attr; int idx; @@ -158,10 +152,10 @@ static void mem_info_svxx(MonitorHMP *hmp, CPUArchState *env) AddressSpace *as = env_cpu(env)->as; int levels, ptidxbits, ptesize, vm, va_bits; hwaddr base; - target_ulong vbase; + vaddr vbase; hwaddr pbase; hwaddr last_paddr; - target_ulong last_size; + uint64_t last_size; int last_attr; if (riscv_cpu_mxl(env) == MXL_RV32) { diff --git a/target/riscv/meson.build b/target/riscv/meson.build index d20eaa2269..a28466515e 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -22,7 +22,6 @@ riscv_stubs_ss = ss.source_set() riscv_system_ss = ss.source_set() riscv_system_ss.add(files( - 'monitor.c', )) riscv_user_ss = ss.source_set() @@ -36,6 +35,7 @@ riscv_common_system_ss.add(files( 'arch_dump.c', 'cpu.c', 'machine.c', + 'monitor.c', 'riscv-qmp-cmds.c', 'time_helper.c', )) -- 2.52.0
