diff --git a/riscv/decode.h b/riscv/decode.h index 51ecbebc..a4bbac66 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -245,7 +245,4 @@ private: #define set_field(reg, mask, val) \ (((reg) & ~(std::remove_cv::type)(mask)) | (((std::remove_cv::type)(val) * ((mask) & ~((mask) << 1))) & (std::remove_cv::type)(mask))) -#define DEBUG_START 0x0 -#define DEBUG_END (0x1000 - 1) - #endif diff --git a/riscv/mmu.cc b/riscv/mmu.cc index b080697e..e95b5755 100644 --- a/riscv/mmu.cc +++ b/riscv/mmu.cc @@ -6,6 +6,7 @@ #include "simif.h" #include "processor.h" #include "decode_macros.h" +#include "platform.h" mmu_t::mmu_t(simif_t* sim, endianness_t endianness, processor_t* proc, reg_t cache_blocksz) : sim(sim), proc(proc), blocksz(cache_blocksz), @@ -140,8 +141,8 @@ reg_t reg_from_bytes(size_t len, const uint8_t* bytes) bool mmu_t::mmio_ok(reg_t paddr, access_type UNUSED type) { // Disallow access to debug region when not in debug mode - static_assert(DEBUG_START == 0); - if (/* paddr >= DEBUG_START && */ paddr <= DEBUG_END && proc && !proc->state.debug_mode) + reg_t debug_start = DEBUG_START; // suppress -Wtype-limits + if (paddr >= debug_start && paddr - debug_start < DEBUG_SIZE && proc && !proc->state.debug_mode) return false; return true; diff --git a/riscv/platform.h b/riscv/platform.h index c8a5bf4b..5b794da2 100644 --- a/riscv/platform.h +++ b/riscv/platform.h @@ -19,5 +19,7 @@ #define NS16550_INTERRUPT_ID 1 #define EXT_IO_BASE 0x40000000 #define DRAM_BASE 0x80000000 +#define DEBUG_START 0x0 +#define DEBUG_SIZE 0x1000 #endif