diff --git a/exosphere/loader_stub/loader_stub.mk b/exosphere/loader_stub/loader_stub.mk index df737a370..7bffe7dc0 100644 --- a/exosphere/loader_stub/loader_stub.mk +++ b/exosphere/loader_stub/loader_stub.mk @@ -15,13 +15,12 @@ ifneq ($(__RECURSIVE__),1) export ATMOSPHERE_TOPDIR := $(CURRENT_DIRECTORY) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(CURDIR)/include \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ - $(CURRENT_DIRECTORY)/../program/$(ATMOSPHERE_OUT_DIR) + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) CFILES := $(call FIND_SOURCE_FILES,$(SOURCES),c) CPPFILES := $(call FIND_SOURCE_FILES,$(SOURCES),cpp) SFILES := $(call FIND_SOURCE_FILES,$(SOURCES),s) -BINFILES := program.lz4 boot_code.lz4 +BINFILES := #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C @@ -102,13 +101,7 @@ $(OUTPUT).elf : $(OFILES) $(OFILES) : $(ATMOSPHERE_LIBRARIES_DIR)/libexosphere/$(ATMOSPHERE_LIBRARY_DIR)/libexosphere.a -program.lz4.o: program.lz4 - @echo $(notdir $<) - @$(bin2o) - -boot_code.lz4.o: boot_code.lz4 - @echo $(notdir $<) - @$(bin2o) +secmon_loader_main.o: CXXFLAGS += --embed-dir="$(CURRENT_DIRECTORY)/../program/$(ATMOSPHERE_OUT_DIR)/" %.elf: @echo linking $(notdir $@) @@ -117,14 +110,6 @@ boot_code.lz4.o: boot_code.lz4 $(OFILES_SRC) : $(OFILES_BIN) -#--------------------------------------------------------------------------------- -# you need a rule like this for each extension you use as binary data -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h: %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - -include $(DEPENDS) #--------------------------------------------------------------------------------------- diff --git a/exosphere/loader_stub/source/secmon_loader_main.cpp b/exosphere/loader_stub/source/secmon_loader_main.cpp index 368941eb1..782d7ac11 100644 --- a/exosphere/loader_stub/source/secmon_loader_main.cpp +++ b/exosphere/loader_stub/source/secmon_loader_main.cpp @@ -15,21 +15,31 @@ */ #include #include "secmon_loader_uncompress.hpp" -#include "program_lz4.h" -#include "boot_code_lz4.h" namespace ams::secmon::loader { - NORETURN void UncompressAndExecute(const void *program, const void *boot_code) { + namespace { + + constexpr const u8 SecmonProgramLz4[] = { + #embed + }; + + constexpr const u8 SecmonBootCodeLz4[] = { + #embed + }; + + } + + NORETURN void UncompressAndExecute() { /* Uncompress the program image. */ - Uncompress(secmon::MemoryRegionPhysicalTzramFullProgramImage.GetPointer(), secmon::MemoryRegionPhysicalTzramFullProgramImage.GetSize(), program, program_lz4_size); + Uncompress(secmon::MemoryRegionPhysicalTzramFullProgramImage.GetPointer(), secmon::MemoryRegionPhysicalTzramFullProgramImage.GetSize(), SecmonProgramLz4, sizeof(SecmonProgramLz4)); /* Copy the boot image to the end of IRAM */ - u8 *relocated_boot_code = secmon::MemoryRegionPhysicalIramBootCodeImage.GetEndPointer() - boot_code_lz4_size; - std::memcpy(relocated_boot_code, boot_code, boot_code_lz4_size); + u8 *relocated_boot_code = secmon::MemoryRegionPhysicalIramBootCodeImage.GetEndPointer() - sizeof(SecmonBootCodeLz4); + std::memcpy(relocated_boot_code, SecmonBootCodeLz4, sizeof(SecmonBootCodeLz4)); /* Uncompress the boot image. */ - Uncompress(secmon::MemoryRegionPhysicalIramBootCodeImage.GetPointer(), secmon::MemoryRegionPhysicalIramBootCodeImage.GetSize(), relocated_boot_code, boot_code_lz4_size); + Uncompress(secmon::MemoryRegionPhysicalIramBootCodeImage.GetPointer(), secmon::MemoryRegionPhysicalIramBootCodeImage.GetSize(), relocated_boot_code, sizeof(SecmonBootCodeLz4)); /* Jump to the boot image. */ reinterpret_cast(secmon::MemoryRegionPhysicalIramBootCodeImage.GetAddress())(); diff --git a/exosphere/loader_stub/source/start.s b/exosphere/loader_stub/source/start.s index 47838e5fa..6640ac2d9 100644 --- a/exosphere/loader_stub/source/start.s +++ b/exosphere/loader_stub/source/start.s @@ -98,8 +98,5 @@ _start: ldr x20, =0x7C020000 mov sp, x20 - adr x0, program_lz4 - adr x1, boot_code_lz4 - /* Uncompress the program and iram boot code images. */ - b _ZN3ams6secmon6loader20UncompressAndExecuteEPKvS3_ + b _ZN3ams6secmon6loader20UncompressAndExecuteEv