From 78332ffbafeae5e9079bfc69ff136c5d24644a4c Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Sat, 23 Apr 2016 10:40:23 -0700 Subject: [PATCH] Make sure to translate Debug RAM addresses also. --- riscv/decode.h | 3 +++ riscv/sim.cc | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/riscv/decode.h b/riscv/decode.h index bf6a84c..9b9df5b 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -237,9 +237,12 @@ private: #define DCSR_CAUSE_STEPPED 4 #define DCSR_CAUSE_HALT 5 +#define DEBUG_START 0xfffffffffffff000 #define DEBUG_RAM_START 0xfffffffffffffc00 // TODO: 0x400 #define DEBUG_RAM_END (DEBUG_RAM_START + 64) #define DEBUG_ROM_START 0xfffffffffffff800 // TODO: 0x800 #define DEBUG_ROM_END (DEBUG_ROM_START + debug_rom_raw_len) +#define DEBUG_END 0xffffffffffffffff +#define DEBUG_SIZE (DEBUG_END - DEBUG_START + 1) #endif diff --git a/riscv/sim.cc b/riscv/sim.cc index 5cf2646..7c50425 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -42,10 +42,11 @@ sim_t::sim_t(const char* isa, size_t nprocs, size_t mem_mb, bool halted, (unsigned long)memsz, (unsigned long)memsz0); /* Copy Debug ROM into the end of the allocated block, because we surely - * didn't succeed in allocation 0xfffffffff800 bytes. */ + * didn't succeed in allocating 0xfffffffff800 bytes. */ /* TODO: Once everything uses the new memory map, just put this at the * address that it actually belongs at. */ - memcpy(mem + memsz - debug_rom_raw_len, debug_rom_raw, debug_rom_raw_len); + memcpy(mem + memsz - DEBUG_SIZE + DEBUG_ROM_START - DEBUG_START, + debug_rom_raw, debug_rom_raw_len); debug_mmu = new mmu_t(this, NULL); -- 2.30.2