Removed old Brahma-compatible chainloader

This commit is contained in:
Wolfvak 2017-07-30 22:51:49 +02:00 committed by d0k3
parent 5d6ee82728
commit ba808f9876
4 changed files with 3 additions and 81 deletions

View File

@ -1,8 +0,0 @@
#pragma once
#include "common.h"
#define PAYLOAD_MAX_SIZE 0xFFFE0
void __attribute__((noreturn)) Chainload(u8 *source, size_t size);
void __attribute__((noreturn)) BootFirm(FirmHeader *firm, char *path);

View File

@ -1,52 +0,0 @@
@ Wolfvak - 25/01/2017
@ TODO: ELF launcher
@ void Chainload(u8 *source, size_t size)
@ Wrapper around chainload_itcm
.arm
.global Chainload
.type Chainload, %function
Chainload:
ldr r2, =0x1FF8100 @ ITCM + 0x100 bytes
mov r3, r2
ldr r4, =chainload_itcm
ldr r5, =chainload_itcm_end
.copy_chainloader:
cmp r4, r5
ldrlt r6, [r4], #4
strlt r6, [r3], #4
blt .copy_chainloader
bx r2 @ Branch to the real chainloader in ITCM
@ void chainload_itcm(void)
@ Note: Uses unprotected bootrom functions
.arm
.type chainload_itcm, %function
.align 4
chainload_itcm:
mov r2, r1
ldr r1, =0x23F00000
mov r4, r1 @ memcpy256 and clean_flush_cache mess with the registers
ldr r3, =0xFFFF03F0 @ memcpy256(u32 *src, u32 *ddest, size_t size)
blx r3
ldr r3, =0xFFFF0830 @ void clean_flush_cache(void)
blx r3
mov r3, r4
mov r0, #0 @ Clear argc
mov r1, #0 @ Same for argv
mov r2, #0
mov lr, #0
bx r3
.pool
chainload_itcm_end:

View File

@ -5,7 +5,6 @@
#include "game.h" #include "game.h"
#include "keydb.h" #include "keydb.h"
#include "ctrtransfer.h" #include "ctrtransfer.h"
#include "chainload.h"
#include "fsscript.h" #include "fsscript.h"
u32 IdentifyFileType(const char* path) { u32 IdentifyFileType(const char* path) {
@ -102,10 +101,6 @@ u32 IdentifyFileType(const char* path) {
return BIN_KEYDB; // key database return BIN_KEYDB; // key database
} else if ((sscanf(fname, "slot%02lXKey", &id) == 1) && (strncasecmp(ext, "bin", 4) == 0) && (fsize = 16) && (id < 0x40)) { } else if ((sscanf(fname, "slot%02lXKey", &id) == 1) && (strncasecmp(ext, "bin", 4) == 0) && (fsize = 16) && (id < 0x40)) {
return BIN_LEGKEY; // legacy key file return BIN_LEGKEY; // legacy key file
#if PAYLOAD_MAX_SIZE <= TEMP_BUFFER_SIZE
} else if ((fsize <= PAYLOAD_MAX_SIZE) && ext && (strncasecmp(ext, "bin", 4) == 0)) {
return BIN_LAUNCH; // assume it's an ARM9 payload
#endif
} else if (ValidateText((char*) data, (fsize > 0X200) ? 0x200 : fsize)) { } else if (ValidateText((char*) data, (fsize > 0X200) ? 0x200 : fsize)) {
if ((fsize <= SCRIPT_MAX_SIZE) && ext && (strncasecmp(ext, SCRIPT_EXT, strnlen(SCRIPT_EXT, 16) + 1) == 0)) if ((fsize <= SCRIPT_MAX_SIZE) && ext && (strncasecmp(ext, SCRIPT_EXT, strnlen(SCRIPT_EXT, 16) + 1) == 0))
return TXT_SCRIPT | TXT_GENERIC; // should be a script (which is also generic text) return TXT_SCRIPT | TXT_GENERIC; // should be a script (which is also generic text)

View File

@ -20,7 +20,7 @@
#include "ctrtransfer.h" #include "ctrtransfer.h"
#include "ncchinfo.h" #include "ncchinfo.h"
#include "image.h" #include "image.h"
#include "chainload.h" #include "bootfirm.h"
#include "qlzcomp.h" #include "qlzcomp.h"
#include "timer.h" #include "timer.h"
#include "power.h" #include "power.h"
@ -891,11 +891,10 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur
bool ebackupable = (FTYPE_EBACKUP(filetype)); bool ebackupable = (FTYPE_EBACKUP(filetype));
bool xorpadable = (FTYPE_XORPAD(filetype)); bool xorpadable = (FTYPE_XORPAD(filetype));
bool scriptable = (FTYPE_SCRIPT(filetype)); bool scriptable = (FTYPE_SCRIPT(filetype));
bool launchable = ((FTYPE_PAYLOAD(filetype)) && (drvtype & DRV_FAT) && !IS_SIGHAX); bool bootable = ((FTYPE_BOOTABLE(filetype)));
bool bootable = ((FTYPE_BOOTABLE(filetype)) && !PathExist("0:/bootonce.firm") && IS_SIGHAX); // works only with boot9strap nightly
bool special_opt = mountable || verificable || decryptable || encryptable || cia_buildable || cia_buildable_legit || cxi_dumpable || bool special_opt = mountable || verificable || decryptable || encryptable || cia_buildable || cia_buildable_legit || cxi_dumpable ||
tik_buildable || key_buildable || titleinfo || renamable || transferable || hsinjectable || restorable || xorpadable || tik_buildable || key_buildable || titleinfo || renamable || transferable || hsinjectable || restorable || xorpadable ||
ebackupable || launchable || bootable || scriptable; ebackupable || bootable || scriptable;
char pathstr[32+1]; char pathstr[32+1];
TruncateString(pathstr, curr_entry->path, 32, 8); TruncateString(pathstr, curr_entry->path, 32, 8);
@ -940,7 +939,6 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur
(filetype & BIN_KEYDB) ? "AESkeydb options..." : (filetype & BIN_KEYDB) ? "AESkeydb options..." :
(filetype & BIN_LEGKEY) ? "Build " KEYDB_NAME : (filetype & BIN_LEGKEY) ? "Build " KEYDB_NAME :
(filetype & BIN_NCCHNFO)? "NCCHinfo options..." : (filetype & BIN_NCCHNFO)? "NCCHinfo options..." :
(filetype & BIN_LAUNCH) ? "Launch as arm9 payload" :
(filetype & TXT_SCRIPT) ? "Execute GM9 script" : "???"; (filetype & TXT_SCRIPT) ? "Execute GM9 script" : "???";
optionstr[hexviewer-1] = "Show in Hexeditor"; optionstr[hexviewer-1] = "Show in Hexeditor";
optionstr[calcsha-1] = "Calculate SHA-256"; optionstr[calcsha-1] = "Calculate SHA-256";
@ -1051,7 +1049,6 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur
int rename = (renamable) ? ++n_opt : -1; int rename = (renamable) ? ++n_opt : -1;
int xorpad = (xorpadable) ? ++n_opt : -1; int xorpad = (xorpadable) ? ++n_opt : -1;
int xorpad_inplace = (xorpadable) ? ++n_opt : -1; int xorpad_inplace = (xorpadable) ? ++n_opt : -1;
int launch = (launchable) ? ++n_opt : -1;
int boot = (bootable) ? ++n_opt : -1; int boot = (bootable) ? ++n_opt : -1;
int script = (scriptable) ? ++n_opt : -1; int script = (scriptable) ? ++n_opt : -1;
if (mount > 0) optionstr[mount-1] = "Mount image to drive"; if (mount > 0) optionstr[mount-1] = "Mount image to drive";
@ -1072,7 +1069,6 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur
if (rename > 0) optionstr[rename-1] = "Rename file"; if (rename > 0) optionstr[rename-1] = "Rename file";
if (xorpad > 0) optionstr[xorpad-1] = "Build XORpads (SD output)"; if (xorpad > 0) optionstr[xorpad-1] = "Build XORpads (SD output)";
if (xorpad_inplace > 0) optionstr[xorpad_inplace-1] = "Build XORpads (inplace)"; if (xorpad_inplace > 0) optionstr[xorpad_inplace-1] = "Build XORpads (inplace)";
if (launch > 0) optionstr[launch-1] = "Launch as ARM9 payload";
if (boot > 0) optionstr[boot-1] = "Boot FIRM"; if (boot > 0) optionstr[boot-1] = "Boot FIRM";
if (script > 0) optionstr[script-1] = "Execute GM9 script"; if (script > 0) optionstr[script-1] = "Execute GM9 script";
@ -1407,15 +1403,6 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur
(success) ? "completed" : "failed!"); (success) ? "completed" : "failed!");
GetDirContents(current_dir, current_path); GetDirContents(current_dir, current_path);
return 0; return 0;
} else if ((user_select == launch)) {
size_t payload_size = FileGetSize(curr_entry->path);
if (ShowUnlockSequence(3, "%s (%dkB)\nLaunch as arm9 payload?", pathstr, payload_size / 1024)) {
if (FileGetData(curr_entry->path, TEMP_BUFFER, payload_size, 0) == payload_size) {
Chainload(TEMP_BUFFER, payload_size);
while(1);
} // failed load is basically impossible here
}
return 0;
} else if ((user_select == boot)) { } else if ((user_select == boot)) {
size_t firm_size = FileGetSize(curr_entry->path); size_t firm_size = FileGetSize(curr_entry->path);
if (firm_size > TEMP_BUFFER_SIZE) { if (firm_size > TEMP_BUFFER_SIZE) {