|
|
|
@ -158,20 +158,8 @@ static reg_t reg_from_bytes(size_t len, const uint8_t* bytes) |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
bool mmu_t::mmio_ok(reg_t paddr, size_t len, access_type UNUSED type) |
|
|
|
{ |
|
|
|
// Disallow access to debug region when not in debug mode
|
|
|
|
if (proc && sim && sim->is_debug_module_access(paddr, len) && !proc->state.debug_mode) |
|
|
|
return false; |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool mmu_t::mmio_fetch(reg_t paddr, size_t len, uint8_t* bytes) |
|
|
|
{ |
|
|
|
if (!mmio_ok(paddr, len, FETCH)) |
|
|
|
return false; |
|
|
|
|
|
|
|
return sim->mmio_fetch(paddr, len, bytes); |
|
|
|
} |
|
|
|
|
|
|
|
@ -191,9 +179,6 @@ bool mmu_t::mmio(reg_t paddr, size_t len, uint8_t* bytes, access_type type) |
|
|
|
bool naturally_aligned = (paddr & (len - 1)) == 0; |
|
|
|
|
|
|
|
if (power_of_2 && naturally_aligned) { |
|
|
|
if (!mmio_ok(paddr, len, type)) |
|
|
|
return false; |
|
|
|
|
|
|
|
if (type == STORE) |
|
|
|
return sim->mmio_store(paddr, len, bytes); |
|
|
|
else |
|
|
|
@ -533,13 +518,13 @@ std::optional<base_pmpaddr_csr_t*> mmu_t::pmp_lookup(reg_t addr, reg_t len, size |
|
|
|
|
|
|
|
bool mmu_t::pmp_ok(reg_t addr, reg_t len, access_type type, reg_t mode, bool hlvx) |
|
|
|
{ |
|
|
|
if (!proc || proc->n_pmp == 0) |
|
|
|
return true; |
|
|
|
|
|
|
|
// The debug module implementation relies on firmware (ROM) owned by spike.
|
|
|
|
// When executing code from this firmware we keep target PMP rules from
|
|
|
|
// blocking the simulator-owned debug firmware.
|
|
|
|
if (proc->state.debug_mode && sim && sim->is_debug_module_access(addr, len)) |
|
|
|
// The Debug Module address region is hidden from normal software.
|
|
|
|
// A hart can access it only in debug mode.
|
|
|
|
if (proc && sim && sim->is_debug_module_access(addr, len)) |
|
|
|
return proc->state.debug_mode; |
|
|
|
|
|
|
|
if (!proc || proc->n_pmp == 0) |
|
|
|
return true; |
|
|
|
|
|
|
|
if (auto pmp = pmp_lookup(addr, len, 0, proc->n_pmp); pmp.has_value()) |
|
|
|
|