-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DLP patches to allow .cia reading from sd card
- Loading branch information
Showing
13 changed files
with
450 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "ios_net_patches.h" | ||
#include "../../ios_net/ios_net_syms.h" | ||
#include "elf_patcher.h" | ||
#include "types.h" | ||
|
||
#define NET_CODE_BASE_PHYS_ADDR (0) | ||
|
||
u32 net_get_phys_code_base(void) { | ||
return _text_start + NET_CODE_BASE_PHYS_ADDR; | ||
} | ||
|
||
void net_run_patches(u32 ios_elf_start) { | ||
section_write(ios_elf_start, _text_start, (void *) net_get_phys_code_base(), _text_end - _text_start); | ||
|
||
// Patch DLP region check by replacing result code with success | ||
section_write_word(ios_elf_start, 0x1239DA7C, 0); | ||
|
||
// Patch DLP to ignore error for missing title archive | ||
section_write_word(ios_elf_start, 0x1239E108, 0xEA000000); // mov r0, r0 | ||
section_write_word(ios_elf_start, 0x1239E10C, 0xEA000000); // mov r0, r0 | ||
section_write_word(ios_elf_start, 0x1239E110, 0xEA000000); // mov r0, r0 | ||
|
||
// Patch DLP path from /vol/content/dlp/app to sd:/dlp/app | ||
section_write_word(ios_elf_start, 0x12455368, 0x2F766F6C); // /vol | ||
section_write_word(ios_elf_start, 0x12455368 + 4, 0x2F646C70); // /dlp | ||
section_write_word(ios_elf_start, 0x12455368 + 8, 0x5F5F7364); // __sd | ||
section_write_word(ios_elf_start, 0x12455368 + 12, 0x2F646C70); // /dlp | ||
section_write_word(ios_elf_start, 0x12455368 + 16, 0x2F617070); // /app | ||
section_write_word(ios_elf_start, 0x12455368 + 20, 0x00000000); // | ||
|
||
// Patch DLP path from /vol/content/dlp/app to sd:/dlp/app | ||
section_write_word(ios_elf_start, 0x12455490, 0x2F766F6C); // /vol | ||
section_write_word(ios_elf_start, 0x12455490 + 4, 0x2F646C70); // /dlp | ||
section_write_word(ios_elf_start, 0x12455490 + 8, 0x5F5F7364); // __sd | ||
section_write_word(ios_elf_start, 0x12455490 + 12, 0x2F646C70); // /dlp | ||
section_write_word(ios_elf_start, 0x12455490 + 16, 0x2F617070); // /app | ||
section_write_word(ios_elf_start, 0x12455490 + 20, 0x00000000); // | ||
|
||
// DLP: (un)mount sd card for .cia reading. | ||
section_write_word(ios_elf_start, 0x1237f33c, ARM_BL(0x1237f33c, DLP_FSAInit_patch)); | ||
section_write_word(ios_elf_start, 0x123a4448, ARM_BL(0x123a4448, DLP_FSAInit_patch)); | ||
section_write_word(ios_elf_start, 0x1239de98, ARM_BL(0x1239de98, DLP_FSAInit_patch)); | ||
|
||
section_write_word(ios_elf_start, 0x1237f310, ARM_BL(0x1237f310, DLP_FSADeinit_patch)); | ||
section_write_word(ios_elf_start, 0x1239dfa0, ARM_BL(0x1239dfa0, DLP_FSADeinit_patch)); | ||
section_write_word(ios_elf_start, 0x1239dfc0, ARM_BL(0x1239dfc0, DLP_FSADeinit_patch)); | ||
section_write_word(ios_elf_start, 0x1239dfd8, ARM_BL(0x1239dfd8, DLP_FSADeinit_patch)); | ||
section_write_word(ios_elf_start, 0x1239dfec, ARM_BL(0x1239dfec, DLP_FSADeinit_patch)); | ||
section_write_word(ios_elf_start, 0x1239e020, ARM_BL(0x1239e020, DLP_FSADeinit_patch)); | ||
section_write_word(ios_elf_start, 0x1239e094, ARM_BL(0x1239e094, DLP_FSADeinit_patch)); | ||
section_write_word(ios_elf_start, 0x123a457c, ARM_BL(0x123a457c, DLP_FSADeinit_patch)); | ||
|
||
// DLP debug: | ||
/* | ||
section_write_word(ios_elf_start, 0x123a449c, ARM_BL(0x123a449c, DLP_FSA_OpenFile)); | ||
section_write_word(ios_elf_start, 0x1239ce08, ARM_BL(0x1239ce08, DLP_FSA_OpenFile)); | ||
section_write_word(ios_elf_start, 0x1239cf68, ARM_BL(0x1239cf68, DLP_FSA_OpenFile)); | ||
section_write_word(ios_elf_start, 0x1239defc, ARM_BL(0x1239defc, DLP_FSA_OpenFile)); | ||
section_write_word(ios_elf_start, 0x1239debc, ARM_BL(0x1239debc, DLP_GetChildTitleId)); | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef _NET_PATCHES_H_ | ||
#define _NET_PATCHES_H_ | ||
|
||
#include "types.h" | ||
|
||
u32 net_get_phys_code_base(void); | ||
|
||
void net_run_patches(u32 ios_elf_start); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#------------------------------------------------------------------------------- | ||
|
||
ifeq ($(strip $(DEVKITPRO)),) | ||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") | ||
endif | ||
|
||
TOPDIR ?= $(CURDIR) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# iosu_rules | ||
#--------------------------------------------------------------------------------- | ||
ifeq ($(strip $(DEVKITARM)),) | ||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>/devkitARM") | ||
endif | ||
|
||
include $(DEVKITARM)/base_rules | ||
export OBJDUMP := $(PREFIX)objdump | ||
|
||
MACHDEP = -DSTARBUCK -mbig-endian -mcpu=arm926ej-s -msoft-float -mfloat-abi=soft | ||
|
||
%.elf: | ||
@echo linking ... $(notdir $@) | ||
$(SILENTCMD)$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ | ||
#--------------------------------------------------------------------------------- | ||
|
||
#--------------------------------------------------------------------------------- | ||
# TARGET is the name of the output | ||
# SOURCES is a list of directories containing source code | ||
# DATA is a list of directories containing data files | ||
# INCLUDES is a list of directories containing header files | ||
#--------------------------------------------------------------------------------- | ||
TARGET := $(notdir $(CURDIR)) | ||
BUILD := build | ||
SOURCES := source | ||
DATA := data | ||
INCLUDES := source | ||
|
||
#--------------------------------------------------------------------------------- | ||
# options for code generation | ||
#--------------------------------------------------------------------------------- | ||
CFLAGS := -Wall -std=gnu11 -Os $(MACHDEP) $(INCLUDE) -Wno-array-bounds -fno-builtin | ||
|
||
ASFLAGS := $(MACHDEP) | ||
|
||
LDFLAGS := -nostartfiles -nodefaultlibs -mbig-endian \ | ||
-Wl,-L $(TOPDIR) -Wl,-Map,$(notdir $*.map),-T $(TOPDIR)/link.ld | ||
|
||
LIBS := -lgcc | ||
|
||
#------------------------------------------------------------------------------- | ||
# list of directories containing libraries, this must be the top level | ||
# containing include and lib | ||
#------------------------------------------------------------------------------- | ||
LIBDIRS := | ||
|
||
#--------------------------------------------------------------------------------- | ||
# no real need to edit anything past this point unless you need to add additional | ||
# rules for different file extensions | ||
#--------------------------------------------------------------------------------- | ||
ifneq ($(BUILD),$(notdir $(CURDIR))) | ||
#--------------------------------------------------------------------------------- | ||
|
||
export TARGETNAME := $(TARGET) | ||
|
||
export OUTPUT := $(CURDIR)/$(TARGET) | ||
export TOPDIR := $(CURDIR) | ||
|
||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) | ||
|
||
export DEPSDIR := $(CURDIR)/$(BUILD) | ||
|
||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) | ||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) | ||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) | ||
|
||
export LD := $(CC) | ||
|
||
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) | ||
export OFILES_SRC := $(SFILES:.s=.o) $(CFILES:.c=.o) | ||
export OFILES := $(OFILES_BIN) $(OFILES_SRC) | ||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) | ||
|
||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | ||
-I$(CURDIR)/$(BUILD) | ||
|
||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||
|
||
.PHONY: $(BUILD) clean all | ||
#--------------------------------------------------------------------------------- | ||
all: $(BUILD) | ||
|
||
$(BUILD): | ||
@[ -d $@ ] || mkdir -p $@ | ||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||
|
||
#--------------------------------------------------------------------------------- | ||
clean: | ||
@echo clean ... | ||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).bin $(TARGET).bin.h $(TARGET)_syms.h | ||
|
||
#--------------------------------------------------------------------------------- | ||
else | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# main targets | ||
#--------------------------------------------------------------------------------- | ||
all : $(OUTPUT).bin.h $(OUTPUT)_syms.h | ||
|
||
$(OUTPUT).elf : $(OFILES) | ||
|
||
$(OUTPUT).bin: $(OUTPUT).elf | ||
@echo "built ... $(notdir $@)" | ||
@$(OBJCOPY) -j .text -j .rodata -j .data -O binary $(OUTPUT).elf $@ | ||
|
||
$(OUTPUT).bin.h: $(OUTPUT).bin | ||
@raw2c $< | ||
@cp $(TARGETNAME).c $@ | ||
|
||
$(OUTPUT)_syms.h: $(OUTPUT).elf | ||
@echo "#ifndef $(TARGETNAME)_SYMS_H" > $@ | ||
@echo "#define $(TARGETNAME)_SYMS_H" >> $@ | ||
@$(OBJDUMP) -EB -t -marm $(OUTPUT).elf | grep 'g F .text' | grep -v '.hidden' | awk '{print "#define " $$6 " 0x" $$1}' >> $@ | ||
@$(OBJDUMP) -EB -t -marm $(OUTPUT).elf | grep -e 'g .text' -e '_bss_' | awk '{print "#define " $$5 " 0x" $$1}' >> $@ | ||
@echo "#endif" >> $@ | ||
|
||
$(OFILES_SRC) : $(HFILES_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) | ||
|
||
#--------------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------------- |
Oops, something went wrong.