mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-07 01:51:17 -04:00
exo: use #embed for loader stub
This commit is contained in:
parent
2c50ef717a
commit
66acab02db
3 changed files with 21 additions and 29 deletions
|
@ -15,13 +15,12 @@ ifneq ($(__RECURSIVE__),1)
|
||||||
export ATMOSPHERE_TOPDIR := $(CURRENT_DIRECTORY)
|
export ATMOSPHERE_TOPDIR := $(CURRENT_DIRECTORY)
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(CURDIR)/include \
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(CURDIR)/include \
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
$(CURRENT_DIRECTORY)/../program/$(ATMOSPHERE_OUT_DIR)
|
|
||||||
|
|
||||||
CFILES := $(call FIND_SOURCE_FILES,$(SOURCES),c)
|
CFILES := $(call FIND_SOURCE_FILES,$(SOURCES),c)
|
||||||
CPPFILES := $(call FIND_SOURCE_FILES,$(SOURCES),cpp)
|
CPPFILES := $(call FIND_SOURCE_FILES,$(SOURCES),cpp)
|
||||||
SFILES := $(call FIND_SOURCE_FILES,$(SOURCES),s)
|
SFILES := $(call FIND_SOURCE_FILES,$(SOURCES),s)
|
||||||
BINFILES := program.lz4 boot_code.lz4
|
BINFILES :=
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
# 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
|
$(OFILES) : $(ATMOSPHERE_LIBRARIES_DIR)/libexosphere/$(ATMOSPHERE_LIBRARY_DIR)/libexosphere.a
|
||||||
|
|
||||||
program.lz4.o: program.lz4
|
secmon_loader_main.o: CXXFLAGS += --embed-dir="$(CURRENT_DIRECTORY)/../program/$(ATMOSPHERE_OUT_DIR)/"
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
boot_code.lz4.o: boot_code.lz4
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
%.elf:
|
%.elf:
|
||||||
@echo linking $(notdir $@)
|
@echo linking $(notdir $@)
|
||||||
|
@ -117,14 +110,6 @@ boot_code.lz4.o: boot_code.lz4
|
||||||
|
|
||||||
$(OFILES_SRC) : $(OFILES_BIN)
|
$(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)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -15,21 +15,31 @@
|
||||||
*/
|
*/
|
||||||
#include <exosphere.hpp>
|
#include <exosphere.hpp>
|
||||||
#include "secmon_loader_uncompress.hpp"
|
#include "secmon_loader_uncompress.hpp"
|
||||||
#include "program_lz4.h"
|
|
||||||
#include "boot_code_lz4.h"
|
|
||||||
|
|
||||||
namespace ams::secmon::loader {
|
namespace ams::secmon::loader {
|
||||||
|
|
||||||
NORETURN void UncompressAndExecute(const void *program, const void *boot_code) {
|
namespace {
|
||||||
|
|
||||||
|
constexpr const u8 SecmonProgramLz4[] = {
|
||||||
|
#embed <program.lz4>
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr const u8 SecmonBootCodeLz4[] = {
|
||||||
|
#embed <boot_code.lz4>
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NORETURN void UncompressAndExecute() {
|
||||||
/* Uncompress the program image. */
|
/* 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 */
|
/* Copy the boot image to the end of IRAM */
|
||||||
u8 *relocated_boot_code = secmon::MemoryRegionPhysicalIramBootCodeImage.GetEndPointer<u8>() - boot_code_lz4_size;
|
u8 *relocated_boot_code = secmon::MemoryRegionPhysicalIramBootCodeImage.GetEndPointer<u8>() - sizeof(SecmonBootCodeLz4);
|
||||||
std::memcpy(relocated_boot_code, boot_code, boot_code_lz4_size);
|
std::memcpy(relocated_boot_code, SecmonBootCodeLz4, sizeof(SecmonBootCodeLz4));
|
||||||
|
|
||||||
/* Uncompress the boot image. */
|
/* 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. */
|
/* Jump to the boot image. */
|
||||||
reinterpret_cast<void (*)()>(secmon::MemoryRegionPhysicalIramBootCodeImage.GetAddress())();
|
reinterpret_cast<void (*)()>(secmon::MemoryRegionPhysicalIramBootCodeImage.GetAddress())();
|
||||||
|
|
|
@ -98,8 +98,5 @@ _start:
|
||||||
ldr x20, =0x7C020000
|
ldr x20, =0x7C020000
|
||||||
mov sp, x20
|
mov sp, x20
|
||||||
|
|
||||||
adr x0, program_lz4
|
|
||||||
adr x1, boot_code_lz4
|
|
||||||
|
|
||||||
/* Uncompress the program and iram boot code images. */
|
/* Uncompress the program and iram boot code images. */
|
||||||
b _ZN3ams6secmon6loader20UncompressAndExecuteEPKvS3_
|
b _ZN3ams6secmon6loader20UncompressAndExecuteEv
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue