Minor stuff
This commit is contained in:
parent
14152b3072
commit
2f915401dd
@ -67,36 +67,34 @@ static bool secureInfoExists(void)
|
|||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int loadCustomVerString(u16 *out, u32 *verStringSize)
|
static void loadCustomVerString(u16 *out, u32 *verStringSize)
|
||||||
{
|
{
|
||||||
static const char path[] = "/luma/customversion.txt";
|
static const char path[] = "/luma/customversion.txt";
|
||||||
|
|
||||||
IFile file;
|
IFile file;
|
||||||
Result ret = fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ);
|
|
||||||
if(R_SUCCEEDED(ret))
|
if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ)))
|
||||||
{
|
{
|
||||||
u64 fileSize;
|
u64 fileSize;
|
||||||
ret = IFile_GetSize(&file, &fileSize);
|
|
||||||
|
|
||||||
if(R_SUCCEEDED(ret) && fileSize <= 19)
|
if(R_SUCCEEDED(IFile_GetSize(&file, &fileSize)) && fileSize <= 19)
|
||||||
{
|
{
|
||||||
*verStringSize = (u32)fileSize;
|
|
||||||
u8 buf[19];
|
u8 buf[19];
|
||||||
u64 total;
|
u64 total;
|
||||||
|
|
||||||
ret = IFile_Read(&file, &total, buf, *verStringSize);
|
if(R_SUCCEEDED(IFile_Read(&file, &total, buf, fileSize)))
|
||||||
|
{
|
||||||
|
*verStringSize = (u32)fileSize;
|
||||||
|
|
||||||
for(u32 i = 0; i < *verStringSize; i++)
|
for(u32 i = 0; i < *verStringSize; i++)
|
||||||
((u8 *)out)[2 * i] = buf[i];
|
((u8 *)out)[2 * i] = buf[i];
|
||||||
|
|
||||||
*verStringSize *= 2;
|
*verStringSize *= 2;
|
||||||
}
|
}
|
||||||
else ret = -1;
|
}
|
||||||
|
|
||||||
IFile_Close(&file);
|
IFile_Close(&file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadTitleCodeSection(u64 progId, u8 *code, u32 size)
|
static void loadTitleCodeSection(u64 progId, u8 *code, u32 size)
|
||||||
@ -108,24 +106,22 @@ static void loadTitleCodeSection(u64 progId, u8 *code, u32 size)
|
|||||||
progIdToStr(path + 35, progId);
|
progIdToStr(path + 35, progId);
|
||||||
|
|
||||||
IFile file;
|
IFile file;
|
||||||
Result ret = fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ);
|
|
||||||
|
|
||||||
if(R_SUCCEEDED(ret))
|
if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ)))
|
||||||
{
|
{
|
||||||
u64 fileSize;
|
u64 fileSize;
|
||||||
ret = IFile_GetSize(&file, &fileSize);
|
|
||||||
|
|
||||||
if(R_SUCCEEDED(ret) && fileSize <= size)
|
if(R_SUCCEEDED(IFile_GetSize(&file, &fileSize)) && fileSize <= size)
|
||||||
{
|
{
|
||||||
u64 total;
|
u64 total;
|
||||||
ret = IFile_Read(&file, &total, code, fileSize);
|
IFile_Read(&file, &total, code, fileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
IFile_Close(&file);
|
IFile_Close(&file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
|
static void loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
|
||||||
{
|
{
|
||||||
/* Here we look for "/luma/locales/[u64 titleID in hex, uppercase].txt"
|
/* Here we look for "/luma/locales/[u64 titleID in hex, uppercase].txt"
|
||||||
If it exists it should contain, for example, "EUR IT" */
|
If it exists it should contain, for example, "EUR IT" */
|
||||||
@ -134,22 +130,19 @@ static int loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
|
|||||||
progIdToStr(path + 29, progId);
|
progIdToStr(path + 29, progId);
|
||||||
|
|
||||||
IFile file;
|
IFile file;
|
||||||
Result ret = fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ);
|
|
||||||
if(R_SUCCEEDED(ret))
|
if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ)))
|
||||||
{
|
{
|
||||||
u64 fileSize;
|
u64 fileSize;
|
||||||
ret = IFile_GetSize(&file, &fileSize);
|
|
||||||
|
|
||||||
if(R_SUCCEEDED(ret) && fileSize == 6)
|
if(R_SUCCEEDED(IFile_GetSize(&file, &fileSize)) && fileSize == 6)
|
||||||
{
|
{
|
||||||
char buf[6];
|
char buf[6];
|
||||||
u64 total;
|
u64 total;
|
||||||
|
|
||||||
ret = IFile_Read(&file, &total, buf, 6);
|
if(R_SUCCEEDED(IFile_Read(&file, &total, buf, 6)))
|
||||||
|
|
||||||
if(R_SUCCEEDED(ret))
|
|
||||||
{
|
{
|
||||||
for(u32 i = 0; i < 7; ++i)
|
for(u32 i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
static const char *regions[] = {"JPN", "USA", "EUR", "AUS", "CHN", "KOR", "TWN"};
|
static const char *regions[] = {"JPN", "USA", "EUR", "AUS", "CHN", "KOR", "TWN"};
|
||||||
|
|
||||||
@ -160,7 +153,7 @@ static int loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(u32 i = 0; i < 12; ++i)
|
for(u32 i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
static const char *languages[] = {"JP", "EN", "FR", "DE", "IT", "ES", "ZH", "KO", "NL", "PT", "RU", "TW"};
|
static const char *languages[] = {"JP", "EN", "FR", "DE", "IT", "ES", "ZH", "KO", "NL", "PT", "RU", "TW"};
|
||||||
|
|
||||||
@ -172,12 +165,9 @@ static int loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else ret = -1;
|
|
||||||
|
|
||||||
IFile_Close(&file);
|
IFile_Close(&file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 *getCfgOffsets(u8 *code, u32 size, u32 *CFGUHandleOffset)
|
static u8 *getCfgOffsets(u8 *code, u32 size, u32 *CFGUHandleOffset)
|
||||||
@ -367,11 +357,11 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
|||||||
0xE0, 0x1E, 0xFF, 0x2F, 0xE1, 0x01, 0x01
|
0xE0, 0x1E, 0xFF, 0x2F, 0xE1, 0x01, 0x01
|
||||||
};
|
};
|
||||||
|
|
||||||
u8 mostRecentFpdVer = 0x07;
|
u8 mostRecentFpdVer = 7;
|
||||||
|
|
||||||
u8 *fpdVer = memsearch(code, fpdVerPattern, size, sizeof(fpdVerPattern));
|
u8 *fpdVer = memsearch(code, fpdVerPattern, size, sizeof(fpdVerPattern));
|
||||||
|
|
||||||
//Allow online access to work with old friends modules, without breaking newer firmwares
|
//Allow online access to work with old friends modules
|
||||||
if(fpdVer != NULL && fpdVer[9] < mostRecentFpdVer) fpdVer[9] = mostRecentFpdVer;
|
if(fpdVer != NULL && fpdVer[9] < mostRecentFpdVer) fpdVer[9] = mostRecentFpdVer;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -391,7 +381,9 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
|||||||
u32 verStringSize;
|
u32 verStringSize;
|
||||||
|
|
||||||
u16 customVerString[19] = {0};
|
u16 customVerString[19] = {0};
|
||||||
if(R_SUCCEEDED(loadCustomVerString(customVerString, &verStringSize))) verString = customVerString;
|
loadCustomVerString(customVerString, &verStringSize);
|
||||||
|
|
||||||
|
if(customVerString[0] != 0) verString = customVerString;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
verStringSize = 8;
|
verStringSize = 8;
|
||||||
@ -442,7 +434,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
|||||||
//Patch Ver. string
|
//Patch Ver. string
|
||||||
patchMemory(code, size,
|
patchMemory(code, size,
|
||||||
verPattern,
|
verPattern,
|
||||||
sizeof(verPattern) - sizeof(u16), 0,
|
sizeof(verPattern) - 2, 0,
|
||||||
verString,
|
verString,
|
||||||
verStringSize, 1
|
verStringSize, 1
|
||||||
);
|
);
|
||||||
@ -514,10 +506,10 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
|||||||
//Use SecureInfo_C
|
//Use SecureInfo_C
|
||||||
patchMemory(code, size,
|
patchMemory(code, size,
|
||||||
secureinfoFilenamePattern,
|
secureinfoFilenamePattern,
|
||||||
sizeof(secureinfoFilenamePattern) - sizeof(u16),
|
sizeof(secureinfoFilenamePattern) - 2,
|
||||||
sizeof(secureinfoFilenamePattern) - sizeof(u16),
|
sizeof(secureinfoFilenamePattern) - 2,
|
||||||
secureinfoFilenamePatch,
|
secureinfoFilenamePatch,
|
||||||
sizeof(secureinfoFilenamePatch) - sizeof(u16), 2
|
sizeof(secureinfoFilenamePatch) - 2, 2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,9 +597,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
|||||||
default:
|
default:
|
||||||
if(CONFIG(USELANGEMUANDCODE))
|
if(CONFIG(USELANGEMUANDCODE))
|
||||||
{
|
{
|
||||||
u32 tidHigh = (progId & 0xFFFFFFF000000000LL) >> 0x24;
|
if((u32)((progId & 0xFFFFFFF000000000LL) >> 0x24) == 0x0004000)
|
||||||
|
|
||||||
if(tidHigh == 0x0004000)
|
|
||||||
{
|
{
|
||||||
//External .code section loading
|
//External .code section loading
|
||||||
loadTitleCodeSection(progId, code, size);
|
loadTitleCodeSection(progId, code, size);
|
||||||
@ -615,11 +605,11 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
|||||||
//Language emulation
|
//Language emulation
|
||||||
u8 regionId = 0xFF,
|
u8 regionId = 0xFF,
|
||||||
languageId = 0xFF;
|
languageId = 0xFF;
|
||||||
|
loadTitleLocaleConfig(progId, ®ionId, &languageId);
|
||||||
|
|
||||||
if(R_SUCCEEDED(loadTitleLocaleConfig(progId, ®ionId, &languageId)))
|
if(regionId != 0xFF || regionId != 0xFF)
|
||||||
{
|
{
|
||||||
u32 CFGUHandleOffset;
|
u32 CFGUHandleOffset;
|
||||||
|
|
||||||
u8 *CFGU_GetConfigInfoBlk2_endPos = getCfgOffsets(code, size, &CFGUHandleOffset);
|
u8 *CFGU_GetConfigInfoBlk2_endPos = getCfgOffsets(code, size, &CFGUHandleOffset);
|
||||||
|
|
||||||
if(CFGU_GetConfigInfoBlk2_endPos != NULL)
|
if(CFGU_GetConfigInfoBlk2_endPos != NULL)
|
||||||
|
@ -31,6 +31,7 @@ void main(void)
|
|||||||
|
|
||||||
memcpy(payloadAddress, (void *)0x24F00000, payloadSize);
|
memcpy(payloadAddress, (void *)0x24F00000, payloadSize);
|
||||||
|
|
||||||
|
//Ensure that all memory transfers have completed and that the caches have been flushed
|
||||||
flushCaches();
|
flushCaches();
|
||||||
|
|
||||||
((void (*)())payloadAddress)();
|
((void (*)())payloadAddress)();
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
|
|
||||||
bool loadSplash(void)
|
bool loadSplash(void)
|
||||||
{
|
{
|
||||||
const char *topSplashPath = "/luma/splash.bin",
|
const char topSplashPath[] = "/luma/splash.bin",
|
||||||
*bottomSplashPath = "/luma/splashbottom.bin";
|
bottomSplashPath[] = "/luma/splashbottom.bin";
|
||||||
|
|
||||||
bool isTopSplashValid = getFileSize(topSplashPath) == SCREEN_TOP_FBSIZE,
|
bool isTopSplashValid = getFileSize(topSplashPath) == SCREEN_TOP_FBSIZE,
|
||||||
isBottomSplashValid = getFileSize(bottomSplashPath) == SCREEN_BOTTOM_FBSIZE;
|
isBottomSplashValid = getFileSize(bottomSplashPath) == SCREEN_BOTTOM_FBSIZE;
|
||||||
|
@ -339,7 +339,6 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
|
|||||||
if(!fileRead(firm, "/luma/firmware.bin", 0x400000) || section[2].address != (u8 *)0x8006800)
|
if(!fileRead(firm, "/luma/firmware.bin", 0x400000) || section[2].address != (u8 *)0x8006800)
|
||||||
error("An old unsupported FIRM has been detected.\nCopy a valid firmware.bin in /luma to boot");
|
error("An old unsupported FIRM has been detected.\nCopy a valid firmware.bin in /luma to boot");
|
||||||
|
|
||||||
//No assumption regarding FIRM version
|
|
||||||
firmVersion = 0xFFFFFFFF;
|
firmVersion = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -595,7 +594,8 @@ static inline void launchFirm(FirmwareType firmType)
|
|||||||
//Set ARM11 kernel entrypoint
|
//Set ARM11 kernel entrypoint
|
||||||
*arm11 = (u32)firm->arm11Entry;
|
*arm11 = (u32)firm->arm11Entry;
|
||||||
|
|
||||||
flushEntireDCache(); //Ensure that all memory transfers have completed and that the data cache has been flushed
|
//Ensure that all memory transfers have completed and that the caches have been flushed
|
||||||
|
flushEntireDCache();
|
||||||
flushEntireICache();
|
flushEntireICache();
|
||||||
|
|
||||||
//Final jump to ARM9 kernel
|
//Final jump to ARM9 kernel
|
||||||
|
@ -132,7 +132,7 @@ bool verifyPin(void)
|
|||||||
u8 cnt = 0;
|
u8 cnt = 0;
|
||||||
u32 charDrawPos = 16 * SPACING_X;
|
u32 charDrawPos = 16 * SPACING_X;
|
||||||
|
|
||||||
const char *messagePath = "/luma/pinmessage.txt";
|
const char messagePath[] = "/luma/pinmessage.txt";
|
||||||
|
|
||||||
u32 messageSize = getFileSize(messagePath);
|
u32 messageSize = getFileSize(messagePath);
|
||||||
if(messageSize > 0 && messageSize <= 800)
|
if(messageSize > 0 && messageSize <= 800)
|
||||||
|
@ -58,7 +58,8 @@ void mcuReboot(void)
|
|||||||
{
|
{
|
||||||
if(!isFirmlaunch && PDN_GPU_CNT != 1) clearScreens(true, true);
|
if(!isFirmlaunch && PDN_GPU_CNT != 1) clearScreens(true, true);
|
||||||
|
|
||||||
flushEntireDCache(); //Ensure that all memory transfers have completed and that the data cache has been flushed
|
//Ensure that all memory transfers have completed and that the data cache has been flushed
|
||||||
|
flushEntireDCache();
|
||||||
|
|
||||||
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
|
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
|
||||||
while(true);
|
while(true);
|
||||||
@ -68,17 +69,15 @@ void mcuPowerOff(void)
|
|||||||
{
|
{
|
||||||
if(!isFirmlaunch && PDN_GPU_CNT != 1) clearScreens(true, true);
|
if(!isFirmlaunch && PDN_GPU_CNT != 1) clearScreens(true, true);
|
||||||
|
|
||||||
flushEntireDCache(); //Ensure that all memory transfers have completed and that the data cache has been flushed
|
//Ensure that all memory transfers have completed and that the data cache has been flushed
|
||||||
|
flushEntireDCache();
|
||||||
|
|
||||||
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
|
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
|
||||||
while(true);
|
while(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add support for TIMER IRQ
|
|
||||||
static inline void startChrono(u64 initialTicks)
|
static inline void startChrono(u64 initialTicks)
|
||||||
{
|
{
|
||||||
//Based on a NATIVE_FIRM disassembly
|
|
||||||
|
|
||||||
REG_TIMER_CNT(0) = 0; //67MHz
|
REG_TIMER_CNT(0) = 0; //67MHz
|
||||||
for(u32 i = 1; i < 4; i++) REG_TIMER_CNT(i) = 4; //Count-up
|
for(u32 i = 1; i < 4; i++) REG_TIMER_CNT(i) = 4; //Count-up
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user