From 49f627bb28103830d8682fda8b46542ba6e06abd Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 16 Oct 2018 14:19:55 -0700 Subject: [PATCH] fusee: Load fs.mitm by default. --- fusee/fusee-secondary/Makefile | 4 ++-- fusee/fusee-secondary/src/main.c | 4 ++-- fusee/fusee-secondary/src/nxboot.c | 4 +++- fusee/fusee-secondary/src/stratosphere.c | 15 +++++++++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/fusee/fusee-secondary/Makefile b/fusee/fusee-secondary/Makefile index 55377889f..d902d588b 100644 --- a/fusee/fusee-secondary/Makefile +++ b/fusee/fusee-secondary/Makefile @@ -69,7 +69,7 @@ ifneq ($(BUILD),$(notdir $(CURDIR))) export OUTPUT := $(CURDIR)/$(TARGET) export TOPDIR := $(CURDIR) -export KIPDIRS := $(AMS)/stratosphere/loader $(AMS)/stratosphere/pm $(AMS)/stratosphere/sm $(AMS)/stratosphere/boot +export KIPDIRS := $(AMS)/stratosphere/loader $(AMS)/stratosphere/pm $(AMS)/stratosphere/sm $(AMS)/stratosphere/boot $(AMS)/stratosphere/fs_mitm export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ $(AMS)/exosphere $(AMS)/thermosphere $(KIPDIRS) @@ -79,7 +79,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -KIPFILES := loader.kip pm.kip sm.kip boot_100.kip boot_200.kip +KIPFILES := loader.kip pm.kip sm.kip fs_mitm.kip boot_100.kip boot_200.kip BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) exosphere.bin thermosphere.bin splash_screen.bmp $(KIPFILES) #--------------------------------------------------------------------------------- diff --git a/fusee/fusee-secondary/src/main.c b/fusee/fusee-secondary/src/main.c index d10e6e7cb..753efc0aa 100644 --- a/fusee/fusee-secondary/src/main.c +++ b/fusee/fusee-secondary/src/main.c @@ -101,13 +101,13 @@ int main(int argc, void **argv) { g_do_nxboot = loader_ctx->chainload_entrypoint == 0; if (g_do_nxboot) { - print(SCREEN_LOG_LEVEL_INFO, "Now performing nxboot.\n"); + print(SCREEN_LOG_LEVEL_MANDATORY, "Now performing nxboot.\n"); uint32_t boot_memaddr = nxboot_main(); nxboot_finish(boot_memaddr); } else { /* TODO: What else do we want to do in terms of argc/argv? */ const char *path = get_loader_ctx()->file_paths_to_load[get_loader_ctx()->file_id_of_entrypoint]; - print(SCREEN_LOG_LEVEL_INFO, "Now chainloading.\n"); + print(SCREEN_LOG_LEVEL_MANDATORY, "Now chainloading.\n"); g_chainloader_argc = 1; strcpy(g_chainloader_arg_data, path); } diff --git a/fusee/fusee-secondary/src/nxboot.c b/fusee/fusee-secondary/src/nxboot.c index 83fb6ca3a..9b9c73ed2 100644 --- a/fusee/fusee-secondary/src/nxboot.c +++ b/fusee/fusee-secondary/src/nxboot.c @@ -292,6 +292,8 @@ uint32_t nxboot_main(void) { fatal_error("[NXBOOT]: Failed to detect target firmware!\n"); else print(SCREEN_LOG_LEVEL_INFO, "[NXBOOT]: Detected target firmware %ld!\n", target_firmware); + + print(SCREEN_LOG_LEVEL_MANDATORY, "[NXBOOT]: Loaded firmware from eMMC...\n"); /* Setup boot configuration for Exosphère. */ nxboot_configure_exosphere(target_firmware); @@ -357,7 +359,7 @@ uint32_t nxboot_main(void) { pmc->scratch1 = (uint32_t)warmboot_memaddr; } - print(SCREEN_LOG_LEVEL_INFO, "[NXBOOT]: Rebuilding package2...\n"); + print(SCREEN_LOG_LEVEL_MANDATORY, "[NXBOOT]: Rebuilding package2...\n"); /* Patch package2, adding Thermosphère + custom KIPs. */ package2_rebuild_and_copy(package2, MAILBOX_EXOSPHERE_CONFIGURATION->target_firmware); diff --git a/fusee/fusee-secondary/src/stratosphere.c b/fusee/fusee-secondary/src/stratosphere.c index 22d058b92..2223a2247 100644 --- a/fusee/fusee-secondary/src/stratosphere.c +++ b/fusee/fusee-secondary/src/stratosphere.c @@ -38,12 +38,13 @@ static ini1_header_t *g_stratosphere_ini1 = NULL; static bool g_stratosphere_loader_enabled = true; static bool g_stratosphere_sm_enabled = true; static bool g_stratosphere_pm_enabled = true; +static bool g_stratosphere_fs_mitm_enabled = true; static bool g_stratosphere_boot_enabled = false; extern const uint8_t boot_100_kip[], boot_200_kip[]; -extern const uint8_t loader_kip[], pm_kip[], sm_kip[]; +extern const uint8_t loader_kip[], pm_kip[], sm_kip[], fs_mitm_kip[]; extern const uint32_t boot_100_kip_size, boot_200_kip_size; -extern const uint32_t loader_kip_size, pm_kip_size, sm_kip_size; +extern const uint32_t loader_kip_size, pm_kip_size, sm_kip_size, fs_mitm_kip_size; /* GCC doesn't consider the size as const... we have to write it ourselves. */ @@ -83,6 +84,11 @@ ini1_header_t *stratosphere_get_ini1(uint32_t target_firmware) { num_processes++; } + if (g_stratosphere_fs_mitm_enabled) { + size += fs_mitm_kip_size; + num_processes++; + } + if (g_stratosphere_boot_enabled) { size += boot_kip_size; num_processes++; @@ -117,6 +123,11 @@ ini1_header_t *stratosphere_get_ini1(uint32_t target_firmware) { data += sm_kip_size; } + if (g_stratosphere_fs_mitm_enabled) { + memcpy(data, fs_mitm_kip, fs_mitm_kip_size); + data += fs_mitm_kip_size; + } + if (g_stratosphere_boot_enabled) { memcpy(data, boot_kip, boot_kip_size); data += boot_kip_size;