diff --git a/Makefile b/Makefile index 6c269bf..1dbf6b8 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,12 @@ commit := $(shell git rev-parse --short=8 HEAD) dir_source := source dir_patches := patches dir_arm11 := arm11 -dir_loader := loader -dir_injector := injector +dir_chainloader := chainloader dir_exceptions := exceptions dir_arm9_exceptions := $(dir_exceptions)/arm9 dir_arm11_exceptions := $(dir_exceptions)/arm11 +dir_sysmodules := sysmodules +dir_loader := $(dir_sysmodules)/loader dir_build := build dir_out := out @@ -30,9 +31,9 @@ objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \ $(call rwildcard, $(dir_source), *.s *.c))) bundled = $(dir_build)/reboot.bin.o $(dir_build)/emunand.bin.o $(dir_build)/svcGetCFWInfo.bin.o $(dir_build)/k11modules.bin.o \ - $(dir_build)/loader.bin.o $(dir_build)/arm9_exceptions.bin.o $(dir_build)/arm11_exceptions.bin.o + $(dir_build)/chainloader.bin.o $(dir_build)/arm9_exceptions.bin.o $(dir_build)/arm11_exceptions.bin.o -modules = $(dir_build)/injector.cxi +modules = $(dir_build)/loader.cxi define bin2o bin2s $< | $(AS) -o $(@) @@ -50,19 +51,19 @@ firm: $(dir_out)/boot.firm .PHONY: clean clean: @$(MAKE) -C $(dir_arm11) clean - @$(MAKE) -C $(dir_loader) clean + @$(MAKE) -C $(dir_chainloader) clean @$(MAKE) -C $(dir_arm9_exceptions) clean @$(MAKE) -C $(dir_arm11_exceptions) clean - @$(MAKE) -C $(dir_injector) clean + @$(MAKE) -C $(dir_loader) clean @rm -rf $(dir_out) $(dir_build) .PRECIOUS: $(dir_build)/%.bin .PHONY: $(dir_arm11) -.PHONY: $(dir_loader) +.PHONY: $(dir_chainloader) .PHONY: $(dir_arm9_exceptions) .PHONY: $(dir_arm11_exceptions) -.PHONY: $(dir_injector) +.PHONY: $(dir_loader) $(dir_out)/$(name)$(revision).7z: all @mkdir -p "$(@D)" @@ -83,14 +84,14 @@ $(dir_build)/arm11.elf: $(dir_arm11) $(dir_build)/main.elf: $(bundled) $(objects) $(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^ -$(dir_build)/injector.cxi: $(dir_injector) +$(dir_build)/loader.cxi: $(dir_loader) @mkdir -p "$(@D)" @$(MAKE) -C $< $(dir_build)/%.bin.o: $(dir_build)/%.bin @$(bin2o) -$(dir_build)/loader.bin: $(dir_loader) +$(dir_build)/chainloader.bin: $(dir_chainloader) @mkdir -p "$(@D)" @$(MAKE) -C $< diff --git a/loader/Makefile b/chainloader/Makefile similarity index 100% rename from loader/Makefile rename to chainloader/Makefile diff --git a/loader/linker.ld b/chainloader/linker.ld similarity index 100% rename from loader/linker.ld rename to chainloader/linker.ld diff --git a/loader/source/cache.h b/chainloader/source/cache.h similarity index 100% rename from loader/source/cache.h rename to chainloader/source/cache.h diff --git a/loader/source/cache.s b/chainloader/source/cache.s similarity index 100% rename from loader/source/cache.s rename to chainloader/source/cache.s diff --git a/loader/source/firm.c b/chainloader/source/firm.c similarity index 100% rename from loader/source/firm.c rename to chainloader/source/firm.c diff --git a/loader/source/firm.h b/chainloader/source/firm.h similarity index 100% rename from loader/source/firm.h rename to chainloader/source/firm.h diff --git a/loader/source/main.c b/chainloader/source/main.c similarity index 100% rename from loader/source/main.c rename to chainloader/source/main.c diff --git a/loader/source/memory.c b/chainloader/source/memory.c similarity index 100% rename from loader/source/memory.c rename to chainloader/source/memory.c diff --git a/loader/source/memory.h b/chainloader/source/memory.h similarity index 100% rename from loader/source/memory.h rename to chainloader/source/memory.h diff --git a/loader/source/start.s b/chainloader/source/start.s similarity index 100% rename from loader/source/start.s rename to chainloader/source/start.s diff --git a/loader/source/types.h b/chainloader/source/types.h similarity index 100% rename from loader/source/types.h rename to chainloader/source/types.h diff --git a/source/firm.c b/source/firm.c index fa701bf..e0c4838 100755 --- a/source/firm.c +++ b/source/firm.c @@ -472,14 +472,12 @@ bool checkFirmPayload(void) void launchFirm(int argc, char **argv) { - u32 *loaderAddress = (u32 *)0x01FF9000; + u32 *chainloaderAddress = (u32 *)0x01FF9000; prepareArm11ForFirmlaunch(); - memcpy(loaderAddress, loader_bin, loader_bin_size); + memcpy(chainloaderAddress, chainloader_bin, chainloader_bin_size); - flushDCacheRange(loaderAddress, loader_bin_size); - flushICacheRange(loaderAddress, loader_bin_size); - - ((void (*)(int, char **, u32))loaderAddress)(argc, argv, 0x0000BEEF); + // No need to flush caches here, the chainloader is in ITCM + ((void (*)(int, char **, u32))chainloaderAddress)(argc, argv, 0x0000BEEF); } diff --git a/injector/LICENSE b/sysmodules/loader/LICENSE similarity index 100% rename from injector/LICENSE rename to sysmodules/loader/LICENSE diff --git a/injector/Makefile b/sysmodules/loader/Makefile similarity index 98% rename from injector/Makefile rename to sysmodules/loader/Makefile index 5657fa8..532d934 100755 --- a/injector/Makefile +++ b/sysmodules/loader/Makefile @@ -11,7 +11,7 @@ name := $(shell basename $(CURDIR)) dir_source := source dir_patches := patches dir_build := build -dir_out := ../$(dir_build) +dir_out := ../../$(dir_build) LIBS := -lctru LIBDIRS := $(CTRULIB) diff --git a/injector/README.md b/sysmodules/loader/README.md similarity index 100% rename from injector/README.md rename to sysmodules/loader/README.md diff --git a/injector/loader.rsf b/sysmodules/loader/loader.rsf similarity index 100% rename from injector/loader.rsf rename to sysmodules/loader/loader.rsf diff --git a/injector/patches/romfsredir.s b/sysmodules/loader/patches/romfsredir.s similarity index 100% rename from injector/patches/romfsredir.s rename to sysmodules/loader/patches/romfsredir.s diff --git a/injector/source/CFWInfo.h b/sysmodules/loader/source/CFWInfo.h similarity index 100% rename from injector/source/CFWInfo.h rename to sysmodules/loader/source/CFWInfo.h diff --git a/injector/source/CFWInfo.s b/sysmodules/loader/source/CFWInfo.s similarity index 100% rename from injector/source/CFWInfo.s rename to sysmodules/loader/source/CFWInfo.s diff --git a/injector/source/exheader.h b/sysmodules/loader/source/exheader.h similarity index 100% rename from injector/source/exheader.h rename to sysmodules/loader/source/exheader.h diff --git a/injector/source/fsldr.c b/sysmodules/loader/source/fsldr.c similarity index 100% rename from injector/source/fsldr.c rename to sysmodules/loader/source/fsldr.c diff --git a/injector/source/fsldr.h b/sysmodules/loader/source/fsldr.h similarity index 100% rename from injector/source/fsldr.h rename to sysmodules/loader/source/fsldr.h diff --git a/injector/source/fsreg.c b/sysmodules/loader/source/fsreg.c similarity index 100% rename from injector/source/fsreg.c rename to sysmodules/loader/source/fsreg.c diff --git a/injector/source/fsreg.h b/sysmodules/loader/source/fsreg.h similarity index 100% rename from injector/source/fsreg.h rename to sysmodules/loader/source/fsreg.h diff --git a/injector/source/ifile.c b/sysmodules/loader/source/ifile.c similarity index 100% rename from injector/source/ifile.c rename to sysmodules/loader/source/ifile.c diff --git a/injector/source/ifile.h b/sysmodules/loader/source/ifile.h similarity index 100% rename from injector/source/ifile.h rename to sysmodules/loader/source/ifile.h diff --git a/injector/source/loader.c b/sysmodules/loader/source/loader.c similarity index 100% rename from injector/source/loader.c rename to sysmodules/loader/source/loader.c diff --git a/injector/source/memory.c b/sysmodules/loader/source/memory.c similarity index 100% rename from injector/source/memory.c rename to sysmodules/loader/source/memory.c diff --git a/injector/source/memory.h b/sysmodules/loader/source/memory.h similarity index 100% rename from injector/source/memory.h rename to sysmodules/loader/source/memory.h diff --git a/injector/source/patcher.c b/sysmodules/loader/source/patcher.c similarity index 100% rename from injector/source/patcher.c rename to sysmodules/loader/source/patcher.c diff --git a/injector/source/patcher.h b/sysmodules/loader/source/patcher.h similarity index 100% rename from injector/source/patcher.h rename to sysmodules/loader/source/patcher.h diff --git a/injector/source/pxipm.c b/sysmodules/loader/source/pxipm.c similarity index 100% rename from injector/source/pxipm.c rename to sysmodules/loader/source/pxipm.c diff --git a/injector/source/pxipm.h b/sysmodules/loader/source/pxipm.h similarity index 100% rename from injector/source/pxipm.h rename to sysmodules/loader/source/pxipm.h diff --git a/injector/source/srvsys.c b/sysmodules/loader/source/srvsys.c similarity index 100% rename from injector/source/srvsys.c rename to sysmodules/loader/source/srvsys.c diff --git a/injector/source/srvsys.h b/sysmodules/loader/source/srvsys.h similarity index 100% rename from injector/source/srvsys.h rename to sysmodules/loader/source/srvsys.h diff --git a/injector/source/strings.c b/sysmodules/loader/source/strings.c similarity index 100% rename from injector/source/strings.c rename to sysmodules/loader/source/strings.c diff --git a/injector/source/strings.h b/sysmodules/loader/source/strings.h similarity index 100% rename from injector/source/strings.h rename to sysmodules/loader/source/strings.h