Rewrite k11ext mmu mapping func + linker script
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
|
||||
struct KExtParameters
|
||||
{
|
||||
u32 ALIGN(0x400) L2MMUTableFor0x40000000[256];
|
||||
u32 basePA;
|
||||
void *originalHandlers[4];
|
||||
u32 L1MMUTableAddrs[4];
|
||||
@@ -46,18 +45,20 @@ void relocateAndSetupMMU(u32 coreId, u32 *L1Table)
|
||||
{
|
||||
struct KExtParameters *p0 = (struct KExtParameters *)((u32)&kExtParameters - 0x40000000 + 0x18000000);
|
||||
struct KExtParameters *p = (struct KExtParameters *)((u32)&kExtParameters - 0x40000000 + p0->basePA);
|
||||
u32 *L2Table = (u32 *)(p0->basePA - 0x1000);
|
||||
|
||||
if(coreId == 0)
|
||||
{
|
||||
// Relocate ourselves, and clear BSS
|
||||
// This is only OK because the jumps will be relative...
|
||||
// This is only OK because the jumps will be relative & there's no mode switch...
|
||||
memcpy((void *)p0->basePA, (const void *)0x18000000, __bss_start__ - __start__);
|
||||
memset((u32 *)(p0->basePA + (__bss_start__ - __start__)), 0, __bss_end__ - __bss_start__);
|
||||
|
||||
// Map the kernel ext to 0x40000000
|
||||
// 4KB extended small pages: [SYS:RW USR:-- X TYP:NORMAL SHARED OUTER NOCACHE, INNER CACHED WB WA]
|
||||
memset(L2Table, 0, 4 * 256);
|
||||
for(u32 offset = 0; offset < (u32)(__end__ - __start__); offset += 0x1000)
|
||||
p->L2MMUTableFor0x40000000[offset >> 12] = (p0->basePA + offset) | 0x516;
|
||||
L2Table[offset >> 12] = (p0->basePA + offset) | 0x516;
|
||||
|
||||
__asm__ __volatile__ ("sev");
|
||||
}
|
||||
@@ -74,7 +75,7 @@ void relocateAndSetupMMU(u32 coreId, u32 *L1Table)
|
||||
L1Table[i + (VA >> 20)] = PA | attribs;
|
||||
}
|
||||
|
||||
L1Table[0x40000000 >> 20] = (u32)p->L2MMUTableFor0x40000000 | 1;
|
||||
L1Table[0x40000000 >> 20] = (u32)L2Table | 1;
|
||||
|
||||
p->L1MMUTableAddrs[coreId] = (u32)L1Table;
|
||||
}
|
||||
@@ -257,7 +258,7 @@ void main(FcramLayout *layout, KCoreContext *ctxs)
|
||||
u32 TTBCR_;
|
||||
s64 nb;
|
||||
|
||||
layout->systemSize -= __end__ - __start__;
|
||||
layout->systemSize -= 0x1000 + __end__ - __start__;
|
||||
fcramLayout = *layout;
|
||||
coreCtxs = ctxs;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.section .text.start, "ax", %progbits
|
||||
.balign 32
|
||||
.balign 4
|
||||
.global _start
|
||||
_start:
|
||||
b start
|
||||
|
||||
@@ -100,7 +100,7 @@ void *svcHook(u8 *pageEnd)
|
||||
case 0x17:
|
||||
if(strcmp(codeSetOfProcess(currentProcess)->processName, "pm") == 0) // only called twice in pm, by the same function
|
||||
{
|
||||
*(vu32 *)(configPage + 0x44) += __end__ - __start__;
|
||||
*(vu32 *)(configPage + 0x44) += 0x1000 + __end__ - __start__;
|
||||
doingVeryShittyPmResLimitWorkaround = true;
|
||||
}
|
||||
return officialSVCs[0x17];
|
||||
@@ -127,7 +127,7 @@ void *svcHook(u8 *pageEnd)
|
||||
case 0x79:
|
||||
if(doingVeryShittyPmResLimitWorkaround)
|
||||
{
|
||||
*(vu32 *)(configPage + 0x44) -= __end__ - __start__;
|
||||
*(vu32 *)(configPage + 0x44) -= 0x1000 + __end__ - __start__;
|
||||
doingVeryShittyPmResLimitWorkaround = false;
|
||||
}
|
||||
return officialSVCs[0x79];
|
||||
|
||||
Reference in New Issue
Block a user