diff --git a/fusee/fusee-primary/src/fs_utils.c b/fusee/fusee-primary/src/fs_utils.c index 1c8529f07..9146ad0c2 100644 --- a/fusee/fusee-primary/src/fs_utils.c +++ b/fusee/fusee-primary/src/fs_utils.c @@ -47,6 +47,12 @@ void unmount_sd(void) sdmmc_device_finish(&g_sd_device); g_sd_mounted = false; } + + /* Disable AHB redirection if necessary. */ + if (g_ahb_redirect_enabled) { + mc_disable_ahb_redirect(); + g_ahb_redirect_enabled = false; + } } uint32_t get_file_size(const char *filename) diff --git a/fusee/fusee-secondary/src/nxboot.c b/fusee/fusee-secondary/src/nxboot.c index dbe0882b1..0e1351251 100644 --- a/fusee/fusee-secondary/src/nxboot.c +++ b/fusee/fusee-secondary/src/nxboot.c @@ -362,6 +362,15 @@ void nxboot_main(void) { printf("[NXBOOT]: Moving BootConfig...\n"); nxboot_move_bootconfig(); + /* Set 3.0.0/3.0.1/3.0.2 warmboot security check. */ + if (MAILBOX_EXOSPHERE_CONFIGURATION->target_firmware == EXOSPHERE_TARGET_FIRMWARE_300) { + const package1loader_header_t *package1loader_header = (const package1loader_header_t *)package1loader; + if (!strcmp(package1loader_header->build_timestamp, "20170519101410")) + pmc->secure_scratch32 = 0xE3; /* Warmboot 3.0.0 security check.*/ + else if (!strcmp(package1loader_header->build_timestamp, "20170710161758")) + pmc->secure_scratch32 = 0x104; /* Warmboot 3.0.1/3.0.2 security check. */ + } + /* Clean up. */ free(package1loader); if (loader_ctx->tsecfw_path[0] != '\0') { @@ -424,7 +433,7 @@ void nxboot_main(void) { display_end(); /* Boot CPU0. */ - cluster_boot_cpu0((uint64_t)(uintptr_t)exosphere_memaddr); + cluster_boot_cpu0((uint32_t)exosphere_memaddr); /* Wait for Exosphère to wake up. */ while (MAILBOX_NX_BOOTLOADER_IS_SECMON_AWAKE == 0) { diff --git a/fusee/fusee-secondary/src/nxfs.c b/fusee/fusee-secondary/src/nxfs.c index fcb05d0f9..81c775a30 100644 --- a/fusee/fusee-secondary/src/nxfs.c +++ b/fusee/fusee-secondary/src/nxfs.c @@ -48,6 +48,7 @@ static int mmc_partition_initialize(device_partition_t *devpart) { devpart->crypto_work_buffer_num_sectors = 0; } + /* Enable AHB redirection if necessary. */ if (!g_ahb_redirect_enabled) { mc_enable_ahb_redirect(); g_ahb_redirect_enabled = true; @@ -78,6 +79,12 @@ static int mmc_partition_initialize(device_partition_t *devpart) { static void mmc_partition_finalize(device_partition_t *devpart) { free(devpart->crypto_work_buffer); + + /* Disable AHB redirection if necessary. */ + if (g_ahb_redirect_enabled) { + mc_disable_ahb_redirect(); + g_ahb_redirect_enabled = false; + } } static int mmc_partition_read(device_partition_t *devpart, void *dst, uint64_t sector, uint64_t num_sectors) {