diff options
author | R. Belmont <rb6502@users.noreply.github.com> | 2018-10-07 08:53:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-07 08:53:07 -0400 |
commit | bd42375413f46b838c68a8bda7f734d4541e0f3a (patch) | |
tree | 97c483c5c31de7ea23ccacf20fe2b9fcfc5939d4 | |
parent | 9a04174b7b14c07d364ff08d437bc69503f1663f (diff) | |
parent | d027ffafd6c25e07e6c222f7ec511bdbfabdd8dd (diff) |
Merge pull request #4078 from hp9k/m68k_mmu_config_exception
m68k: throw mmu configuration exception if SRP/CRP is invalid (nw)
-rw-r--r-- | src/devices/cpu/m68000/m68kcpu.h | 1 | ||||
-rw-r--r-- | src/devices/cpu/m68000/m68kmmu.h | 26 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/devices/cpu/m68000/m68kcpu.h b/src/devices/cpu/m68000/m68kcpu.h index bd3fed4e2ca..28b56600a56 100644 --- a/src/devices/cpu/m68000/m68kcpu.h +++ b/src/devices/cpu/m68000/m68kcpu.h @@ -55,6 +55,7 @@ static constexpr int EXCEPTION_UNINITIALIZED_INTERRUPT = 15; static constexpr int EXCEPTION_SPURIOUS_INTERRUPT = 24; static constexpr int EXCEPTION_INTERRUPT_AUTOVECTOR = 24; static constexpr int EXCEPTION_TRAP_BASE = 32; +static constexpr int EXCEPTION_MMU_CONFIGURATION = 56; // only on 020/030 /* Function codes set by CPU during data/address bus activity */ static constexpr int FUNCTION_CODE_USER_DATA = 1; diff --git a/src/devices/cpu/m68000/m68kmmu.h b/src/devices/cpu/m68000/m68kmmu.h index e7f4c13fa24..2d9270d5615 100644 --- a/src/devices/cpu/m68000/m68kmmu.h +++ b/src/devices/cpu/m68000/m68kmmu.h @@ -1026,7 +1026,18 @@ void m68881_mmu_ops() if (m_mmu_tc & 0x80000000) { - m_pmmu_enabled = 1; + int bits = 0; + for(int shift = 20; shift >= 0; shift -= 4) { + bits += (m_mmu_tc >> shift) & 0x0f; + } + + if (bits != 32 || !((m_mmu_tc >> 23) & 1)) { + logerror("MMU: TC invalid!\n"); + m_mmu_tc &= ~0x80000000; + m68ki_exception_trap(EXCEPTION_MMU_CONFIGURATION); + } else { + m_pmmu_enabled = 1; + } // printf("PMMU enabled\n"); } else @@ -1046,6 +1057,12 @@ void m68881_mmu_ops() m_mmu_srp_limit = (temp64>>32) & 0xffffffff; m_mmu_srp_aptr = temp64 & 0xffffffff; // printf("PMMU: SRP limit = %08x aptr = %08x\n", m_mmu_srp_limit, m_mmu_srp_aptr); + // CRP type 0 is not allowed + if ((m_mmu_crp_limit & 3) == 0) { + m68ki_exception_trap(EXCEPTION_MMU_CONFIGURATION); + return; + } + if (!(modes & 0x100)) { pmmu_atc_flush(); @@ -1057,6 +1074,13 @@ void m68881_mmu_ops() m_mmu_crp_limit = (temp64>>32) & 0xffffffff; m_mmu_crp_aptr = temp64 & 0xffffffff; // printf("PMMU: CRP limit = %08x aptr = %08x\n", m_mmu_crp_limit, m_mmu_crp_aptr); + // CRP type 0 is not allowed + if ((m_mmu_crp_limit & 3) == 0) { + m68ki_exception_trap(EXCEPTION_MMU_CONFIGURATION); + return; + } + + if (!(modes & 0x100)) { pmmu_atc_flush(); |