m68k: throw mmu configuration exception if SRP/CRP is invalid

This commit is contained in:
Sven Schnelle 2018-10-07 11:04:10 +02:00
parent be699d5197
commit d027ffafd6
2 changed files with 26 additions and 1 deletions

View File

@ -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;

View File

@ -1016,7 +1016,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
@ -1036,6 +1047,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();
@ -1047,6 +1064,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();