diff --git a/Makefile b/Makefile index eb4886941..5a31e2ec3 100644 --- a/Makefile +++ b/Makefile @@ -131,6 +131,7 @@ dist: dist-no-debug cp exosphere/loader_stub/loader_stub.elf atmosphere-$(AMSVER)-debug/exosphere-loader-stub.elf cp exosphere/program/program.elf atmosphere-$(AMSVER)-debug/exosphere-program.elf cp exosphere/warmboot/warmboot.elf atmosphere-$(AMSVER)-debug/exosphere-warmboot.elf + cp exosphere/mariko_fatal/mariko_fatal.elf atmosphere-$(AMSVER)-debug/exosphere-mariko-fatal.elf cp exosphere/program/sc7fw/sc7fw.elf atmosphere-$(AMSVER)-debug/exosphere-sc7fw.elf cp exosphere/program/rebootstub/rebootstub.elf atmosphere-$(AMSVER)-debug/exosphere-rebootstub.elf cp mesosphere/kernel_ldr/kernel_ldr.elf atmosphere-$(AMSVER)-debug/kernel_ldr.elf diff --git a/exosphere/Makefile b/exosphere/Makefile index 6ce912754..2a69bda57 100644 --- a/exosphere/Makefile +++ b/exosphere/Makefile @@ -5,25 +5,39 @@ define ATMOSPHERE_ADD_TARGET ATMOSPHERE_BUILD_CONFIGS += $(strip $1) -$(strip $1): exosphere$(strip $2).bin check_warmboot_$(strip $1) - @cp warmboot/warmboot$(strip $2).bin warmboot$(strip $2).bin +$(strip $1): exosphere$(strip $2).bin warmboot$(strip $2).bin mariko_fatal$(strip $2).bin exosphere$(strip $2).bin: loader_stub/loader_stub$(strip $2).bin @cp loader_stub/loader_stub$(strip $2).bin exosphere$(strip $2).bin @printf LENY >> exosphere$(strip $2).bin @echo "Built exosphere$(strip $2).bin..." +warmboot$(strip $2).bin: warmboot/warmboot$(strip $2).bin + @cp warmboot/warmboot$(strip $2).bin warmboot$(strip $2).bin + @echo "Built warmboot$(strip $2).bin..." + +mariko_fatal$(strip $2).bin: mariko_fatal/mariko_fatal$(strip $2).bin + @cp mariko_fatal/mariko_fatal$(strip $2).bin mariko_fatal$(strip $2).bin + @echo "Built mariko_fatal$(strip $2).bin..." + check_program_$(strip $1): @$$(MAKE) -C program $(strip $1) check_warmboot_$(strip $1): @$$(MAKE) -C warmboot $(strip $1) +check_mariko_fatal_$(strip $1): + @$$(MAKE) -C mariko_fatal $(strip $1) + loader_stub/loader_stub$(strip $2).bin: check_program_$(strip $1) @$$(MAKE) -C loader_stub $(strip $1) -clean-$(strip $1): clean-program-$(strip $1) clean-loader_stub-$(strip $1) clean-warmboot-$(strip $1) - @rm -rf exosphere$(strip $2).bin warmboot$(strip $2).bin +warmboot/warmboot$(strip $2).bin: check_warmboot_$(strip $1) + +mariko_fatal/mariko_fatal$(strip $2).bin: check_mariko_fatal_$(strip $1) + +clean-$(strip $1): clean-program-$(strip $1) clean-loader_stub-$(strip $1) clean-warmboot-$(strip $1) clean-mariko_fatal-$(strip $1) + @rm -rf exosphere$(strip $2).bin warmboot$(strip $2).bin mariko_fatal$(strip $2).bin clean-program-$(strip $1): @$$(MAKE) -C program clean-$(strip $1) @@ -34,6 +48,9 @@ clean-loader_stub-$(strip $1): clean-warmboot-$(strip $1): @$$(MAKE) -C warmboot clean-$(strip $1) +clean-mariko_fatal-$(strip $1): + @$$(MAKE) -C mariko_fatal clean-$(strip $1) + endef $(eval $(call ATMOSPHERE_ADD_TARGET, release, )) @@ -41,7 +58,7 @@ $(eval $(call ATMOSPHERE_ADD_TARGET, debug, _debug)) $(eval $(call ATMOSPHERE_ADD_TARGET, audit, _audit)) clean: clean-program clean-loader_stub clean-warmboot - @rm -rf exosphere*.bin warmboot*.bin + @rm -rf exosphere*.bin warmboot*.bin mariko_fatal*.bin clean-program: @$(MAKE) -C program clean @@ -52,4 +69,7 @@ clean-loader_stub: clean-warmboot: @$(MAKE) -C warmboot clean +clean-mariko_fatal: + @$(MAKE) -C mariko_fatal clean + .PHONY: all clean clean-program clean-loader_stub clean-warmboot $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),check_program_$(config) check_warmboot_$(strip $1) clean-$(config) clean-program-$(config) clean-loader_stub-$(config) clean-warmboot-$(config)) diff --git a/fusee/fusee-secondary/Makefile b/fusee/fusee-secondary/Makefile index 62520cc2c..b92040ea2 100644 --- a/fusee/fusee-secondary/Makefile +++ b/fusee/fusee-secondary/Makefile @@ -100,7 +100,8 @@ KIPFILES := loader.kip ncm.kip pm.kip sm.kip ams_mitm.kip spl.kip boot.kip BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) fusee-primary.bin \ exosphere.bin warmboot.bin rebootstub.bin thermosphere.bin splash_screen.bmp \ sept-primary.bin sept-secondary_00.enc sept-secondary_01.enc emummc.kip \ - sept-secondary_dev_00.enc sept-secondary_dev_01.enc mesosphere.bin kernel_ldr.bin $(KIPFILES) + sept-secondary_dev_00.enc sept-secondary_dev_01.enc mesosphere.bin kernel_ldr.bin \ + mariko_fatal.bin $(KIPFILES) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C diff --git a/fusee/fusee-secondary/linker.ld b/fusee/fusee-secondary/linker.ld index 0b4503a44..79dcb5f4b 100644 --- a/fusee/fusee-secondary/linker.ld +++ b/fusee/fusee-secondary/linker.ld @@ -256,4 +256,6 @@ SECTIONS PROVIDE(__kernel_ldr_bin_size__ = kernel_ldr_bin_end - kernel_ldr_bin); PROVIDE(__mesosphere_bin_start__ = mesosphere_bin - __start__); PROVIDE(__mesosphere_bin_size__ = mesosphere_bin_end - mesosphere_bin); + PROVIDE(__mariko_fatal_bin_start__ = mariko_fatal_bin - __start__); + PROVIDE(__mariko_fatal_bin_size__ = mariko_fatal_bin_end - mariko_fatal_bin); } diff --git a/fusee/fusee-secondary/src/nxboot.c b/fusee/fusee-secondary/src/nxboot.c index 907a95115..838927a35 100644 --- a/fusee/fusee-secondary/src/nxboot.c +++ b/fusee/fusee-secondary/src/nxboot.c @@ -55,6 +55,7 @@ #define u8 uint8_t #define u32 uint32_t #include "exosphere_bin.h" +#include "mariko_fatal_bin.h" #include "mesosphere_bin.h" #include "sept_secondary_00_enc.h" #include "sept_secondary_01_enc.h" @@ -1006,6 +1007,24 @@ uint32_t nxboot_main(void) { memcpy(exosphere_memaddr, exosphere_bin, exosphere_bin_size); } + /* Copy the exosphere mariko fatal program to a good location. */ + { + void * const mariko_fatal_dst = (void *)0x80020000; + memset(mariko_fatal_dst, 0, 0x20000); + + const size_t sd_mf_size = get_file_size("atmosphere/mariko_fatal.bin"); + if (sd_mf_size != 0) { + if (sd_mf_size > 0x20000) { + fatal_error("Error: atmosphere/mariko_fatal.bin is too large!\n"); + } + if (read_from_file(mariko_fatal_dst, sd_mf_size, "atmosphere/mariko_fatal.bin") != sd_mf_size) { + fatal_error("Error: failed to read atmosphere/mariko_fatal.bin"); + } + } else { + memcpy(mariko_fatal_dst, mariko_fatal_bin, mariko_fatal_bin_size); + } + } + /* Move BootConfig. */ print(SCREEN_LOG_LEVEL_INFO, "[NXBOOT] Moving BootConfig...\n"); nxboot_move_bootconfig(); diff --git a/fusee/fusee-secondary/src/start.s b/fusee/fusee-secondary/src/start.s index b9c118519..c73b9498c 100644 --- a/fusee/fusee-secondary/src/start.s +++ b/fusee/fusee-secondary/src/start.s @@ -107,6 +107,7 @@ _metadata: #define CONTENT_TYPE_EMC 8 #define CONTENT_TYPE_KLD 9 #define CONTENT_TYPE_KRN 10 +#define CONTENT_TYPE_EXF 11 #define CONTENT_FLAG_NONE (0 << 0) @@ -289,6 +290,18 @@ _content_headers: .asciz "emummc" .align 5 +/* exosphere mariko fatal program content header */ +.word __mariko_fatal_bin_start__ +.word __mariko_fatal_bin_size__ +.byte CONTENT_TYPE_EXF +.byte CONTENT_FLAG_NONE +.byte CONTENT_FLAG_NONE +.byte CONTENT_FLAG_NONE +.word 0xCCCCCCCC +.asciz "exosphere_fatal" +.align 5 + + /* splash_screen content header */ .word __splash_screen_bmp_start__ .word __splash_screen_bmp_size__