diff options
Diffstat (limited to 'src/CP15.cpp')
-rw-r--r-- | src/CP15.cpp | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/src/CP15.cpp b/src/CP15.cpp index c258478..69551de 100644 --- a/src/CP15.cpp +++ b/src/CP15.cpp @@ -136,12 +136,10 @@ void ARMv5::UpdateITCMSetting() if (CP15Control & (1<<18)) { ITCMSize = 0x200 << ((ITCMSetting >> 1) & 0x1F); - //printf("ITCM [%08X] enabled at %08X, size %X\n", ITCMSetting, 0, ITCMSize); } else { ITCMSize = 0; - //printf("ITCM disabled\n"); } } @@ -150,6 +148,9 @@ void ARMv5::UpdateITCMSetting() // (not to the region range/enabled status) void ARMv5::UpdatePURegion(u32 n) { + if (!(CP15Control & (1<<0))) + return; + u32 coderw = (PU_CodeRW >> (4*n)) & 0xF; u32 datarw = (PU_DataRW >> (4*n)) & 0xF; @@ -274,6 +275,8 @@ void ARMv5::UpdatePURegions(bool update_all) // TODO: this is way unoptimized // should be okay unless the game keeps changing shit, tho if (update_all) UpdateRegionTimings(0x00000, 0x100000); + + // TODO: throw exception if the region we're running in has become non-executable, I guess } void ARMv5::UpdateRegionTimings(u32 addrstart, u32 addrend) @@ -522,7 +525,7 @@ void ARMv5::CP15Write(u32 id, u32 val) return; case 0x502: // data permissions - {printf("SET DATAPERM %08X (%08X %08X)\n", val,PU_DataRW,PU_DataRW ^ val); + { u32 diff = PU_DataRW ^ val; PU_DataRW = val; for (u32 i = 0; i < 8; i++) @@ -747,6 +750,15 @@ u32 ARMv5::CP15Read(u32 id) u32 ARMv5::CodeRead32(u32 addr, bool branch) { + /*if (branch || (!(addr & 0xFFF))) + { + if (!(PU_Map[addr>>12] & 0x04)) + { + PrefetchAbort(); + return 0; + } + }*/ + if (addr < ITCMSize) { CodeCycles = 1; @@ -772,6 +784,12 @@ u32 ARMv5::CodeRead32(u32 addr, bool branch) void ARMv5::DataRead8(u32 addr, u32* val) { + if (!(PU_Map[addr>>12] & 0x01)) + { + DataAbort(); + return; + } + DataRegion = addr; if (addr < ITCMSize) @@ -793,6 +811,12 @@ void ARMv5::DataRead8(u32 addr, u32* val) void ARMv5::DataRead16(u32 addr, u32* val) { + if (!(PU_Map[addr>>12] & 0x01)) + { + DataAbort(); + return; + } + DataRegion = addr; addr &= ~1; @@ -816,11 +840,11 @@ void ARMv5::DataRead16(u32 addr, u32* val) void ARMv5::DataRead32(u32 addr, u32* val) { - /*if (!(PU_Map[addr>>12] & 0x01)) - {printf("addr %08X very bad\n", addr); + if (!(PU_Map[addr>>12] & 0x01)) + { DataAbort(); return; - }*/ + } DataRegion = addr; @@ -866,6 +890,12 @@ void ARMv5::DataRead32S(u32 addr, u32* val) void ARMv5::DataWrite8(u32 addr, u8 val) { + if (!(PU_Map[addr>>12] & 0x02)) + { + DataAbort(); + return; + } + DataRegion = addr; if (addr < ITCMSize) @@ -890,6 +920,12 @@ void ARMv5::DataWrite8(u32 addr, u8 val) void ARMv5::DataWrite16(u32 addr, u16 val) { + if (!(PU_Map[addr>>12] & 0x02)) + { + DataAbort(); + return; + } + DataRegion = addr; addr &= ~1; @@ -916,11 +952,11 @@ void ARMv5::DataWrite16(u32 addr, u16 val) void ARMv5::DataWrite32(u32 addr, u32 val) { - /*if (!(PU_Map[addr>>12] & 0x02)) - {printf("addr %08X wr very bad\n", addr); + if (!(PU_Map[addr>>12] & 0x02)) + { DataAbort(); return; - }*/ + } DataRegion = addr; |