*.vco
input
host/copy.sh
+Makefile.in
+aclocal.m4
+autom4te.cache/
+compile
+config.guess
+config.sub
+configure
+install-sh
+ltmain.sh
+missing
+.deps
+config.log
+config.status
+libtool
+.dirstamp
+depcomp
+/Makefile
+/source/Makefile
+/external/Makefile
+/source/corbenik
+/m4
+/include/config.h
+/include/stamp-h1
+++ /dev/null
-rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
-
-include common.mk
-
-objects_cfw = $(patsubst %.s, %.o, \
- $(patsubst %.c, %.o, \
- $(call rwildcard, $(dir_source), *.s *.c)))
-
-.PHONY: all
-all: hosttools font ctr9io a9lh patch external
-
-.PHONY: ctr9io
-ctr9io:
- cd external/libctr9 && autoreconf -fi && CFLAGS= LDFLAGS= ASFLAGS= ./configure --host arm-none-eabi --prefix=$(shell pwd)/external/libctr9/out && make && make install
-
-.PHONY: release
-release:
- rm -rf rel
- mkdir -p rel
- make clean
- make CHAINLOADER=0 REL=$(REL) full
- mv out/release.zip rel/release-nochain.zip
- cat out/release.zip.sha512 | sed 's/release.zip/release-nochain.zip/' > rel/release-nochain.zip.sha512
- make clean
- make CHAINLOADER=1 REL=$(REL) full
- mv out/release.zip out/release.zip.sha512 rel/
-
-.PHONY: hosttools
-hosttools:
- make -C host/bdfe dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root)
-
-.PHONY: font
-font: hosttools
- make -C host/bdfe
- mkdir -p $(dir_out)/$(fw_folder)/bits
- ./host/bdfe/bdfe -A -n external/tewi-font/tewi-medium-11.bdf > $(dir_out)/$(fw_folder)/bits/termfont.bin
-
-.PHONY: full
-full: all contrib $(dir_out)/$(fw_folder)/locale
- cp README.md LICENSE.txt $(dir_out)/
- cd out && zip -r9 release.zip *
- cd out && sha512sum -b release.zip > release.zip.sha512 # Security.
-
-.PHONY: contrib
-contrib:
- make -C contrib dir_out=$(dir_out) fw_name=$(fw_name) fw_folder=$(fw_folder) root=$(root)
-
-.PHONY: external
-external:
- make -C external dir_out=$(dir_out) fw_name=$(fw_name) fw_folder=$(fw_folder) CHAINLOADER=$(CHAINLOADER) root=$(root)
-
-.PHONY: patch
-patch:
- make -C patch dir_out=$(dir_out) fw_name=$(fw_name) fw_folder=$(fw_folder) root=$(root)
-
-.PHONY: a9lh
-a9lh: $(dir_out)/main.bin
- mkdir -p $(dir_out)/$(fw_folder)/bits
-
-.PHONY: reformat
-reformat:
- clang-format -i $(dir_source)/*.{c,h} $(dir_source)/*/*.{c,h} external/loader/source/*.{c,h}
-
-$(dir_out)/$(fw_folder)/locale: all
- echo "Generating langemu data from 3dsdb - may take a bit"
- cd out/$(fw_folder) && ../../host/generate_langemu_conf.sh
-
-.PHONY: clean
-clean:
- rm -f $(objects_cfw)
- cd external/libctr9 && git clean -fxd
- make -C external dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root) clean
- make -C patch dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root) clean
- make -C host/bdfe dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root) clean
- rm -rf $(dir_out) $(dir_build)
-
-out/main.bin: out/main.elf
- $(OC) $(OCFLAGS) -S -O binary $< $@
-
-out/main.elf: $(objects_cfw)
- $(CC) $(LDFLAGS) -T linker.ld -o $@ $<
-
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-%.o: %.s
- $(AS) $(ASFLAGS) -c -o $@ $<
-
-include $(call rwildcard, $(dir_build), *.d)
-include common.mk
+SUBDIRS = include host external source patch contrib
+ACLOCAL_AMFLAGS = -I m4
-corbenik_SOURCES = aes.c ctr_nand_crypto_interface.c ctr_sd_interface.c sha.c \
- ctr_io_interface.c ctr_nand_interface.c sdmmc/delay.s sdmmc/sdmmc.c i2c.c \
- ctr_rtc.c fatfs/diskio.c fatfs/ff.c fatfs/option/unicode.c ctr_system.c \
- ctr_fatfs_interface.c fatfs/ctr_fatfs_disk.c ctr_disks.c \
- fatfs/ctr_fatfs_disk.c ctr_fatfs.c ctr_interrupt.c ctr_system_ARM.c \
- ctr_interrupt_asm.s ctr_screen.c ctr_hid.c ctr_pxi.c gamecart/command_ctr.c\
- gamecart/command_ntr.c gamecart/protocol.c gamecart/protocol_ctr.c \
- gamecart/protocol_ntr.c ctr_cart_interface.c gamecart/delay.s ctr_headers.c \
- ctr_timer.c ctr_irq.c ctr_system_clock.c
+install:
+ @echo "Please don't call the install target directly, it doesn't work."
+ @exit 1
-
-includedirectory = include
-
-corbenik_HEADERS = $(includedirectory)/
+all-local:
+ mkdir -p out
+ mkdir -p out/@prefix@
+ mkdir -p out/@libdir@/{module,firmware}
+ mkdir -p out/@datarootdir@/{keys,locale/emu}
+ mkdir -p out/@bindir@
+ mkdir -p out/@sbindir@
+ mkdir -p out/@prefix@/boot
+ mkdir -p out/@libexecdir@
+ mkdir -p out/@sysconfdir@
+ mkdir -p out/@localstatedir@
+ cp source/corbenik.bin out/arm9loaderhax.bin
+ cp source/corbenik.bin out/@prefix@/boot/
+ cp external/loader/loader.cxi out/@libdir@/module/loader.cxi
+ cp external/bits/*.bin out/@libexecdir@/
+ cp external/screeninit/build/screeninit.bin out/@libexecdir@/
+ cp host/termfont.bin out/@libexecdir@/
+ cp patch/*.vco out/@sbindir@
+ cp contrib/*.vco out/@bindir@
--- /dev/null
+#!/bin/sh
+mkdir -p m4
+autoreconf -fi
-INCPATHS=-I$(top_srcdir)/include
+INCPATHS=-I$(top_srcdir)/include -I$(top_srcdir)/external/libctr9/include
+
C9FLAGS=-mcpu=arm946e-s -march=armv5te -mlittle-endian -mword-relocations
SIZE_OPTIMIZATION = -Wl,--gc-sections -ffunction-sections
-CFLAGS= -std=gnu11 -O2 -g -fomit-frame-pointer -ffast-math \
+AM_CFLAGS= -std=gnu11 -O2 -g -fomit-frame-pointer -ffast-math \
-Wpedantic -Wall -Wextra -Wcast-align -Wcast-qual \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op \
-Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls \
-Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default \
-Wundef -Wno-unused $(THUMBFLAGS) $(SIZE_OPTIMIZATION) $(INCPATHS) $(C9FLAGS) \
- -I$(shell pwd)/external/libctr9/out/include -I$(shell pwd)/include -Os $(ASFLAGS) \
+ -Os $(ASFLAGS) \
-fshort-wchar -fno-builtin -std=gnu11 -DVERSION=\"$(REVISION)\" -DREL=\"$(REL)\" \
-DCHAINLOADER=$(CHAINLOADER) -DPATH_CFW=\"/$(fw_folder)\" -DFW_NAME=\"$(fw_name)\" \
$(PATHARGS)
-LDFLAGS=-Wl,--use-blx,--pic-veneer,-q -nostdlib -Wl,-z,defs -lgcc \
- -Wl,-Map,$(dir_out)/link.map -L$(shell pwd)/external/libctr9/out/lib -lctr9
+AM_LDFLAGS=-Wl,--use-blx,--pic-veneer,-q -nostdlib -Wl,-z,defs -lgcc \
+ -L$(top_srcdir)/external/libctr9/src
OCFLAGS=--set-section-flags .bss=alloc,load,contents
# Only cygwin is maybe working on windows.
PATH := $(PATH):$(DEVKITARM)/bin
-CC := arm-none-eabi-gcc
-AS := arm-none-eabi-as
-LD := arm-none-eabi-ld
-OC := arm-none-eabi-objcopy
-
-BUILD_CC ?= gcc
-BUILD_AS ?= as
-BUILD_LD ?= ld
-BUILD_OC ?= objcopy
-
fw_name ?= Corbenik
# If unset, the primary folder is /corbenik.
# cruel
root ?= clusterfuck
-ifeq "$(root)" "clusterfuck"
- PATHARGS := -DPATH_ROOT=\"\"
- PATHARGS += -DPATH_DATA=\"/$(fw_folder)\"
-else ifeq "$(root)" "cruel"
- PATHARGS := -DPATH_ROOT=\"/3ds/apps\"
- PATHARGS += -DPATH_DATA=\"/3ds/appdata/$(fw_folder)\"
-else ifeq "$(root)" "shadowhand"
- PATHARGS := -DPATH_ROOT=\"/homebrew/3ds\"
- PATHARGS += -DPATH_DATA=\"/homebrew/3ds/$(fw_folder)\"
-endif
-
-dir_source := source
-dir_data := data
-dir_build := build
-dir_out := out
+# ifeq "$(root)" "clusterfuck"
+# PATHARGS := -DPATH_ROOT=\"\"
+# PATHARGS += -DPATH_DATA=\"/$(fw_folder)\"
+# else ifeq "$(root)" "cruel"
+# PATHARGS := -DPATH_ROOT=\"/3ds/apps\"
+# PATHARGS += -DPATH_DATA=\"/3ds/appdata/$(fw_folder)\"
+# else ifeq "$(root)" "shadowhand"
+# PATHARGS := -DPATH_ROOT=\"/homebrew/3ds\"
+# PATHARGS += -DPATH_DATA=\"/homebrew/3ds/$(fw_folder)\"
+# endif
+
+# dir_source := source
+# dir_data := data
+# dir_build := build
+# dir_out := out
REVISION := $(shell git rev-parse HEAD | head -c10)+$(shell git rev-list --count HEAD)
REL ?= master
-AC_INIT([libctr9], [0.0.1], [], [])
+AC_INIT([corbenik], [0.1.2], [https://github.com/chaoskagami/corbenik], [])
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz subdir-objects])
-#Find AR and RANLIB for lto support before initializing libtool
+AC_CONFIG_MACRO_DIRS([m4])
+
+# Find AR and RANLIB for lto support before initializing libtool
AC_CHECK_TOOL([AR],gcc-ar)
AC_CHECK_TOOL([RANLIB],gcc-ranlib)
LT_INIT
+AC_PROG_SED
AC_PROG_CC
+AC_PROG_CXX
AM_PROG_AS
AC_CHECK_TOOL([OBJCOPY],objcopy)
-AC_CONFIG_FILES([Makefile src/Makefile test/Makefile examples/Makefile])
+AC_ARG_ENABLE([chainloader],
+ AS_HELP_STRING([--disable-chainloader], [Disable chainloading of external programs]))
+
+AC_PREFIX_DEFAULT([/corbenik])
+
+if ! "$enable_chainloader" == "no" ; then
+ CHAINLOADER=1
+else
+ CHAINLOADER=0
+fi
+
+AC_DEFINE([CHAINLOADER], [$CHAINLOADER])
+
+AC_CONFIG_FILES([Makefile source/Makefile external/Makefile include/Makefile])
+
+AC_CONFIG_SUBDIRS([external/libctr9])
+
+echo "
+Corbenik $VERSION
+========================
+Prefix: ${prefix}
+
+cc: ${CC}
+cxx: ${CXX}
+ld: ${LD}
+oc: ${OBJCOPY}
+
+sed: ${SED}
+
+cflags: ${CFLAGS}
+cxxflags: ${CXXFLAGS}
+ldflags: ${LDFLAGS}
+ocflags: ${OCFLAGS}
+
+Chainloader: ${CHAINLOADER}
+"
AC_OUTPUT
-out := ../$(dir_out)/$(fw_folder)
-
.PHONY: all
-all: build install
+all: build
.PHONY: build
build: clean $(patsubst %.pco, %.vco, $(wildcard *.pco))
.PHONY: install
-install: build
- mkdir -p $(out)/contrib
- cp *.vco README.md $(out)/contrib/
+install:
%.vco: %.pco
../host/bytecode_asm.py $< $@
+++ /dev/null
-out := ../$(dir_out)/$(fw_folder)
-
-.PHONY: all
-all: loader bits screeninit
- mkdir -p $(out)/module
- mkdir -p $(out)/bits
- cp loader/loader.cxi $(out)/module/loader.cxi
- cp bits/backdoor.bin $(out)/bits/backdoor.bin
- cp bits/emunand.bin $(out)/bits/emunand.bin
-ifeq "$(CHAINLOADER)" "1"
- cp bits/chain.bin $(out)/bits/chain.bin
-endif
- cp bits/reboot_hook.bin $(out)/bits/reboot_hook.bin
- cp bits/reboot_code.bin $(out)/bits/reboot_code.bin
- cp screeninit/build/screeninit.bin $(out)/bits/screeninit.bin
-
-.PHONY: clean
-clean: clean_loader clean_bits clean_screeninit
- rm -rf $(out)/bits
- rm -rf $(out)/module
-
-.PHONY: loader
-loader:
- make -C loader dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root)
-
-.PHONY: bits
-bits:
- make -C bits dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root)
-
-.PHONY: screeninit
-screeninit:
- make -C screeninit dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root)
-
-.PHONY: clean_loader
-clean_loader:
- make -C loader dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root) clean
-
-.PHONY: clean_bits
-clean_bits:
- make -C bits dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root) clean
-
-.PHONY: clean_screeninit
-screeninit_clean:
- make -C screeninit dir_out=$(dir_out) fw_folder=$(fw_folder) root=$(root) clean
--- /dev/null
+SUBDIRS = libctr9 loader bits screeninit
+
+install:
.PHONY: clean
clean:
rm -f *.bin *.elf *.o
+
+.PHONY: install
+install:
-fomit-frame-pointer -ffunction-sections -fdata-sections -fshort-wchar \
$(ARCH)
-CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DLOADER=1 -DPATH_CFW=\"/$(fw_folder)\" $(PATHARGS)
+CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DLOADER=1 -I../../../include $(PATHARGS)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu99
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
+
+.PHONY: install
+install:
#define PATH_MAX 255
#define _MAX_LFN 255
#endif
-#include "../../../source/config.h"
-#include "../../../source/patch_format.h"
+#include <option.h>
+#include <patch_format.h>
// Patches must consist of fewer bytes than this.
// 16K is reasonable, IMO, and doesn't cause issues.
#define PATH_MAX 255
#define _MAX_LFN 255
#endif
-#include "../../../source/config.h"
-#include "../../../source/patch_format.h"
+#include <option.h>
+#include <patch_format.h>
Handle log_file_hdl;
int logger_is_initd = 0;
#define PATH_MAX 255
#define _MAX_LFN 255
#endif
-#include "../../../source/config.h"
-#include "../../../source/patch_format.h"
-/*
-int
-memcmp(const void *buf1, const void *buf2, u32 size)
-{
- const u8 *buf1c = (const u8 *)buf1;
- const u8 *buf2c = (const u8 *)buf2;
-
- for (u32 i = 0; i < size; i++) {
- int cmp = buf1c[i] - buf2c[i];
- if (cmp)
- return cmp;
- }
-
- return 0;
-}
-*/
+#include <option.h>
+#include <patch_format.h>
// Quick Search algorithm, adapted from
// http://igm.univ-mlv.fr/~lecroq/string/node19.html#SECTION00190
#include "internal.h"
#include "memory.h"
#include "logger.h"
-#include "../../../source/patch_format.h"
-#include "../../../source/std/unused.h"
+#include <patch_format.h>
+#include <std/unused.h>
#include "interp.h"
#ifndef PATH_MAX
#define PATH_MAX 255
#define _MAX_LFN 255
#endif
-#include "../../../source/config.h"
+#include <option.h>
#define TEXT_PATH PATH_EXEFS_TEXT "/0000000000000000"
#define DATA_PATH PATH_EXEFS_DATA "/0000000000000000"
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
include $(call rwildcard, $(dir_build), *.d)
+
+.PHONY: install
+install:
#define INIT_PARAMS 1
#define INIT_DEINIT 2
-void main(void) {
+void __attribute__((naked)) main(void) {
// FIXME - We could use some serious macros here...
u32 do_init = *(vu32 *)0x24FFFC08;
*(vu32 *)0x10141200 = 0x1007F;
*(vu32 *)0x10202014 = 0x00000001;
*(vu32 *)0x1020200C &= 0xFFFEFFFE;
+ }
+
*(vu32 *)0x10202240 = brightnessLevel; // Alteration; directly read brightness.
*(vu32 *)0x10202A40 = brightnessLevel;
+
+ if (do_init == INIT_FULL) {
*(vu32 *)0x10202244 = 0x1023E;
*(vu32 *)0x10202A44 = 0x1023E;
+ }
// Top screen
*(vu32 *)0x10400400 = 0x000001c2;
*(vu32 *)0x10400540 = 0x01980194;
*(vu32 *)0x10400544 = 0x00000000;
*(vu32 *)0x10400548 = 0x00000011;
-
*(vu32 *)0x1040055C = 0x00f00140;
*(vu32 *)0x10400560 = 0x01c100d1;
*(vu32 *)0x10400564 = 0x01920052;
*((vu32 *)0x23FFFE00) = 0x18300000;
*((vu32 *)0x23FFFE04) = 0x18300000;
*((vu32 *)0x23FFFE08) = 0x18300000 + (yaw * 400);
- } else if (do_init == INIT_DEINIT) {
-
- }
//Clear ARM11 entry offset
*arm11 = 0;
--- /dev/null
+all: bdfe font
+
+bdfe_dir:
+ make -C bdfe
+
+font: bdfe_dir
+ ./bdfe/bdfe -n -A ../external/tewi-font/tewi-medium-11.bdf > termfont.bin
+
+clean:
+ make -C bdfe clean
+ rm -f termfont.bin
rm -rf $mnt/corbenik
cp -r out/* $mnt/ || exit 0
cp -r input/* $mnt/ || exit 0
-cp out/arm9loaderhax.bin $mnt/corbenik/chain/Corbenik || exit 0
-cp out/arm9loaderhax.bin $mnt/arm9loaderhax_si.bin || exit 0
-rm -f $mnt/arm9loaderhax.bin || exit 0
+cp out/arm9loaderhax.bin $mnt/corbenik/boot/Corbenik || exit 0
umount $mnt || exit 0
sync || exit 0
eject ${dev} || exit 0
--- /dev/null
+all-local:
+ ${SED} \
+ -e "s|%CHAINLOADER%|${CHAINLOADER}|g" \
+ -e "s|%PREFIX%|${prefix}|g" \
+ -e "s|%LOCALSTATEDIR%|${localstatedir}|g" \
+ -e "s|%BINDIR%|${bindir}|g" \
+ -e "s|%SBINDIR%|${sbindir}|g" \
+ -e "s|%LIBDIR%|${libdir}|g" \
+ -e "s|%LIBEXECDIR%|${libexecdir}|g" \
+ -e "s|%DATAROOTDIR%|${datarootdir}|g" \
+ -e "s|%SYSCONFDIR%|${sysconfdir}|g" \
+ -e "s|%PACKAGE%|${PACKAGE}|g" \
+ -e "s|%PACKAGE_VERSION%|${PACKAGE_VERSION}|g" \
+ config.h.in > config.h
#ifndef __COMMON_H
#define __COMMON_H
+#include <corbconf.h>
+
#include <std/unused.h>
#include <std/abort.h>
#include <screeninit.h>
#include <interrupt.h>
-#include <config.h>
+#include <option.h>
#include <input.h>
#include <interp.h>
#include <patcher.h>
--- /dev/null
+/* use chainloader code */
+#define CHAINLOADER %CHAINLOADER%
+
+/* CFW data dirs */
+#define PREFIX "%PREFIX%"
+
+#define LOCALSTATEDIR "%LOCALSTATEDIR%"
+#define BINDIR "%BINDIR%"
+#define SBINDIR "%SBINDIR%"
+#define LIBDIR "%LIBDIR%"
+#define LIBEXECDIR "%LIBEXECDIR%"
+#define SHAREDIR "%DATAROOTDIR%"
+#define SYSCONFDIR "%SYSCONFDIR%"
+
+#define LOCALEDIR SHAREDIR "/locale"
+
+/* Name of package */
+#define PACKAGE "%PACKAGE%"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "%VERSION%"
+
--- /dev/null
+#ifndef __CORBENIK_CONF
+#define __CORBENIK_CONF
+
+#include <config.h>
+
+#ifndef ROOT
+#define ROOT "/corbenik"
+#endif
+
+#ifndef DATA
+#define DATA ROOT
+#endif
+
+#endif
#ifndef __FIRM_H
+#define __FIRM_H
#include <stdint.h>
#ifndef __PATCH_FORMAT_H
#define __PATCH_FORMAT_H
+#include <corbconf.h>
+
// The following are titleids which are handled specially for one reason or
// another.
// We use titleIDs to be generic; it ensures that patches can share the same
#define PATCH_DISABLED (1 << 2) // Do not allow changing this patch's status. With PATCH_MANDATORY,
// this prevents disabling it.
-#ifndef PATH_ROOT
-#define PATH_ROOT "" // Root "storage" directory. Nothing by default (e.g. root clutter mode)
-#endif
-
-// You can redefine this in the Makefile, if you'd like.
-// Recommended names for being silly:
-// Windows
-// system
-
-//#ifndef PATH_CFW
-//#define PATH_CFW "/corbenik" // CFW root directory.
-//#endif
-
-//#ifndef PATH_DATA
-//#define PATH_DATA PATH_ROOT PATH_CFW // Data "storage" directory. Nothing by default (e.g. root clutter mode)
-//#endif
-
-#define PATH_MODULES PATH_ROOT PATH_CFW "/module" // Sysmodule location
-#define PATH_PATCHES PATH_ROOT PATH_CFW "/patch" // Patch binary folder.
+#define PATH_MODULES LIBDIR "/module" // Sysmodule location
+#define PATH_PATCHES SBINDIR // Patch binary folder.
-#define PATH_BITS PATH_ROOT PATH_CFW "/bits" // Path to misc bits we need (emunand code, reboot code, etc)
+#define PATH_BITS LIBEXECDIR // Path to misc bits we need (emunand code, reboot code, etc)
-#define PATH_EMUNAND_CODE PATH_BITS "/emunand.bin" // Emunand hook.
-#define PATH_SCREENINIT_CODE PATH_BITS "/screeninit.bin" // Screeninit code (ARM11)
-#define PATH_BACKDOOR PATH_BITS "/backdoor.bin" // svcBackdoor
-#define PATH_REBOOT_HOOK PATH_BITS "/reboot_hook.bin" // Reboot hook
-#define PATH_REBOOT_CODE PATH_BITS "/reboot_code.bin" // Reboot entry code
+#define PATH_EMUNAND_CODE PATH_BITS "/emunand.bin" // Emunand hook.
+#define PATH_SCREENINIT_CODE PATH_BITS "/screeninit.bin" // Screeninit code (ARM11)
+#define PATH_BACKDOOR PATH_BITS "/backdoor.bin" // svcBackdoor
+#define PATH_REBOOT_HOOK PATH_BITS "/reboot_hook.bin" // Reboot hook
+#define PATH_REBOOT_CODE PATH_BITS "/reboot_code.bin" // Reboot entry code
-#define PATH_CHAINS PATH_DATA "/chain"
+#define PATH_CHAINS PREFIX "/boot"
-#define PATH_TEMP PATH_DATA "/cache" // Files that are transient and used to speed operation
-#define PATH_LOADER_CACHE PATH_TEMP "/loader" // Cached patch bytecode for loader.
+#define PATH_TEMP LOCALSTATEDIR // Files that are transient and used to speed operation
+#define PATH_LOADER_CACHE PATH_TEMP "/loader" // Cached patch bytecode for loader.
-#define PATH_LOCEMU PATH_DATA "/locale" // Locale emulation config
-#define PATH_FIRMWARES PATH_DATA "/firmware" // Firmware folder.
+#define PATH_LOCEMU LOCALEDIR "/emu" // Locale emulation config
+#define PATH_FIRMWARES LIBDIR "/firmware" // Firmware folder.
-#define PATH_CONFIG_DIR PATH_DATA "/config" // Config file directory.
-#define PATH_CONFIG PATH_CONFIG_DIR "/main.conf" // Config file.
-#define PATH_CPU_CFG PATH_CONFIG_DIR "/cpu.conf" // CPU settings config
+#define PATH_CONFIG_DIR SYSCONFDIR // Config file directory.
+#define PATH_CONFIG PATH_CONFIG_DIR "/main.conf" // Config file.
+#define PATH_CPU_CFG PATH_CONFIG_DIR "/cpu.conf" // CPU settings config
-#define PATH_NATIVE_P PATH_TEMP "/p_native"
-#define PATH_AGB_P PATH_TEMP "/p_agb"
-#define PATH_TWL_P PATH_TEMP "/p_twl"
+#define PATH_NATIVE_P PATH_TEMP "/p_native"
+#define PATH_AGB_P PATH_TEMP "/p_agb"
+#define PATH_TWL_P PATH_TEMP "/p_twl"
-#define PATH_KEYS PATH_DATA "/keys" // Keyfiles will be loaded from this dir, and
- // additionally the root if not found.
+#define PATH_KEYS SHAREDIR "/keys" // Keyfiles will be loaded from this dir, and
+ // additionally the root if not found.
-#define PATH_EXEFS PATH_DATA "/exe" // ExeFS overrides/dumps, named by titleid
-#define PATH_EXEFS_TEXT PATH_EXEFS "/text" // Text segment overrides/dumps, named by titleid
-#define PATH_EXEFS_RO PATH_EXEFS "/ro" // RO segment overrides/dumps, named by titleid
-#define PATH_EXEFS_DATA PATH_EXEFS "/data" // Data segment overrides/dumps, named by titleid
+#define PATH_EXEFS LIBDIR "/exe" // ExeFS overrides/dumps, named by titleid
+#define PATH_EXEFS_TEXT PATH_EXEFS "/text" // Text segment overrides/dumps, named by titleid
+#define PATH_EXEFS_RO PATH_EXEFS "/ro" // RO segment overrides/dumps, named by titleid
+#define PATH_EXEFS_DATA PATH_EXEFS "/data" // Data segment overrides/dumps, named by titleid
-#define PATH_NATIVE_F PATH_FIRMWARES "/native"
-#define PATH_AGB_F PATH_FIRMWARES "/agb"
-#define PATH_TWL_F PATH_FIRMWARES "/twl"
+#define PATH_NATIVE_F PATH_FIRMWARES "/native"
+#define PATH_AGB_F PATH_FIRMWARES "/agb"
+#define PATH_TWL_F PATH_FIRMWARES "/twl"
-#define PATH_NATIVE_CETK PATH_KEYS "/native.cetk"
-#define PATH_TWL_CETK PATH_KEYS "/twl.cetk"
-#define PATH_AGB_CETK PATH_KEYS "/agb.cetk"
+#define PATH_NATIVE_CETK PATH_KEYS "/native.cetk"
+#define PATH_TWL_CETK PATH_KEYS "/twl.cetk"
+#define PATH_AGB_CETK PATH_KEYS "/agb.cetk"
-#define PATH_NATIVE_FIRMKEY PATH_KEYS "/native.key"
-#define PATH_TWL_FIRMKEY PATH_KEYS "/twl.key"
-#define PATH_AGB_FIRMKEY PATH_KEYS "/agb.key"
+#define PATH_NATIVE_FIRMKEY PATH_KEYS "/native.key"
+#define PATH_TWL_FIRMKEY PATH_KEYS "/twl.key"
+#define PATH_AGB_FIRMKEY PATH_KEYS "/agb.key"
-#define PATH_SLOT0X11KEY96 PATH_KEYS "/11.key"
+#define PATH_SLOT0X11KEY96 PATH_KEYS "/11Key96.key"
#define PATH_ALT_SLOT0X11KEY96 "/slot0x11key96.bin" // Hey, your perrogative, buddy. I like cleaned up
// paths.
-#define PATH_BOOTLOG PATH_DATA "/boot.log"
-#define PATH_LOADERLOG PATH_DATA "/loader.log"
+#define PATH_BOOTLOG LOCALSTATEDIR "/boot.log"
+#define PATH_LOADERLOG LOCALSTATEDIR "/loader.log"
#define PATCH_FLAG_REQUIRE (1 << 0) // Force enable patch unless 'Unsafe Options' is checked.
#define PATCH_FLAG_DEVMODE (1 << 1) // Require 'Developer Options' to be checked.
+#ifndef __UNUSED_H
+#define __UNUSED_H
+
#define _UNUSED __attribute__((unused))
+
+#endif
-out := ../$(dir_out)/$(fw_folder)
-
.PHONY: all
-all: build install
+all: build
.PHONY: build
build: clean $(patsubst %.pco, %.vco, $(wildcard *.pco))
.PHONY: install
-install: build
- mkdir -p $(out)/patch
- cp *.vco $(out)/patch/
+install:
%.vco: %.pco
../host/bytecode_asm.py $< $@
--- /dev/null
+include $(top_srcdir)/common.mk
+
+noinst_PROGRAMS = corbenik
+corbenik_CFLAGS=$(AM_CFLAGS) -T$(srcdir)/linker.ld -nostartfiles
+corbenik_LDFLAGS=$(AM_LDFLAGS) -lctr9
+EXTRA_DIST = linker.ld
+
+install:
+
+all-local: corbenik.bin
+
+clean-local:
+ rm -f corbenik.bin
+
+corbenik.bin:
+ $(OBJCOPY) $(OCFLAGS) -O binary corbenik corbenik.bin
+
+corbenikdir = $(top_srcdir)/source
+
+inc_dir = $(top_srcdir)/include
+
+corbenik_SOURCES = patch/reboot.c patch/svc.c patch/module.c patch/emunand.c main.c option.c std/fs.c std/draw.c std/memory.c std/abort.c menu.c chain.c firm/version.c firm/firm.c firm/decryptor.c firm/fcram.c interp.c input.c patcher.c display.c start.s interrupt.c screeninit.c
-#if defined(CHAINLOADER) && CHAINLOADER == 1
+#include <corbconf.h>
+#ifdef CHAINLOADER
#include <common.h>
#include <screeninit.h>
#include <ctr9/ctr_hid.h>
+#include <ctr9/io.h>
+#include <ctr9/ctr_screen.h>
+#include <ctr9/i2c.h>
#include <common.h>
std_init();
int c = fmount();
- screen_mode(0);
+
+ screen_mode(0); // Use RGBA8 mode.
+
clear_bg();
- load_bg_top(PATH_BITS "/top.bin");
+
+ load_bg_top (PATH_BITS "/top.bin");
load_bg_bottom(PATH_BITS "/bottom.bin"); // This is basically a menuhax splash (90deg rotated BGR8 pixel data)
+
clear_disp(TOP_SCREEN);
clear_disp(BOTTOM_SCREEN);
+ ctr_screen_enable_backlight(CTR_SCREEN_BOTH);
+
set_font(PATH_BITS "/termfont.bin");
install_interrupts(); // Get some free debug info.
ctr_system_poweroff();
}
-#if defined(CHAINLOADER) && CHAINLOADER == 1
+#ifdef CHAINLOADER
void chainload_menu();
#endif
{ 0, "Reboot", "Reboots the console.", call_fun, (uint32_t)reset, 0 },
{ 0, "Power off", "Powers off the console.", call_fun, (uint32_t)poweroff, 0 },
{ 0, "Save Configuration", "Save the configuration.\nYou must do this prior to booting,\notherwise the cache will not be (re)generated..", call_fun, (uint32_t)save_config, 0 },
-#if defined(CHAINLOADER) && CHAINLOADER == 1
+#ifdef CHAINLOADER
{ 0, "Chainload", "Boot another ARM9 payload file.", call_fun, (uint32_t)chainload_menu, 0 },
#endif
{ 0, "Boot Firmware", "Generates caches, patches the firmware, and boots it.\nMake sure to 'Save Configuration' first if any options changed.", break_menu, 0, 0 },
// And no, 3dbrew didn't help. Partial init seems to be a superset of what
// I was attempting.
-// if (PDN_GPU_CNT == 1) {
+ screenInitAddress[2] = 1; // Do a partial init.
+
+ if (PDN_GPU_CNT == 1)
screenInitAddress[2] = 0; // Do a full init.
- screenInitAddress[3] = 0xFF; // Brightness
- screenInitAddress[4] = mode; // Mode
- *a11_entry = (uint32_t)screenInitAddress;
+ screenInitAddress[3] = 0xFF; // Brightness
+ screenInitAddress[4] = mode; // Mode
- while (*a11_entry);
+ *a11_entry = (uint32_t)screenInitAddress;
- // Turn on backlight
- i2cWriteRegister(I2C_DEV_MCU, 0x22, 1 << 1);
+ while (*a11_entry);
- // FIXME - Time to yell at Gelex now. :|
- ctr_screen_enable_backlight(CTR_SCREEN_BOTH);
-// }
+ // Turn on backlight
+ i2cWriteRegister(I2C_DEV_MCU, 0x22, 1 << 1);
}