-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7073ee0
Showing
31 changed files
with
5,391 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
KEY_DEFINES = -DMECHA_PATCH_KEY=$(MECHA_PATCH_KEY) -DGLOBAL_FLAGS_KEY=$(GLOBAL_FLAGS_KEY) | ||
|
||
PATCHES = patch-irq-hook patch-cdprotect-hook | ||
PATCHES_UNFIXED = $(foreach obj,$(PATCHES),bin/$(obj).unfixed.bin) | ||
PATCHES_FIXED = $(foreach obj,$(PATCHES),bin/$(obj).fixed.bin) | ||
PATCHES_DECRYPTED = $(foreach obj,$(PATCHES),bin/$(obj).decrypted.bin) | ||
PAYLOADS = bin/payload-fastdump.bin bin/payload-writenvm.bin bin/payload-keystoredump.bin | ||
|
||
# Make subcommands so we can repeat them between clean and all more easily. | ||
MAKECMD_MECHADUMP = $(MAKE) TOOL_PREFIX=$(EE_PREFIX) OUT_DIR=../out LIB_DIR=../mechacrypto/lib-ee \ | ||
INCLUDE_DIR=../mechacrypto PATCH_DIR=../bin DEFINES="$(KEY_DEFINES)" -C mechadump | ||
MAKECMD_MECHAPATCHTOOL = $(MAKE) TOOL_PREFIX=$(HOST_PREFIX) OUT_DIR=../bin BIN_DIR=bin-host \ | ||
LIB_DIR=../mechacrypto/lib-host INCLUDE_DIR=../mechacrypto DEFINES="$(KEY_DEFINES)" -C mechapatchtool | ||
MAKECMD_MECHACRYPTO_HOST = $(MAKE) TOOL_PREFIX=$(HOST_PREFIX) OUT_DIR=lib-host BIN_DIR=bin-host \ | ||
-C mechacrypto | ||
MAKECMD_MECHACRYPTO_EE = $(MAKE) TOOL_PREFIX=$(EE_PREFIX) OUT_DIR=lib-ee BIN_DIR=bin-ee -C mechacrypto | ||
MAKECMD_PATCH = $(MAKE) TOOL_PREFIX=$(ARM_PREFIX) OUT_DIR=../bin BIN_DIR=bin-arm -C patch | ||
MAKECMD_PAYLOAD = $(MAKE) TOOL_PREFIX=$(ARM_PREFIX) OUT_DIR=../bin BIN_DIR=bin-arm -C payload | ||
|
||
|
||
.PHONY: all clean debugdata mechadump mechapatchtool libmechacrypto-host libmechacrypto-ee | ||
|
||
all: mechadump libmechacrypto-ee debugdata | ||
|
||
clean: | ||
rm -f bin/mechapatchtool bin/*.bin | ||
$(MAKECMD_MECHADUMP) clean | ||
$(MAKECMD_MECHAPATCHTOOL) clean | ||
$(MAKECMD_MECHACRYPTO_HOST) clean | ||
$(MAKECMD_MECHACRYPTO_EE) clean | ||
$(MAKECMD_PATCH) clean | ||
$(MAKECMD_PAYLOAD) clean | ||
|
||
bin: | ||
mkdir bin | ||
out: | ||
mkdir out | ||
|
||
debugdata: $(PATCHES_DECRYPTED) | ||
|
||
mechadump: $(PATCHES_FIXED) $(PAYLOADS) libmechacrypto-ee | bin out | ||
$(MAKECMD_MECHADUMP) | ||
|
||
$(PATCHES_DECRYPTED): %.decrypted.bin: %.fixed.bin | bin mechapatchtool | ||
bin/mechapatchtool --decrypt --in="$^" --out="$@" | ||
$(PATCHES_FIXED): %.fixed.bin: %.unfixed.bin | bin mechapatchtool | ||
bin/mechapatchtool --fixup --in="$^" --out="$@" | ||
$(PATCHES_UNFIXED): | bin | ||
$(MAKECMD_PATCH) | ||
|
||
$(PAYLOADS): | ||
$(MAKECMD_PAYLOAD) | ||
|
||
mechapatchtool: libmechacrypto-host | bin | ||
$(MAKECMD_MECHAPATCHTOOL) | ||
|
||
libmechacrypto-host: | ||
$(MAKECMD_MECHACRYPTO_HOST) | ||
libmechacrypto-ee: | ||
$(MAKECMD_MECHACRYPTO_EE) |
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,42 @@ | ||
BIN_DIR = bin$(OUT_SUFFIX) | ||
ifndef OUT_DIR | ||
OUT_DIR = $(BIN_DIR) | ||
endif | ||
|
||
C_OBJECTS = cipher.o crc32.o util.o | ||
TARGET_C_OBJECTS = $(foreach obj,$(C_OBJECTS),$(BIN_DIR)/$(obj)) | ||
|
||
LIBRARY = $(OUT_DIR)/libmechacrypto$(OUT_SUFFIX).a | ||
|
||
CC = $(TOOL_PREFIX)gcc | ||
CXX = $(TOOL_PREFIX)g++ | ||
AR = $(TOOL_PREFIX)ar | ||
|
||
BASEFLAGS = -O2 -Wall | ||
CCFLAGS = $(BASEFLAGS) -std=c11 | ||
CXXFLAGS = $(BASEFLAGS) -std=c++14 | ||
|
||
.PHONY: all clean headers | ||
|
||
all: $(BIN_DIR) $(OUT_DIR) $(LIBRARY) | ||
|
||
clean: | ||
rm -f $(BIN_DIR)/*.o $(BIN_DIR)/*.a $(LIBRARY) | ||
|
||
$(BIN_DIR): | ||
mkdir $@ | ||
$(OUT_DIR): | ||
mkdir $@ | ||
|
||
$(LIBRARY): $(TARGET_C_OBJECTS) | $(OUT_DIR) | ||
rm -f $@ | ||
$(AR) -crs $@ $^ | ||
|
||
# Will need to fix... | ||
#$(TARGET_C_OBJECTS): $(BIN_DIR)/%.o: %.cpp | ||
# $(CXX) $(CXXFLAGS) -c $^ -o $@ | ||
|
||
$(TARGET_C_OBJECTS): $(BIN_DIR)/%.o: %.c | $(BIN_DIR) headers | ||
$(CC) $(CCFLAGS) -c $^ -o $@ | ||
|
||
headers: *.h |
Oops, something went wrong.