Adjust config mem values

This commit is contained in:
TuxSH 2017-06-14 01:29:55 +02:00
parent 2ab41dbd01
commit 19d68b6df4
6 changed files with 44 additions and 14 deletions

View File

@ -94,8 +94,13 @@ extern bool *isDevUnit;
extern vu8 *configPage;
extern u32 kernelVersion;
extern FcramLayout fcramLayout;
extern void *originalHandlers[8];
extern u32 nbSection0Modules;
extern u8 __start__[], __end__[], __bss_start__[], __bss_end__[];
extern Result (*InterruptManager__MapInterrupt)(InterruptManager *manager, KBaseInterruptEvent *iEvent, u32 interruptID,
u32 coreID, u32 priority, bool disableUponReceipt, bool levelHighActive);
extern InterruptManager *interruptManager;

View File

@ -1123,6 +1123,16 @@ typedef union KCacheMaintenanceInterruptEvent
KCacheMaintenanceInterruptEventO3DS O3DS;
} KCacheMaintenanceInterruptEvent;
typedef struct FcramLayout
{
void *applicationAddr;
u32 applicationSize;
void *systemAddr;
u32 systemSize;
void *baseAddr;
u32 baseSize;
} FcramLayout;
extern bool isN3DS;
extern void *officialSVCs[0x7E];

View File

@ -90,6 +90,10 @@ bool *isDevUnit;
vu8 *configPage;
u32 kernelVersion;
FcramLayout fcramLayout;
void *originalHandlers[8] = {NULL};
u32 nbSection0Modules;
Result (*InterruptManager__MapInterrupt)(InterruptManager *manager, KBaseInterruptEvent *iEvent, u32 interruptID,

View File

@ -33,10 +33,6 @@
#include "svcHandler.h"
#include "memory.h"
void *originalHandlers[8] = {NULL};
extern u8 __start__[], __end__[], __bss_start__[], __bss_end__[];
struct KExtParameters
{
u32 ALIGN(0x400) L2MMUTableFor0x40000000[256];
@ -94,6 +90,9 @@ void configHook(vu8 *cfgPage)
configPage = cfgPage;
kernelVersion = *(vu32 *)configPage;
*(vu32 *)(configPage + 0x40) = fcramLayout.applicationSize;
*(vu32 *)(configPage + 0x44) = fcramLayout.systemSize;
*(vu32 *)(configPage + 0x48) = fcramLayout.baseSize;
*isDevUnit = true; // enable debug features
}
@ -248,12 +247,15 @@ static void findUsefulSymbols(void)
}
}
void main(void)
void main(FcramLayout *layout)
{
struct KExtParameters *p = &kExtParameters;
u32 TTBCR_;
s64 nb;
layout->systemSize -= __end__ - __start__;
fcramLayout = *layout;
__asm__ volatile("mrc p15, 0, %0, c2, c0, 2" : "=r"(TTBCR_));
TTBCR = TTBCR_;
isN3DS = getNumberOfCores() == 4;

View File

@ -49,15 +49,7 @@ start:
push {r0-r12, lr}
@ Adjust the size of the SYSTEM memregion
sub r4, #8
ldr r0, [r4, #0xC]
ldr r1, =__end__
ldr r2, =__start__
sub r1, r2
sub r0, r1
str r0, [r4, #0xC]
sub r0, r4, #8
bl main
pop {r0-r12, pc}

View File

@ -24,6 +24,7 @@
* reasonable ways as different from the original version.
*/
#include "memory.h"
#include "svc.h"
#include "svc/ControlMemory.h"
#include "svc/GetProcessInfo.h"
@ -87,6 +88,8 @@ void signalSvcReturn(u8 *pageEnd)
SignalDebugEvent(DBGEVENT_OUTPUT_STRING, 0xFFFFFFFF, svcId);
}
static bool doingVeryShittyPmResLimitWorkaround = false; // I feel dirty
void *svcHook(u8 *pageEnd)
{
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
@ -98,6 +101,13 @@ void *svcHook(u8 *pageEnd)
{
case 0x01:
return ControlMemoryHookWrapper;
case 0x17:
if(strcmp(codeSetOfProcess(currentProcess)->processName, "pm") == 0) // only called twice in pm, by the same function
{
*(vu32 *)(configPage + 0x44) += __end__ - __start__;
doingVeryShittyPmResLimitWorkaround = true;
}
return officialSVCs[0x17];
case 0x2A:
return GetSystemInfoHookWrapper;
case 0x2B:
@ -116,6 +126,13 @@ void *svcHook(u8 *pageEnd)
return SetGpuProt;
case 0x5A:
return SetWifiEnabled;
case 0x79:
if(doingVeryShittyPmResLimitWorkaround)
{
*(vu32 *)(configPage + 0x44) -= __end__ - __start__;
doingVeryShittyPmResLimitWorkaround = false;
}
return officialSVCs[0x79];
case 0x7B:
return Backdoor;
case 0x7C: