1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-22 18:32:05 +00:00

fusee: embed a copy of emummc

This commit is contained in:
Michael Scire 2019-06-15 05:48:04 -07:00
parent 5ae9bd5fe5
commit e5402bd8b8
4 changed files with 46 additions and 22 deletions

View file

@ -89,7 +89,7 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(AMS)/exosphere $(AMS)/exosphere/lp0fw $(AMS)/exosphere/rebootstub \
$(AMS)/thermosphere $(AMS)/fusee/fusee-primary $(AMS)/sept/sept-primary \
$(AMS)/sept/sept-secondary $(KIPDIRS)
$(AMS)/sept/sept-secondary $(AMS)/emummc $(KIPDIRS)
export DEPSDIR := $(CURDIR)/$(BUILD)
@ -99,7 +99,7 @@ SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
KIPFILES := loader.kip pm.kip sm.kip ams_mitm.kip spl.kip boot.kip
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) fusee-primary.bin \
exosphere.bin lp0fw.bin rebootstub.bin thermosphere.bin splash_screen.bmp \
sept-primary.bin sept-secondary.enc \
sept-primary.bin sept-secondary.enc emummc.kip \
$(KIPFILES)
#---------------------------------------------------------------------------------
@ -128,7 +128,7 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean all
.PHONY: check_fusee_primary check_exosphere check_sept check_thermosphere check_stratosphere
.PHONY: check_fusee_primary check_exosphere check_sept check_emummc check_thermosphere check_stratosphere
#---------------------------------------------------------------------------------
all: $(BUILD)
@ -142,6 +142,9 @@ check_exosphere:
check_sept:
@$(MAKE) -C $(AMS)/sept all
check_emummc:
@$(MAKE) -C $(AMS)/emummc EMUMMCDIR=$(AMS)/emummc all
check_thermosphere:
@$(MAKE) -C $(AMS)/thermosphere all
@ -149,7 +152,7 @@ check_stratosphere:
@$(MAKE) -C $(AMS)/stratosphere all
$(BUILD): check_fusee_primary check_exosphere check_sept check_thermosphere check_stratosphere
$(BUILD): check_fusee_primary check_exosphere check_sept check_emummc check_thermosphere check_stratosphere
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@ -161,6 +164,7 @@ clean:
@$(MAKE) -C $(AMS)/thermosphere clean
@$(MAKE) -C $(AMS)/stratosphere clean
@$(MAKE) -C $(AMS)/sept clean
@$(MAKE) -C $(AMS)/emummc clean
@rm -fr $(BUILD) $(TARGET).bin $(TARGET).elf
#---------------------------------------------------------------------------------

View file

@ -246,4 +246,6 @@ SECTIONS
PROVIDE(__splash_screen_bmp_size__ = splash_screen_bmp_end - splash_screen_bmp);
PROVIDE(__thermosphere_bin_start__ = thermosphere_bin - __start__);
PROVIDE(__thermosphere_bin_size__ = thermosphere_bin_end - thermosphere_bin);
PROVIDE(__emummc_kip_start__ = emummc_kip - __start__);
PROVIDE(__emummc_kip_size__ = emummc_kip_end - emummc_kip);
}

View file

@ -55,6 +55,7 @@
#include "exosphere_bin.h"
#include "sept_secondary_enc.h"
#include "lp0fw_bin.h"
#include "emummc_kip.h"
#include "lib/log.h"
#undef u8
#undef u32
@ -451,8 +452,8 @@ uint32_t nxboot_main(void) {
void *warmboot_memaddr;
void *package1loader;
size_t package1loader_size;
void *emummc_kip;
size_t emummc_kip_size;
void *emummc;
size_t emummc_size;
uint32_t available_revision;
FILE *boot0, *pk2file;
void *exosphere_memaddr;
@ -460,25 +461,33 @@ uint32_t nxboot_main(void) {
/* Configure emummc or mount the real NAND. */
if (!nxboot_configure_emummc(&exo_emummc_cfg)) {
emummc_kip = NULL;
emummc_kip_size = 0;
emummc = NULL;
emummc_size = 0;
if (nxfs_mount_emmc() < 0) {
fatal_error("[NXBOOT] Failed to mount eMMC!\n");
}
} else {
emummc_kip_size = get_file_size("atmosphere/emummc.kip");
if (emummc_kip_size == 0) {
fatal_error("[NXBOOT] Could not read emummc kip!\n");
}
/* Allocate memory for the TSEC firmware. */
emummc_kip = memalign(0x100, emummc_kip_size);
if (emummc_kip == NULL) {
fatal_error("[NXBOOT] Out of memory!\n");
}
if (read_from_file(emummc_kip, emummc_kip_size, "atmosphere/emummc.kip") != emummc_kip_size) {
fatal_error("[NXBOOT] Could not read the emummc kip!\n");
emummc_size = get_file_size("atmosphere/emummc.kip");
if (emummc_size != 0) {
/* Allocate memory for the TSEC firmware. */
emummc = memalign(0x100, emummc_size);
if (emummc == NULL) {
fatal_error("[NXBOOT] Out of memory!\n");
}
if (read_from_file(emummc, emummc_size, "atmosphere/emummc.kip") != emummc_size) {
fatal_error("[NXBOOT] Could not read the emummc kip!\n");
}
} else {
/* Use embedded copy. */
emummc_size = emummc_kip_size;
emummc = memalign(0x100, emummc_size);
if (emummc == NULL) {
fatal_error("[NXBOOT] Out of memory!\n");
}
memcpy(emummc, emummc_kip, emummc_size);
}
}
@ -694,7 +703,7 @@ uint32_t nxboot_main(void) {
print(SCREEN_LOG_LEVEL_INFO, u8"[NXBOOT] Configured Stratosphere...\n");
/* Patch package2, adding Thermosphère + custom KIPs. */
package2_rebuild_and_copy(package2, MAILBOX_EXOSPHERE_CONFIGURATION->target_firmware, emummc_kip, emummc_kip_size);
package2_rebuild_and_copy(package2, MAILBOX_EXOSPHERE_CONFIGURATION->target_firmware, emummc, emummc_size);
/* Set detected FS version. */
MAILBOX_EXOSPHERE_CONFIGURATION->emummc_cfg.base_cfg.fs_version = stratosphere_get_fs_version();

View file

@ -93,6 +93,7 @@ _metadata:
#define CONTENT_TYPE_SP2 5
#define CONTENT_TYPE_KIP 6
#define CONTENT_TYPE_BMP 7
#define CONTENT_TYPE_EMC 8
_content_headers:
/* ams_mitm content header */
@ -191,6 +192,14 @@ _content_headers:
.asciz "spl"
.align 5
/* emummc content header */
.word __emummc_kip_start__
.word __emummc_kip_size__
.word CONTENT_TYPE_EMC
.word 0xCCCCCCCC
.asciz "emummc"
.align 5
/* splash_screen content header */
.word __splash_screen_bmp_start__
.word __splash_screen_bmp_size__