diff --git a/breakpoint_memory.cpp b/breakpoint_memory.cpp index 7adfa48..3584e9e 100644 --- a/breakpoint_memory.cpp +++ b/breakpoint_memory.cpp @@ -23,7 +23,7 @@ std::optional breakpoint_memory::is_triggered() const uint16_t v = 0; if (is_virtual) - v = b->read(addr, word_mode, rm_cur, true, i_space); + v = b->peek_word(addr); else v = b->read_physical(addr); diff --git a/bus.cpp b/bus.cpp index acbcfda..2fd37ad 100644 --- a/bus.cpp +++ b/bus.cpp @@ -242,7 +242,7 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm { int run_mode = mode_selection == rm_cur ? c->getPSW_runmode() : c->getPSW_prev_runmode(); - uint32_t m_offset = mmu_->calculate_physical_address(c, run_mode, addr_in, !peek_only, false, space); + uint32_t m_offset = mmu_->calculate_physical_address(c, run_mode, addr_in, false, space); uint32_t io_base = mmu_->get_io_base(); bool is_io = m_offset >= io_base; @@ -517,6 +517,7 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm } } + // TODO: this will fail for peek & odd addressing if (m_offset >= m->get_memory_size()) { if (peek_only) { TRACE("READ from %06o - out of range!", addr_in); @@ -563,7 +564,7 @@ write_rc_t bus::write(const uint16_t addr_in, const word_mode_t word_mode, uint1 if (mmu_->is_enabled() && (addr_in & 1) == 0 /* TODO remove this? */ && addr_in != ADDR_MMR0) mmu_->set_page_written_to(run_mode, d, apf); - uint32_t m_offset = mmu_->calculate_physical_address(c, run_mode, addr_in, true, true, space); + uint32_t m_offset = mmu_->calculate_physical_address(c, run_mode, addr_in, true, space); uint32_t io_base = mmu_->get_io_base(); bool is_io = m_offset >= io_base; diff --git a/console_ncurses.cpp b/console_ncurses.cpp index 1850c88..cd6f2cf 100644 --- a/console_ncurses.cpp +++ b/console_ncurses.cpp @@ -148,7 +148,7 @@ void console_ncurses::panel_update_thread() uint16_t current_PC = c->getPC(); memory_addresses_t rc = b->getMMU()->calculate_physical_address(run_mode, current_PC); - uint16_t current_instr = b->read_word(current_PC); + uint16_t current_instr = b->peek_word(current_PC); auto data = c->disassemble(current_PC); diff --git a/debugger.cpp b/debugger.cpp index 53058c1..23eb05e 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -933,7 +933,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto for(int i=0; iread(cur_addr, wm_word, rm_cur, true) : b->read_physical(cur_addr); + int val = parts[2] == "v" ? b->peek_word(cur_addr) : b->read_physical(cur_addr); if (val == -1) { cnsl->put_string_lf(format("Can't read from %06o\n", cur_addr)); diff --git a/mmu.cpp b/mmu.cpp index bc4e2c6..88ff8ff 100644 --- a/mmu.cpp +++ b/mmu.cpp @@ -473,7 +473,7 @@ void mmu::verify_page_length(cpu *const c, const uint16_t virt_addr, const int r } } -uint32_t mmu::calculate_physical_address(cpu *const c, const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write, const d_i_space_t space) +uint32_t mmu::calculate_physical_address(cpu *const c, const int run_mode, const uint16_t a, const bool is_write, const d_i_space_t space) { uint32_t m_offset = a; @@ -490,17 +490,15 @@ uint32_t mmu::calculate_physical_address(cpu *const c, const int run_mode, const if ((getMMR3() & 16) == 0) // off is 18bit m_offset &= 0x3ffff; - if (trap_on_failure) [[likely]] { - verify_page_access(c, a, run_mode, d, apf, is_write); + verify_page_access(c, a, run_mode, d, apf, is_write); - // e.g. ram or i/o, not unmapped - uint32_t io_base = get_io_base(); - bool is_io = m_offset >= io_base; + // e.g. ram or i/o, not unmapped + uint32_t io_base = get_io_base(); + bool is_io = m_offset >= io_base; - verify_access_valid(c, m_offset, run_mode, d, apf, is_io, is_write); + verify_access_valid(c, m_offset, run_mode, d, apf, is_io, is_write); - verify_page_length(c, a, run_mode, d, apf, is_write); - } + verify_page_length(c, a, run_mode, d, apf, is_write); } return m_offset; diff --git a/mmu.h b/mmu.h index c1316d4..c97987c 100644 --- a/mmu.h +++ b/mmu.h @@ -94,7 +94,7 @@ class mmu : public device memory_addresses_t calculate_physical_address(const int run_mode, const uint16_t a) const; std::pair get_trap_action(const int run_mode, const bool d, const int apf, const bool is_write); - uint32_t calculate_physical_address(cpu *const c, const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write, const d_i_space_t space); + uint32_t calculate_physical_address(cpu *const c, const int run_mode, const uint16_t a, const bool is_write, const d_i_space_t space); uint16_t getMMR0() const { return MMR0; } uint16_t getMMR1() const { return MMR1; }