$(call rwildcard, $(dir_source), *.s *.c)))
.PHONY: all
-all: a9lh modules external
+all: a9lh external
.PHONY: full
full: host/langemu.conf all
-.PHONY: modules
-modules:
- make -C modules
-
.PHONY: external
external:
make -C external
.PHONY: a9lh
a9lh: $(dir_out)/arm9loaderhax.bin
- echo "Generating symbol table"
- ./host/symtab.sh > modules/template/src/symtab.h
.PHONY: reformat
reformat:
.PHONY: clean
clean:
rm -f host/langemu.conf
- make -C modules clean
make -C external clean
rm -rf $(dir_out) $(dir_build)
+++ /dev/null
-.PHONY: all copyout
-all: template
- mkdir -p ../out/corbenik/bin
- cp template/out/patch.vco ../out/corbenik/bin/example.vco
-
-.PHONY: clean
-clean: clean_template
- rm -rf ../out/corbenik/bin
-
-.PHONY: template
-template:
- make -C template
-
-.PHONY: clean_template
-clean_template:
- make -C template clean
+++ /dev/null
-Corbenik patch binaries
-----------------------------------
-
-This directory contains the source for vco files - the patcher executables.
-
-You're probably wondering what the heck corbenik does differently from cakes,
-considering it seems similar in many ways.
-
-Patches are actually code for whatever processor they're intended to run on,
-be it ARM9 or ARM11. They're loaded to a static offset in memory, and executed
-from there with relocations to corbenik's internal functions. This keeps patches
-relatively small, and allows complete control over behavior.
-
-Patches should have a declaration of this sort somewhere in them:
- { 0xc0, 0x9b, 0xe5, 0x1c }
-Followed by a table large enough to fill with all usable functions.
-
-The loader is subject to change at any moment's notice; the ABI is not yet
-stable. It may become an ELF loader at some point. I don't know.
-
-You may want to consult src/loader.c to see what functions are exported, or
-simply base your code on the generic example in the 'template' folder instead.
-
-There's some key differences here, obviously, from running just arm9loader code. Namely:
-
- 1) Patches must not clobber the previous state. Meaning; start does nothing but
- chain to main.
-
- 2) Patches must properly return, and also return a value. Return code 0 is
- success; keep this in mind. Corbenik will attempt to reset after a non-
- zero return code. If you don't know how to return; you're looking for
- 'bx lr'.
-
- 3) Patches must have a symbol table with the appropriate magic.
- No symbol table? No load. This might be relaxed in future versions
- to allow patches to be marked static, but IDK.
-
- 4) Don't code a patch that does too fancy stuff. Patches are not intended to
- be 65k binaries. Seriously.
-
- 5) _start must be at offset 0x24400000. This is where you are in memory.
-
-You can implement shit yourself, but it's an utter waste of memory. Try to use
-the linker exports unless you have a good reason not to.
+++ /dev/null
-rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
-
-PATH := $(PATH):$(DEVKITARM)/bin
-
-HOST_CC := gcc
-
-CC := arm-none-eabi-gcc
-AS := arm-none-eabi-as
-LD := arm-none-eabi-ld
-OC := arm-none-eabi-objcopy
-
-dir_source := src
-dir_build := build
-dir_out := out
-
-ASFLAGS := -mlittle-endian -mcpu=arm946e-s -march=armv5te
-CFLAGS := -MMD -MP -Wall -Wextra -Werror -Os -fno-omit-frame-pointer $(ASFLAGS) -fno-builtin -std=c11
-FLAGS := dir_out=$(abspath $(dir_out)) --no-print-directory
-LDFLAGS := -nostdlib -Wl,-z,defs -lgcc
-
-objects_cfw = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
- $(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
- $(call rwildcard, $(dir_source), *.s *.c)))
-
-.PHONY: all
-all: patchbin
-
-.PHONY: patchbin
-patchbin: tool $(dir_out)/patch.bin
- ./compile_header
-
-.PHONY: tool
-tool:
- $(HOST_CC) -o compile_header ../../host/compile_header.c
-
-
-.PHONY: clean
-clean:
- rm -rf $(dir_out) $(dir_build) compile_header
-
-.PHONY: $(dir_out)/patch.bin
-$(dir_out)/patch.bin: $(dir_build)/main.bin
- @mkdir -p "$(dir_out)"
- @cp -av $< $@
-
-$(dir_build)/main.bin: $(dir_build)/main.elf
- $(OC) -S -O binary $< $@
-
-$(dir_build)/main.elf: $(objects_cfw)
- $(CC) -T linker.ld $(OUTPUT_OPTION) $^ $(LDFLAGS)
-
-$(dir_build)/%.o: $(dir_source)/%.c
- @mkdir -p "$(@D)"
- $(COMPILE.c) $(OUTPUT_OPTION) $<
-
-$(dir_build)/%.o: $(dir_source)/%.s
- @mkdir -p "$(@D)"
- $(COMPILE.s) $(OUTPUT_OPTION) $<
-
-include $(call rwildcard, $(dir_build), *.d)
+++ /dev/null
-ENTRY(main)
-SECTIONS
-{
- . = 0x24400000;
-
- START_SECTION = .;
- .text.start : {
- *(.text.start)
- }
- START_SECTION_END = .;
-
- TEXT_SECTION = .;
- .text : {
- *(.text)
- }
- TEXT_SECTION_END = .;
-
- DATA_SECTION = .;
- .data : {
- *(.data)
- }
- DATA_SECTION_END = .;
-
- BSS_SECTION = .;
- .bss : {
- *(.bss COMMON)
- }
- BSS_SECTION_END = .;
-
- RODATA_SECTION = .;
- .rodata : {
- *(.rodata)
- }
- RODATA_SECTION_END = .;
-
- . = ALIGN(4);
-}
+++ /dev/null
-Prints "Hello World!"
+++ /dev/null
-Example Patch
+++ /dev/null
-#ifndef EXPORTED_H
-#define EXPORTED_H
-
-#include "symtab.h"
-
-#include "headers.h"
-
-#define stdout ((void*)0)
-#define stderr ((void*)2)
-
-int (*strlen)(const char *string) = strlen_offset;
-int (*isprint)(char c) = isprint_offset;
-void (*memcpy)(void *dest, const void *src, size_t size) = memcpy_offset;
-void (*memmove)(void *dest, const void *src, size_t size) = memmove_offset;
-void (*memset)(void *dest, const int filler, size_t size) = memset_offset;
-int (*memcmp)(const void *buf1, const void *buf2, const size_t size) = memcmp_offset;
-void (*strncpy)(void *dest, const void *src, const size_t size) = strncpy_offset;
-int (*strncmp)(const void *buf1, const void *buf2, const size_t size) = strncmp_offset;
-int (*atoi)(const char *str) = atoi_offset;
-uint8_t* (*memfind)(uint8_t *string, uint32_t stringlen, uint8_t *pat, uint32_t patlen) = memfind_offset;
-
-void (*putc)(void* buf, const int c) = putc_offset;
-void (*puts)(void* buf, const char *string) = puts_offset;
-void (*fprintf)(void* channel, const char* format, ...) = fprintf_offset;
-
-exefs_h* (*get_firm_proc9_exefs)() = get_firm_proc9_exefs_offset;
-exefs_h* (*get_agb_proc9_exefs)() = get_agb_proc9_exefs_offset;
-exefs_h* (*get_twl_proc9_exefs)() = get_twl_proc9_exefs_offset;
-
-#endif
+++ /dev/null
-../../../source/firm/headers.h
\ No newline at end of file
+++ /dev/null
-#include <stdint.h>
-#include <stddef.h>
-#include "exported.h"
-
-int main() {
- fprintf(stderr, "Hi!\n");
-
- return 0;
-}
#define FCRAM_START 0x24000000
// firm.c
+// 24
#define FCRAM_FIRM_LOC FCRAM_START
+// 241
#define FCRAM_TWL_FIRM_LOC (FCRAM_START + FCRAM_SPACING) // Double size
+// 242
#define FCRAM_AGB_FIRM_LOC (FCRAM_START + FCRAM_SPACING * 3)
+// 243
// patch.c
#define FCRAM_PATCHBIN_EXEC_LOC (FCRAM_START + FCRAM_SPACING * 4)
+// 244
// Throwaway temporary space. Don't expect it to stay sane.
#define FCRAM_JUNK_LOCATION (FCRAM_START + FCRAM_SPACING * 5)
int
patch_firm_all()
{
- // FIXME - Linker is bork at the moment.
- execp(PATH_PATCHES "/example.vco");
-
- // wait();
-
// Use builtin signature patcher?
if (config.options[OPTION_SIGPATCH]) {