forked from Mirror/GodMode9
Use new entrypoint detection method, remove old one
This commit is contained in:
parent
7937540162
commit
05ca9109de
@ -12,6 +12,7 @@
|
||||
#include "nandutil.h"
|
||||
#include "filetype.h"
|
||||
#include "unittype.h"
|
||||
#include "entrypoints.h"
|
||||
#include "nand.h"
|
||||
#include "virtual.h"
|
||||
#include "vcart.h"
|
||||
@ -1691,7 +1692,7 @@ u32 SplashInit(const char* modestr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 GodMode(bool is_b9s) {
|
||||
u32 GodMode(int entrypoint) {
|
||||
const u32 quick_stp = (MAIN_SCREEN == TOP_SCREEN) ? 20 : 19;
|
||||
u32 exit_mode = GODMODE_EXIT_POWEROFF;
|
||||
|
||||
@ -1705,8 +1706,7 @@ u32 GodMode(bool is_b9s) {
|
||||
u32 last_clipboard_size = 0;
|
||||
|
||||
|
||||
u32 boot_origin = GetBootOrigin();
|
||||
bool bootloader = !is_b9s && IS_SIGHAX && (boot_origin & BOOT_NAND);
|
||||
bool bootloader = IS_SIGHAX && (entrypoint == ENTRY_NANDBOOT);
|
||||
bool bootmenu = bootloader && (BOOTMENU_KEY != BUTTON_START) && CheckButton(BOOTMENU_KEY);
|
||||
bool godmode9 = !bootloader;
|
||||
FirmHeader* firm_in_mem = (FirmHeader*) (void*) (TEMP_BUFFER + TEMP_BUFFER_SIZE); // should be safe here
|
||||
@ -1724,9 +1724,9 @@ u32 GodMode(bool is_b9s) {
|
||||
// get mode string for splash screen
|
||||
const char* disp_mode = NULL;
|
||||
if (bootloader) disp_mode = "bootloader mode\nR+LEFT for menu";
|
||||
else if (!is_b9s && !IS_SIGHAX) disp_mode = "oldloader mode";
|
||||
else if (!is_b9s && IS_SIGHAX && (boot_origin & BOOT_NTRBOOT)) disp_mode = "ntrboot mode";
|
||||
// else if (!is_b9s || !IS_SIGHAX) disp_mode = "unknown mode";
|
||||
else if (!IS_SIGHAX && (entrypoint == ENTRY_NANDBOOT)) disp_mode = "oldloader mode";
|
||||
else if (entrypoint == ENTRY_NTRBOOT) disp_mode = "ntrboot mode";
|
||||
else if (entrypoint == ENTRY_UNKNOWN) disp_mode = "unknown mode";
|
||||
|
||||
bool show_splash = true;
|
||||
#ifdef SALTMODE
|
||||
@ -1745,7 +1745,7 @@ u32 GodMode(bool is_b9s) {
|
||||
|
||||
InitSDCardFS();
|
||||
AutoEmuNandBase(true);
|
||||
InitNandCrypto(!is_b9s);
|
||||
InitNandCrypto(entrypoint != ENTRY_B9S);
|
||||
InitExtFS();
|
||||
|
||||
// check for embedded essential backup
|
||||
@ -1773,7 +1773,7 @@ u32 GodMode(bool is_b9s) {
|
||||
}
|
||||
|
||||
// check aeskeydb.bin / key state
|
||||
if (!is_b9s && (CheckRecommendedKeyDb(NULL) != 0)) {
|
||||
if ((entrypoint != ENTRY_B9S) && (CheckRecommendedKeyDb(NULL) != 0)) {
|
||||
ShowPrompt(false, "WARNING:\nNot running from a boot9strap\ncompatible entrypoint. Not\neverything may work as expected.\n \nProvide the recommended\naeskeydb.bin file to make this\nwarning go away.");
|
||||
}
|
||||
|
||||
@ -2245,7 +2245,7 @@ u32 GodMode(bool is_b9s) {
|
||||
}
|
||||
|
||||
#ifdef AUTORUN_SCRIPT
|
||||
u32 ScriptRunner(bool is_b9s) {
|
||||
u32 ScriptRunner(int entrypoint) {
|
||||
// show splash and initialize
|
||||
ClearScreenF(true, true, COLOR_STD_BG);
|
||||
SplashInit("scriptrunner mode");
|
||||
@ -2253,7 +2253,7 @@ u32 ScriptRunner(bool is_b9s) {
|
||||
|
||||
InitSDCardFS();
|
||||
AutoEmuNandBase(true);
|
||||
InitNandCrypto(!is_b9s);
|
||||
InitNandCrypto(entrypoint != ENTRY_B9S);
|
||||
InitExtFS();
|
||||
|
||||
while (CheckButton(BUTTON_A)); // don't continue while A is held
|
||||
|
@ -5,5 +5,5 @@
|
||||
#define GODMODE_EXIT_REBOOT 0
|
||||
#define GODMODE_EXIT_POWEROFF 1
|
||||
|
||||
u32 GodMode(bool is_b9s);
|
||||
u32 ScriptRunner(bool is_b9s);
|
||||
u32 GodMode(int entrypoint);
|
||||
u32 ScriptRunner(int entrypoint);
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
void main(int argc, char** argv, int entrypoint)
|
||||
{
|
||||
(void) argv; // unused for now
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
// Wait for ARM11
|
||||
PXI_WaitRemote(PXI_READY);
|
||||
@ -15,10 +16,10 @@ void main(int argc, char** argv, int entrypoint)
|
||||
|
||||
#ifdef AUTORUN_SCRIPT
|
||||
// Run the script runner
|
||||
if (ScriptRunner(argc) == GODMODE_EXIT_REBOOT)
|
||||
if (ScriptRunner(entrypoint) == GODMODE_EXIT_REBOOT)
|
||||
#else
|
||||
// Run the main program
|
||||
if (GodMode(argc) == GODMODE_EXIT_REBOOT)
|
||||
if (GodMode(entrypoint) == GODMODE_EXIT_REBOOT)
|
||||
#endif
|
||||
Reboot();
|
||||
|
||||
|
@ -534,30 +534,6 @@ u32 GetNandPartitionInfo(NandPartitionInfo* info, u32 type, u32 subtype, u32 ind
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 GetBootOrigin(void)
|
||||
{
|
||||
// see: https://github.com/AuroraWright/Luma3DS/blob/bc1aa15dd709a703b9af1a0f89ccded21fc08823/source/main.c#L58-L62
|
||||
// and: https://www.3dbrew.org/wiki/Bootloader#BootROM_Errors
|
||||
const vu8* bootMediaStatus = (vu8*) 0x1FFFE00C;
|
||||
const vu8* bootNcsdStatus = (vu8*) 0x1FFFE010;
|
||||
|
||||
if (!*(u64*) (void*) bootNcsdStatus) { // no NAND boot
|
||||
bool ntrboot_ok = !(bootMediaStatus[1]);
|
||||
bool shell_closed = (bootMediaStatus[3] == 2); // unsure of meaning(!)
|
||||
if (ntrboot_ok && shell_closed) return BOOT_NTRBOOT;
|
||||
} else if (!bootMediaStatus[0]) { // NAND boot okay, check partitions boot state
|
||||
int n_boot_firm = -1;
|
||||
for (u32 i = 0; i < 8; i++) {
|
||||
if (bootNcsdStatus[i] != 0) continue; // not booted from here, continue
|
||||
if (n_boot_firm >= 0) return BOOT_UNKNOWN; // booted from 2+ partitions?
|
||||
n_boot_firm = i;
|
||||
}
|
||||
if (n_boot_firm >= 0) return BOOT_NAND;
|
||||
}
|
||||
|
||||
return BOOT_UNKNOWN;
|
||||
}
|
||||
|
||||
bool CheckMultiEmuNand(void)
|
||||
{
|
||||
// this only checks for the theoretical possibility
|
||||
|
@ -79,7 +79,6 @@ u32 GetNandMinSizeSectors(u32 nand_src);
|
||||
u32 GetNandSizeSectors(u32 nand_src);
|
||||
u32 GetNandNcsdPartitionInfo(NandPartitionInfo* info, u32 type, u32 subtype, u32 index, NandNcsdHeader* ncsd);
|
||||
u32 GetNandPartitionInfo(NandPartitionInfo* info, u32 type, u32 subtype, u32 index, u32 nand_src);
|
||||
u32 GetBootOrigin(void);
|
||||
|
||||
u32 ValidateSecretSector(u8* sector);
|
||||
bool CheckMultiEmuNand(void);
|
||||
|
@ -353,8 +353,7 @@ bool init_vars(const char* path_script) {
|
||||
set_var("NULL", ""); // this one is special and should not be changed later
|
||||
set_var("CURRDIR", curr_dir); // script path, never changes
|
||||
set_var("GM9OUT", OUTPUT_PATH); // output path, never changes
|
||||
set_var("HAX", ((GetBootOrigin() & BOOT_NTRBOOT) && IS_SIGHAX) ? "ntrboot" :
|
||||
IS_SIGHAX ? "sighax" : IS_A9LH ? "a9lh" : ""); // type of hax running from
|
||||
set_var("HAX", IS_SIGHAX ? "sighax" : IS_A9LH ? "a9lh" : ""); // type of hax running from
|
||||
set_var("ONTYPE", IS_O3DS ? "O3DS" : "N3DS"); // type of the console
|
||||
set_var("RDTYPE", IS_DEVKIT ? "devkit" : "retail"); // devkit / retail
|
||||
upd_var(NULL); // set all dynamic environment vars
|
||||
|
Loading…
x
Reference in New Issue
Block a user