diff options
Diffstat (limited to 'src/devices/cpu/arm7/arm7.cpp')
-rw-r--r-- | src/devices/cpu/arm7/arm7.cpp | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/src/devices/cpu/arm7/arm7.cpp b/src/devices/cpu/arm7/arm7.cpp index 813cf22c619..7f479a668d4 100644 --- a/src/devices/cpu/arm7/arm7.cpp +++ b/src/devices/cpu/arm7/arm7.cpp @@ -32,21 +32,20 @@ TODO: #include "emu.h" #include "debug/debugcon.h" -#include "debug/debugcmd.h" #include "debugger.h" #include "arm7.h" #include "arm7core.h" //include arm7 core #include "arm7help.h" -#define LOG_MMU (1 << 0) -#define LOG_DSP (1 << 1) -#define LOG_COPRO_READS (1 << 2) -#define LOG_COPRO_WRITES (1 << 3) -#define LOG_COPRO_UNKNOWN (1 << 4) -#define LOG_COPRO_RESERVED (1 << 5) -#define LOG_TLB (1 << 6) -#define LOG_TLB_MISS (1 << 7) -#define LOG_PREFETCH (1 << 8) +#define LOG_MMU (1U << 1) +#define LOG_DSP (1U << 2) +#define LOG_COPRO_READS (1U << 3) +#define LOG_COPRO_WRITES (1U << 4) +#define LOG_COPRO_UNKNOWN (1U << 5) +#define LOG_COPRO_RESERVED (1U << 6) +#define LOG_TLB (1U << 7) +#define LOG_TLB_MISS (1U << 8) +#define LOG_PREFETCH (1U << 9) #define VERBOSE (0) // (LOG_COPRO_READS | LOG_COPRO_WRITES | LOG_COPRO_UNKNOWN | LOG_COPRO_RESERVED) #include "logmacro.h" @@ -300,6 +299,7 @@ void arm7_cpu_device::update_reg_ptr() void arm7_cpu_device::set_cpsr(uint32_t val) { uint8_t old_mode = GET_CPSR & MODE_FLAG; + bool call_hook = false; if (m_archFlags & ARCHFLAG_MODE26) { if ((val & 0x10) != (m_r[eCPSR] & 0x10)) @@ -315,6 +315,7 @@ void arm7_cpu_device::set_cpsr(uint32_t val) // 32 -> 26 m_r[eR15] = (m_r[eR15] & 0x03FFFFFC) /* PC */ | (val & 0xF0000000) /* N Z C V */ | ((val & 0x000000C0) << (26 - 6)) /* I F */ | (val & 0x00000003) /* M1 M0 */; } + call_hook = true; } else { @@ -329,11 +330,17 @@ void arm7_cpu_device::set_cpsr(uint32_t val) { val |= 0x10; // force valid mode } + if ((val & T_MASK) != (m_r[eCPSR] & T_MASK)) + call_hook = true; m_r[eCPSR] = val; if ((GET_CPSR & MODE_FLAG) != old_mode) { + if ((GET_CPSR & MODE_FLAG) == eARM7_MODE_USER || old_mode == eARM7_MODE_USER) + call_hook = true; update_reg_ptr(); } + if (call_hook) + debugger_privilege_hook(); } @@ -854,40 +861,40 @@ bool arm7_cpu_device::translate_vaddr_to_paddr(offs_t &vaddr, const int flags) } } -void arm7_cpu_device::translate_insn_command(const std::vector<std::string> ¶ms) +void arm7_cpu_device::translate_insn_command(const std::vector<std::string_view> ¶ms) { - translate_command(params, TRANSLATE_FETCH); + translate_command(params, TR_FETCH); } -void arm7_cpu_device::translate_data_command(const std::vector<std::string> ¶ms) +void arm7_cpu_device::translate_data_command(const std::vector<std::string_view> ¶ms) { - translate_command(params, TRANSLATE_READ); + translate_command(params, TR_READ); } -void arm7_cpu_device::translate_command(const std::vector<std::string> ¶ms, int intention) +void arm7_cpu_device::translate_command(const std::vector<std::string_view> ¶ms, int intention) { uint64_t vaddr; - if (!machine().debugger().commands().validate_number_parameter(params[0], vaddr)) return; + if (!machine().debugger().console().validate_number_parameter(params[0], vaddr)) return; vaddr &= 0xffffffff; offs_t paddr = (offs_t)vaddr; - bool can_translate = memory_translate(AS_PROGRAM, intention, paddr); + address_space *space = nullptr; + bool can_translate = memory_translate(AS_PROGRAM, intention, paddr, space); if (can_translate) - machine().debugger().console().printf("%s vaddr %08x => phys %08x\n", intention == TRANSLATE_FETCH ? "instruction" : "data", (uint32_t)vaddr, paddr); + machine().debugger().console().printf("%s vaddr %08x => phys %08x\n", intention == TR_FETCH ? "instruction" : "data", (uint32_t)vaddr, paddr); else - machine().debugger().console().printf("%s vaddr %08x => unmapped\n", intention == TRANSLATE_FETCH ? "instruction" : "data"); + machine().debugger().console().printf("%s vaddr %08x => unmapped\n", intention == TR_FETCH ? "instruction" : "data"); } -bool arm7_cpu_device::memory_translate(int spacenum, int intention, offs_t &address) +bool arm7_cpu_device::memory_translate(int spacenum, int intention, offs_t &address, address_space *&target_space) { + target_space = &space(spacenum); /* only applies to the program address space and only does something if the MMU's enabled */ if (spacenum == AS_PROGRAM && (m_control & COPRO_CTRL_MMU_EN)) { - int intention_type = intention & TRANSLATE_TYPE_MASK; - - const int flags = (intention_type & TRANSLATE_FETCH) ? ARM7_TLB_ABORT_P : ARM7_TLB_ABORT_D; + const int flags = intention == TR_FETCH ? ARM7_TLB_ABORT_P : ARM7_TLB_ABORT_D; if (address < 0x2000000) address += m_pid_offset; @@ -2124,8 +2131,7 @@ uint32_t arm946es_cpu_device::arm7_cpu_read32(uint32_t addr) if (addr & 3) { uint32_t *wp = (uint32_t *)&ITCM[(addr & ~3)&0x7fff]; - result = *wp; - result = (result >> (8 * (addr & 3))) | (result << (32 - (8 * (addr & 3)))); + result = rotr_32(*wp, 8 * (addr & 3)); } else { @@ -2138,8 +2144,7 @@ uint32_t arm946es_cpu_device::arm7_cpu_read32(uint32_t addr) if (addr & 3) { uint32_t *wp = (uint32_t *)&DTCM[(addr & ~3)&0x3fff]; - result = *wp; - result = (result >> (8 * (addr & 3))) | (result << (32 - (8 * (addr & 3)))); + result = rotr_32(*wp, 8 * (addr & 3)); } else { @@ -2151,8 +2156,7 @@ uint32_t arm946es_cpu_device::arm7_cpu_read32(uint32_t addr) { if (addr & 3) { - result = m_program->read_dword(addr & ~3); - result = (result >> (8 * (addr & 3))) | (result << (32 - (8 * (addr & 3)))); + result = rotr_32(m_program->read_dword(addr & ~3), 8 * (addr & 3)); } else { @@ -2322,8 +2326,7 @@ uint32_t arm7_cpu_device::arm7_cpu_read32(uint32_t addr) if (addr & 3) { - result = m_program->read_dword(addr & ~3); - result = (result >> (8 * (addr & 3))) | (result << (32 - (8 * (addr & 3)))); + result = rotr_32(m_program->read_dword(addr & ~3), 8 * (addr & 3)); } else { |