Skip to content

Commit

Permalink
JAP support!
Browse files Browse the repository at this point in the history
  • Loading branch information
plutoo committed Jun 10, 2016
1 parent b9b2c77 commit 4fa1628
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
.PHONY: all eur usa

################################################################################
all: new_eur old_eur new_usa old_usa
all: new_eur old_eur new_usa old_usa new_jap old_jap
new_eur: build/new_eur/exploit/DCIM/100NIN03/HNI_0001.JPG build/new_eur/exploit/freaky.bin
old_eur: build/old_eur/exploit/DCIM/100NIN03/HNI_0001.JPG build/old_eur/exploit/freaky.bin
new_usa: build/new_usa/exploit/DCIM/100NIN03/HNI_0001.JPG build/new_usa/exploit/freaky.bin
old_usa: build/old_usa/exploit/DCIM/100NIN03/HNI_0001.JPG build/old_usa/exploit/freaky.bin
new_jap: build/new_jap/exploit/DCIM/100NIN03/HNI_0001.JPG build/new_jap/exploit/freaky.bin
old_jap: build/old_jap/exploit/DCIM/100NIN03/HNI_0001.JPG build/old_jap/exploit/freaky.bin
clean:
rm -rf build/

Expand All @@ -14,6 +16,8 @@ build/new_eur/stage0.elf: DEFINES := -DEUR -DNEW3DS
build/old_eur/stage0.elf: DEFINES := -DEUR
build/new_usa/stage0.elf: DEFINES := -DUSA -DNEW3DS
build/old_usa/stage0.elf: DEFINES := -DUSA
build/new_jap/stage0.elf: DEFINES := -DJAP -DNEW3DS
build/old_jap/stage0.elf: DEFINES := -DJAP

build/%/stage0.elf: src/stage0.s
mkdir -p $(dir $@)
Expand All @@ -36,6 +40,8 @@ build/new_eur/stage1.elf: DEFINES := -DEUR -DNEW3DS
build/old_eur/stage1.elf: DEFINES := -DEUR
build/new_usa/stage1.elf: DEFINES := -DUSA -DNEW3DS
build/old_usa/stage1.elf: DEFINES := -DUSA
build/new_jap/stage1.elf: DEFINES := -DJAP -DNEW3DS
build/old_jap/stage1.elf: DEFINES := -DJAP

build/%/stage1.elf: src/stage1.s
mkdir -p $(dir $@)
Expand All @@ -49,6 +55,8 @@ build/new_eur/stage2.elf: DEFINES := -DEUR -DNEW3DS
build/old_eur/stage2.elf: DEFINES := -DEUR
build/new_usa/stage2.elf: DEFINES := -DUSA -DNEW3DS
build/old_usa/stage2.elf: DEFINES := -DUSA
build/new_jap/stage2.elf: DEFINES := -DJAP -DNEW3DS
build/old_jap/stage2.elf: DEFINES := -DJAP

build/%/stage2.elf: src/stage2.s
mkdir -p $(dir $@)
Expand Down
43 changes: 21 additions & 22 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
/* plutoo 2016 */
#include "macros.h"

REGION_CONST(QR_BUF_ADDR, 0x081428E8, 0x08140CA8);
REGION_CONST(QR_BUF_ADDR, 0x081428E8, 0x08140CA8, 0x0813F008);

/* Rop gadgets. */
REGION_CONST(GADGET_LDR_R7_R0_4__LDR_R0_R7__LDR_R1_R0__BLX_R1, 0x00305160, 0x00305AA4);
REGION_CONST(GADGET_ADD_SP_R7_0x64__POP_R4R5R6R7PC, 0x003A5978, 0x003A6BA4);
REGION_CONST(GADGET_LDRD_R0_R0__STRD_R0_R7__POP_R4R5R6R7R8PC, 0x00207C5C, 0x0020817C);
REGION_CONST(GADGET_R0, 0x0012D484, 0x00129AE8);
REGION_CONST(GADGET_R1, 0x002812D4, 0x002818C4);
REGION_CONST(GADGET_R1R2R3R4R5, 0x0012BD08, 0x0012A890);
REGION_CONST(GADGET_ADD_SP_R3__POP_PC, 0x0012C988, 0x0012CA14);
REGION_CONST(SVC_SLEEP_THREAD_GADGET, 0x0028DE38, 0x0028E428);
REGION_CONST(GSP_ENQUEUE_CMD_GADGET, 0x001169C4, 0x00116A34);
REGION_CONST(GADGET_LDR_R7_R0_4__LDR_R0_R7__LDR_R1_R0__BLX_R1, 0x00305160, 0x00305AA4, 0x00304D70);
REGION_CONST(GADGET_ADD_SP_R7_0x64__POP_R4R5R6R7PC, 0x003A5978, 0x003A6BA4, 0x003A5DD0);
REGION_CONST(GADGET_LDRD_R0_R0__STRD_R0_R7__POP_R4R5R6R7R8PC, 0x00207C5C, 0x0020817C, 0x002079D8);
REGION_CONST(GADGET_R0, 0x0012D484, 0x00129AE8, 0x00129A68);
REGION_CONST(GADGET_R1, 0x002812D4, 0x002818C4, 0x00280ED4);
REGION_CONST(GADGET_R1R2R3R4R5, 0x0012BD08, 0x0012A890, 0x0012A810);
REGION_CONST(GADGET_ADD_SP_R3__POP_PC, 0x0012C988, 0x0012CA14, 0x0012C978);
REGION_CONST(SVC_SLEEP_THREAD_GADGET, 0x0028DE38, 0x0028E428, 0x0028DA38);
REGION_CONST(GSP_ENQUEUE_CMD_GADGET, 0x001169C4, 0x00116A34, 0x001169B4);

/* FS functions. */
REGION_CONST(FS_MOUNT_SDMC, 0x002CCCF8, 0x002CDA28);
REGION_CONST(FS_OPEN_FILE, 0x0028CC30, 0x0028D220);
REGION_CONST(FS_READ_FILE, 0x00115A90, 0x00115B00);
REGION_CONST(FS_MOUNT_SDMC, 0x002CCCF8, 0x002CDA28, 0x002CCA34);
REGION_CONST(FS_OPEN_FILE, 0x0028CC30, 0x0028D220, 0x0028C830);
REGION_CONST(FS_READ_FILE, 0x00115A90, 0x00115B00, 0x00115A80);

/* GSP functions. */
REGION_CONST(GSP_FLUSH_DATA_CACHE, 0x00116AB8, 0x00116B28);
REGION_CONST(GSP_ENQUEUE_CMD, 0x00285994, 0x00285F84);
REGION_CONST(GSP_GX_CMD4, 0x00116BB8, 0x00116C28);
REGION_CONST(GSP_GET_HANDLE, 0x0028A8F8, 0x0028AEE8);
REGION_CONST(GSP_GET_INTERRUPTRECEIVER, 0x00287F94, 0x00288584);
REGION_CONST(GSP_WRITE_HW_REGS, 0x00110080, 0x001100F0);
REGION_CONST(GSP_THREAD_OBJ_PTR, 0x00594C40, 0x0051FC40);
REGION_CONST(GSP_FLUSH_DATA_CACHE, 0x00116AB8, 0x00116B28, 0x00116AA8);
REGION_CONST(GSP_ENQUEUE_CMD, 0x00285994, 0x00285F84, 0x00285594);
REGION_CONST(GSP_GX_CMD4, 0x00116BB8, 0x00116C28, 0x00116BA8);
REGION_CONST(GSP_GET_HANDLE, 0x0028A8F8, 0x0028AEE8, 0x0028A4F8);
REGION_CONST(GSP_GET_INTERRUPTRECEIVER, 0x00287F94, 0x00288584, 0x00287B94);
REGION_CONST(GSP_WRITE_HW_REGS, 0x00110080, 0x001100F0, 0x00110070);
REGION_CONST(GSP_THREAD_OBJ_PTR, 0x00594C40, 0x0051FC40, 0x00480C40);

/* We will overwrite the padding at end of the last code page. This guarantees
that we don't overwrite existing code, and also avoids potential issues
with the instruction cache. */
REGION_CONST(STAGE2_CODE_VA, 0x003AE800, 0x003AF200);
REGION_CONST(STAGE2_CODE_VA, 0x003AE800, 0x003AF200, 0x003AE400);
GLOBAL_CONST(STAGE2_CODE_PA, CODE_VA_TO_PA(STAGE2_CODE_VA));
GLOBAL_CONST(STAGE2_SIZE, 0x800); // European game limits this size.

Expand All @@ -44,4 +44,3 @@ GLOBAL_CONST(OTHERAPP_CODE_VA, 0x00101000);
GLOBAL_CONST(OTHERAPP_CODE_PA, CODE_VA_TO_PA(OTHERAPP_CODE_VA));
GLOBAL_CONST(OTHERAPP_ADDR, 0x142C0000);
GLOBAL_CONST(OTHERAPP_SIZE, 0xC000);

18 changes: 12 additions & 6 deletions src/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
#define GARBAGE 0xDEADC0DE

#if defined(EUR)
#define REGION_CONST(name, eur, usa) .set name, eur
#define REGION_CONST(name, eur, usa, jap) .set name, eur
#elif defined(USA)
#define REGION_CONST(name, eur, usa) .set name, usa
#define REGION_CONST(name, eur, usa, jap) .set name, usa
#elif defined(JAP)
#define REGION_CONST(name, eur, usa, jap) .set name, jap
#else
/* I didn't buy the japanese game. :( */
#error "moshi moshi"
#error "wat"
#endif

#define GLOBAL_CONST(name, val) .set name, val

#define PA_TO_GPU_ADDR(pa) ((pa) - 0x0C000000)
#define GPU_TO_PA_ADDR(pa) ((pa) + 0x0C000000)

/* Apparently JAP code is a bit smaller than the other ones, making code.bin
being allocated at a slightly different address. */
REGION_CONST(NEW_VA_TO_PA, 0x27700000, 0x27700000, 0x27800000);
REGION_CONST(OLD_VA_TO_PA, 0x23B00000, 0x23B00000, 0x23C00000);

#if defined(NEW3DS)
#define CODE_VA_TO_PA(va) ((va) + 0x27700000)
#define CODE_VA_TO_PA(va) ((va) + NEW_VA_TO_PA)
#else
#define CODE_VA_TO_PA(va) ((va) + 0x23B00000)
#define CODE_VA_TO_PA(va) ((va) + OLD_VA_TO_PA)
#endif

0 comments on commit 4fa1628

Please # to comment.