Further TLB fix
Imagine testing 2 segments and having them work perfectly fine, and then you go for the third, and it somehow doesn't work, because clearly you can't trust a system that loads 3 things in a row to just map it to the first 3 :^) So guess we have a mapping segment table now to track it.
This commit is contained in:
1 parent
bc1fac4b9e
commit
bc903a73fc
3 files changed
+15
-4
No files matched your search
@@ -314,15 +314,22 @@ static void level_cmd_init_level(void) {
|
||||
}
|
||||
|
||||
extern s32 gTlbEntries;
|
||||
extern u8 gTlbSegments[32];
|
||||
|
||||
//This clears all the temporary bank TLB maps. group0, common1 and behavourdata are always loaded,
|
||||
//and they're also loaded first, so that means we just leave the first 3 indexes mapped.
|
||||
void unmap_tlbs(void)
|
||||
{
|
||||
while (gTlbEntries > 3)
|
||||
s32 i;
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
osUnmapTLB(gTlbEntries);
|
||||
gTlbEntries--;
|
||||
if (gTlbSegments[i] && i != 0x17 && i != 0x16 && i != 0x13)
|
||||
{
|
||||
osUnmapTLB(gTlbEntries);
|
||||
gTlbSegments[i] = 0;
|
||||
gTlbEntries--;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "mario.h"
|
||||
#include "save_file.h"
|
||||
#include "game_init.h"
|
||||
#include "obj_behaviors_2.h"
|
||||
#include "level_headers.h"
|
||||
#include "level_misc_macros.h"
|
||||
|
||||
#define o gCurrentObject
|
||||
|
||||
|
||||
+2
-1
@@ -28,7 +28,6 @@
|
||||
#define ALIGN4(val) (((val) + 0x3) & ~0x3)
|
||||
#define ALIGN8(val) (((val) + 0x7) & ~0x7)
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
//#define ALIGN(val, alignment) (((val) + ((alignment) - 1)) & ~((alignment) - 1))
|
||||
|
||||
struct MainPoolState {
|
||||
u32 freeSpace;
|
||||
@@ -307,6 +306,7 @@ void *dynamic_dma_read(u8 *srcStart, u8 *srcEnd, u32 side, u32 alignment, u32 bs
|
||||
|
||||
#define TLB_PAGE_SIZE 4096 //Blocksize of TLB transfers. Larger values can be faster to transfer, but more wasteful of RAM.
|
||||
s32 gTlbEntries = 0;
|
||||
u8 gTlbSegments[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
void mapTLBPages(uintptr_t virtualAddress, uintptr_t physicalAddress, s32 length)
|
||||
{
|
||||
@@ -344,6 +344,7 @@ void *load_segment(s32 segment, u8 *srcStart, u8 *srcEnd, u32 side, u8 *bssStart
|
||||
u8 *realAddr = (u8 *)ALIGN((uintptr_t)addr, TLB_PAGE_SIZE);
|
||||
set_segment_base_addr(segment, realAddr);
|
||||
mapTLBPages(segment << 24, VIRTUAL_TO_PHYSICAL(realAddr), (srcEnd - srcStart) + ((uintptr_t)bssEnd - (uintptr_t)bssStart));
|
||||
gTlbSegments[segment] = gTlbEntries;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user