arm7: Add debugger privilege callback for 26/32, A/T and user mode changes

This commit is contained in:
AJR 2022-03-13 11:58:29 -04:00
parent 1c4be582e9
commit cf53896b89
2 changed files with 10 additions and 2 deletions

View File

@ -300,6 +300,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 +316,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 +331,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();
}

View File

@ -1676,8 +1676,8 @@ void arm7_cpu_device::arm7ops_0123(uint32_t insn)
R15 = GetRegister(insn & 0x0f);
// If new PC address has A0 set, switch to Thumb mode
if (R15 & 1) {
set_cpsr(GET_CPSR|T_MASK);
R15--;
set_cpsr(GET_CPSR|T_MASK);
}
}
else if ((insn & 0x0ff000f0) == 0x01200030) // BLX Rn - v5
@ -1688,8 +1688,8 @@ void arm7_cpu_device::arm7ops_0123(uint32_t insn)
R15 = GetRegister(insn & 0x0f);
// If new PC address has A0 set, switch to Thumb mode
if (R15 & 1) {
set_cpsr(GET_CPSR|T_MASK);
R15--;
set_cpsr(GET_CPSR|T_MASK);
}
}
else if ((insn & 0x0ff000f0) == 0x01600010) // CLZ - v5