You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
currently when a data/prefetch abort occurs the "defaultExceptionHandler" will assume a data abort occurred and try to read and decode an instruction only if the pc was within normal main ram or itcm bounds.
It would make the exception handler smarter and more flexible to instead check for a prefetch abort first by manually calculating the region bounds from the mpu region sizing regs and checking against the region's code read perms to determine if the pc was within an executable region, and then try to decode the instruction if so. (though you might also want to ensure it's a readable region as well? though maybe that's overengineering a debug tool)
Some example sorta pseudo-code:
bool prefetchabort = true;
for (int i = 7; i >= 0; i--) // higher number regions have higher priority
{
if (!(MPURegionSize[i] & 1)) continue; // check if region is enabled
int size = 1 << std::max(12, ((MPURegionSize[i] & 0x3E) >> 1) + 1); // get the size of the region, minimum size is 12.
u32 startaddr = MPURegionSize[i] & ~(size-1); // start address is size aligned
u32 endaddr = startaddr + size-1;
if ((PC > startaddr) && (PC < endaddr))
{
prefetchabort = !RegionCodeRead[i]; // ngl idk what the proper way to check for region access perms is? you'd probably have to use a switch statement to look it up? and it'd also be different if the exception occurred in user mode (idk why you'd want to be in user mode tho)
break;
}
}
The text was updated successfully, but these errors were encountered:
Does the NTR BIOS not have any other way of distinguishing between a data and prefetch abort? That's honestly a little disappointing.
asiekierka
changed the title
Prefetch Aborts and the default exception handler
Use MPU regions instead of hardcoded RAM information to better distinguish data and prefetch aborts
Nov 8, 2024
There are separate exception vector offsets for prefetch and data aborts, but annoyingly the (ds and dsi) arm9 bios makes no efforts to distinguish them by immediately redirecting them to the same handler, with no clarifying info preserved. So only with the low exception vector can you distinguish them.
Yeah, I'm not 100% on throwing out the BIOS handler just yet; especially as we can't do that on ARM7. Let's stick to using MPU region information instead, then.
currently when a data/prefetch abort occurs the "defaultExceptionHandler" will assume a data abort occurred and try to read and decode an instruction only if the pc was within normal main ram or itcm bounds.
It would make the exception handler smarter and more flexible to instead check for a prefetch abort first by manually calculating the region bounds from the mpu region sizing regs and checking against the region's code read perms to determine if the pc was within an executable region, and then try to decode the instruction if so. (though you might also want to ensure it's a readable region as well? though maybe that's overengineering a debug tool)
Some example sorta pseudo-code:
The text was updated successfully, but these errors were encountered: