This can be here

This commit is contained in:
Aurora 2016-10-10 03:39:23 +02:00
parent e9692a438b
commit d270d5b9ca
4 changed files with 10 additions and 9 deletions

View File

@ -102,7 +102,7 @@ static inline u32 getFreeK9Space(u8 *pos, u32 size, u8 **freeK9Space)
//Looking for the last free space before Process9
*freeK9Space = memsearch(pos + 0x13500, pattern, size - 0x13500, sizeof(pattern)) + 0x455;
return *freeK9Space == NULL ? 1 : 0;
return *freeK9Space == NULL ? 1 : 0;
}
static inline u32 getSdmmc(u8 *pos, u32 size, u32 *sdmmc)
@ -171,13 +171,13 @@ static inline u32 patchMpu(u8 *pos, u32 size)
return ret;
}
u32 patchEmuNand(u8 *arm9Section, u8 *process9Offset, u32 process9Size, u32 emuHeader)
u32 patchEmuNand(u8 *arm9Section, u32 arm9SectionSize, u8 *process9Offset, u32 process9Size, u32 emuHeader, u8 *kernel9Address)
{
u32 ret = 0;
//Copy EmuNAND code
u8 *freeK9Space;
ret += getFreeK9Space(arm9Section, firm->section[2].size, &freeK9Space);
ret += getFreeK9Space(arm9Section, arm9SectionSize, &freeK9Space);
if(!ret)
{
memcpy(freeK9Space, emunand_bin, emunand_bin_size);
@ -195,10 +195,10 @@ u32 patchEmuNand(u8 *arm9Section, u8 *process9Offset, u32 process9Size, u32 emuH
if(!ret) *posSdmmc = sdmmc;
//Add EmuNAND hooks
ret += patchNandRw(process9Offset, process9Size, (u32)(freeK9Space - arm9Section + firm->section[2].address));
ret += patchNandRw(process9Offset, process9Size, (u32)(freeK9Space - arm9Section + kernel9Address));
//Set MPU
ret += patchMpu(arm9Section, firm->section[2].size);
ret += patchMpu(arm9Section, arm9SectionSize);
}
return ret;

View File

@ -27,4 +27,4 @@
#define ROUND_TO_4MB(a) (((a) + 0x2000 - 1) & (~(0x2000 - 1)))
void locateEmuNand(u32 *emuHeader, FirmwareSource *nandType);
u32 patchEmuNand(u8 *arm9Section, u8 *process9Offset, u32 process9Size, u32 emuHeader);
u32 patchEmuNand(u8 *arm9Section, u32 arm9SectionSize, u8 *process9Offset, u32 process9Size, u32 emuHeader, u8 *kernel9Address);

View File

@ -34,6 +34,8 @@
#include "screen.h"
#include "../build/bundled.h"
static Firm *firm = (Firm *)0x24000000;
u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage, bool isSdMode)
{
const char *firmwareFiles[] = {
@ -140,7 +142,7 @@ u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, u32
ret += patchSignatureChecks(process9Offset, process9Size);
//Apply EmuNAND patches
if(nandType != FIRMWARE_SYSNAND) ret += patchEmuNand(arm9Section, process9Offset, process9Size, emuHeader);
if(nandType != FIRMWARE_SYSNAND) ret += patchEmuNand(arm9Section, firm->section[2].size, process9Offset, process9Size, emuHeader, firm->section[2].address);
//Apply FIRM0/1 writes patches on sysNAND to protect A9LH
else if(ISA9LH || (ISFIRMLAUNCH && BOOTCFG_A9LH != 0)) ret += patchFirmWrites(process9Offset, process9Size);

View File

@ -100,5 +100,4 @@ typedef enum FirmwareType
NATIVE_FIRM1X2X
} FirmwareType;
extern u16 launchedFirmTidLow[8]; //Defined in start.s
static Firm *const firm = (Firm *)0x24000000;
extern u16 launchedFirmTidLow[8]; //Defined in start.s