Added configuration menu (thanks to Cakes for the screen printing code - no more flags!), auto-delete of patched FIRMs when switching to/from A9LH or the CFW gets updated, moved screen init from the loader, general reorganization
This commit is contained in:
parent
d01d9b53f2
commit
b7b734bad1
@ -1,98 +0,0 @@
|
||||
#include "i2c.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static const struct { u8 bus_id, reg_addr; } dev_data[] = {
|
||||
{0, 0x4A}, {0, 0x7A}, {0, 0x78},
|
||||
{1, 0x4A}, {1, 0x78}, {1, 0x2C},
|
||||
{1, 0x2E}, {1, 0x40}, {1, 0x44},
|
||||
{2, 0xD6}, {2, 0xD0}, {2, 0xD2},
|
||||
{2, 0xA4}, {2, 0x9A}, {2, 0xA0},
|
||||
};
|
||||
|
||||
static inline u8 i2cGetDeviceBusId(u8 device_id) {
|
||||
return dev_data[device_id].bus_id;
|
||||
}
|
||||
|
||||
static inline u8 i2cGetDeviceRegAddr(u8 device_id) {
|
||||
return dev_data[device_id].reg_addr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static vu8* reg_data_addrs[] = {
|
||||
(vu8*)(I2C1_REG_OFF + I2C_REG_DATA),
|
||||
(vu8*)(I2C2_REG_OFF + I2C_REG_DATA),
|
||||
(vu8*)(I2C3_REG_OFF + I2C_REG_DATA),
|
||||
};
|
||||
|
||||
static inline vu8* i2cGetDataReg(u8 bus_id) {
|
||||
return reg_data_addrs[bus_id];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static vu8* reg_cnt_addrs[] = {
|
||||
(vu8*)(I2C1_REG_OFF + I2C_REG_CNT),
|
||||
(vu8*)(I2C2_REG_OFF + I2C_REG_CNT),
|
||||
(vu8*)(I2C3_REG_OFF + I2C_REG_CNT),
|
||||
};
|
||||
|
||||
static inline vu8* i2cGetCntReg(u8 bus_id) {
|
||||
return reg_cnt_addrs[bus_id];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static inline void i2cWaitBusy(u8 bus_id) {
|
||||
while (*i2cGetCntReg(bus_id) & 0x80);
|
||||
}
|
||||
|
||||
static inline u32 i2cGetResult(u8 bus_id) {
|
||||
i2cWaitBusy(bus_id);
|
||||
return (*i2cGetCntReg(bus_id) >> 4) & 1;
|
||||
}
|
||||
|
||||
static void i2cStop(u8 bus_id, u8 arg0) {
|
||||
*i2cGetCntReg(bus_id) = (arg0 << 5) | 0xC0;
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetCntReg(bus_id) = 0xC5;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static u32 i2cSelectDevice(u8 bus_id, u8 dev_reg) {
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetDataReg(bus_id) = dev_reg;
|
||||
*i2cGetCntReg(bus_id) = 0xC2;
|
||||
return i2cGetResult(bus_id);
|
||||
}
|
||||
|
||||
static u32 i2cSelectRegister(u8 bus_id, u8 reg) {
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetDataReg(bus_id) = reg;
|
||||
*i2cGetCntReg(bus_id) = 0xC0;
|
||||
return i2cGetResult(bus_id);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
u32 i2cWriteRegister(u8 dev_id, u8 reg, u8 data) {
|
||||
u8 bus_id = i2cGetDeviceBusId(dev_id);
|
||||
u8 dev_addr = i2cGetDeviceRegAddr(dev_id);
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (i2cSelectDevice(bus_id, dev_addr) && i2cSelectRegister(bus_id, reg)) {
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetDataReg(bus_id) = data;
|
||||
*i2cGetCntReg(bus_id) = 0xC1;
|
||||
i2cStop(bus_id, 0);
|
||||
if (i2cGetResult(bus_id))
|
||||
return 1;
|
||||
}
|
||||
*i2cGetCntReg(bus_id) = 0xC5;
|
||||
i2cWaitBusy(bus_id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define I2C1_REG_OFF 0x10161000
|
||||
#define I2C2_REG_OFF 0x10144000
|
||||
#define I2C3_REG_OFF 0x10148000
|
||||
|
||||
#define I2C_REG_DATA 0
|
||||
#define I2C_REG_CNT 1
|
||||
#define I2C_REG_CNTEX 2
|
||||
#define I2C_REG_SCL 4
|
||||
|
||||
#define I2C_DEV_MCU 3
|
||||
#define I2C_DEV_GYRO 10
|
||||
#define I2C_DEV_IR 13
|
||||
|
||||
u32 i2cWriteRegister(u8 dev_id, u8 reg, u8 data);
|
@ -1,6 +1,5 @@
|
||||
#include "types.h"
|
||||
#include "buttons.h"
|
||||
#include "screeninit.h"
|
||||
#include "fatfs/ff.h"
|
||||
|
||||
#define PAYLOAD_ADDRESS 0x23F00000
|
||||
@ -35,9 +34,6 @@ void main(void){
|
||||
((pressed & BUTTON_LEFT) && loadPayload("/aurei/payloads/left.bin")) ||
|
||||
((pressed & BUTTON_UP) && loadPayload("/aurei/payloads/up.bin")) ||
|
||||
((pressed & BUTTON_DOWN) && loadPayload("/aurei/payloads/down.bin")) ||
|
||||
loadPayload("/aurei/payloads/default.bin")){
|
||||
//Determine if screen was already inited
|
||||
if(*(vu8 *)0x10141200 == 0x1) initLCD();
|
||||
loadPayload("/aurei/payloads/default.bin"))
|
||||
((void (*)())PAYLOAD_ADDRESS)();
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void initLCD(void);
|
21
source/buttons.h
Normal file
21
source/buttons.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* buttons.h
|
||||
* by Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define HID_PAD ((~*(vu16 *)0x10146000) & 0xFFF)
|
||||
#define BUTTON_R1 (1 << 8)
|
||||
#define BUTTON_L1 (1 << 9)
|
||||
#define BUTTON_L1R1 (BUTTON_R1 | BUTTON_L1)
|
||||
#define BUTTON_A 1
|
||||
#define BUTTON_B (1 << 1)
|
||||
#define BUTTON_UP (1 << 6)
|
||||
#define BUTTON_DOWN (1 << 7)
|
||||
#define BUTTON_START (1 << 3)
|
||||
#define BUTTON_SELECT (1 << 2)
|
||||
#define SAFEMODE (BUTTON_L1R1 | BUTTON_A | (1 << 6))
|
108
source/config.c
Normal file
108
source/config.c
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* config.c
|
||||
* by Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "draw.h"
|
||||
#include "fs.h"
|
||||
#include "i2c.h"
|
||||
#include "buttons.h"
|
||||
|
||||
//Number of options that can be configured
|
||||
#define OPTIONS 3
|
||||
|
||||
#define COLOR_TITLE 0xFF9900
|
||||
#define COLOR_NORMAL 0xFFFFFF
|
||||
#define COLOR_SELECTED 0x0000FF
|
||||
#define COLOR_BLACK 0x000000
|
||||
|
||||
struct options {
|
||||
char *text[OPTIONS];
|
||||
int pos_y[OPTIONS];
|
||||
u32 enabled[OPTIONS];
|
||||
u32 selected;
|
||||
};
|
||||
|
||||
static u16 waitInput(void){
|
||||
u32 pressedkey = 0;
|
||||
u16 key;
|
||||
|
||||
//Wait for no keys to be pressed
|
||||
while(HID_PAD);
|
||||
|
||||
do {
|
||||
//Wait for a key to be pressed
|
||||
while(!HID_PAD);
|
||||
key = HID_PAD;
|
||||
|
||||
//Make sure it's pressed
|
||||
for(u32 i = 0x13000; i; i--){
|
||||
if (key != HID_PAD)
|
||||
break;
|
||||
if(i==1) pressedkey = 1;
|
||||
}
|
||||
} while (!pressedkey);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
void configureCFW(const char *configPath){
|
||||
struct options options;
|
||||
|
||||
options.text[0] = "( ) Updated SysNAND mode";
|
||||
options.text[1] = "( ) Use pre-patched FIRMs";
|
||||
options.text[2] = "( ) Force A9LH detection";
|
||||
|
||||
clearScreens();
|
||||
|
||||
drawString("AuReiNand configuration", 10, 10, COLOR_TITLE);
|
||||
drawString("Press A to select, START to save and reboot", 10, 30, COLOR_NORMAL);
|
||||
|
||||
//Read and parse the existing configuration
|
||||
u16 tempConfig = 0;
|
||||
fileRead((u8 *)&tempConfig, configPath, 2);
|
||||
for(u32 i = 0; i < OPTIONS; i++)
|
||||
options.enabled[i] = (tempConfig >> i) & 0x1;
|
||||
|
||||
//Pre-select the first configuration option
|
||||
options.selected = 0;
|
||||
|
||||
//Boring configuration menu
|
||||
while(1){
|
||||
u16 pressed = 0;
|
||||
|
||||
do{
|
||||
for(u32 i = 0; i < OPTIONS; i++){
|
||||
options.pos_y[i] = drawString(options.text[i], 10, !i ? 60 : options.pos_y[i - 1] + SPACING_VERT, options.selected == i ? COLOR_SELECTED : COLOR_NORMAL);
|
||||
drawCharacter('x', 10 + SPACING_HORIZ, options.pos_y[i], options.enabled[i] ? (options.selected == i ? COLOR_SELECTED : COLOR_NORMAL) : COLOR_BLACK);
|
||||
}
|
||||
pressed = waitInput();
|
||||
} while(!(pressed & (BUTTON_UP | BUTTON_DOWN | BUTTON_A | BUTTON_START)));
|
||||
|
||||
if(pressed == BUTTON_UP) options.selected = !options.selected ? OPTIONS - 1 : options.selected - 1;
|
||||
else if(pressed == BUTTON_DOWN) options.selected = options.selected == OPTIONS - 1 ? 0 : options.selected + 1;
|
||||
else if(pressed == BUTTON_A) options.enabled[options.selected] = !options.enabled[options.selected];
|
||||
else if(pressed == BUTTON_START) break;
|
||||
}
|
||||
|
||||
//Preserve the last-used boot options (second byte)
|
||||
tempConfig &= 0xFF00;
|
||||
|
||||
//Parse and write the selected options
|
||||
for(u32 i = 0; i < OPTIONS; i++)
|
||||
tempConfig |= options.enabled[i] << i;
|
||||
fileWrite((u8 *)&tempConfig, configPath, 2);
|
||||
|
||||
//Reboot
|
||||
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
|
||||
while(1);
|
||||
}
|
||||
|
||||
void deleteFirms(const char *firmPaths[], u32 firms){
|
||||
while(firms){
|
||||
fileDelete(firmPaths[firms - 1]);
|
||||
firms--;
|
||||
}
|
||||
}
|
12
source/config.h
Normal file
12
source/config.h
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* config.h
|
||||
* by Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void configureCFW(const char *configPath);
|
||||
void deleteFirms(const char *firmPaths[], u32 firms);
|
@ -1,4 +1,10 @@
|
||||
// From http://github.com/b1l1s/ctr
|
||||
/*
|
||||
* crypto.c
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Crypto libs from http://github.com/b1l1s/ctr
|
||||
*
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "crypto.h"
|
||||
#include "memory.h"
|
||||
|
@ -1,4 +1,10 @@
|
||||
// From http://github.com/b1l1s/ctr
|
||||
/*
|
||||
* crypto.h
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Crypto libs from http://github.com/b1l1s/ctr
|
||||
*
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -1,12 +1,18 @@
|
||||
/*
|
||||
* draw.c
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Code to print to the screen by mid-kid @CakesFW
|
||||
*
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "draw.h"
|
||||
#include "fs.h"
|
||||
#include "memory.h"
|
||||
#include "font.h"
|
||||
|
||||
#define SCREEN_TOP_WIDTH 400
|
||||
#define SCREEN_TOP_HEIGHT 240
|
||||
|
||||
static const struct fb {
|
||||
u8 *top_left;
|
||||
@ -14,26 +20,13 @@ static const struct fb {
|
||||
u8 *bottom;
|
||||
} *const fb = (struct fb *)0x23FFFE00;
|
||||
|
||||
void __attribute__((naked)) shutdownLCD(void){
|
||||
//Disable interrupts
|
||||
__asm(".word 0xF10C01C0");
|
||||
vu32 *const arm11 = (u32 *)0x1FFFFFF8;
|
||||
|
||||
//Clear ARM11 entry offset
|
||||
*arm11 = 0;
|
||||
|
||||
//Shutdown LCDs
|
||||
*(vu32 *)0x10202A44 = 0;
|
||||
*(vu32 *)0x10202244 = 0;
|
||||
*(vu32 *)0x10202014 = 0;
|
||||
|
||||
//Wait for the entry to be set
|
||||
while(!*arm11);
|
||||
//Jump to it
|
||||
((void (*)())*arm11)();
|
||||
static int strlen(const char *string){
|
||||
char *stringEnd = (char *)string;
|
||||
while(*stringEnd) stringEnd++;
|
||||
return stringEnd - string;
|
||||
}
|
||||
|
||||
static void clearScreens(void){
|
||||
void clearScreens(void){
|
||||
memset32(fb->top_left, 0, 0x46500);
|
||||
memset32(fb->top_right, 0, 0x46500);
|
||||
memset32(fb->bottom, 0, 0x38400);
|
||||
@ -41,9 +34,49 @@ static void clearScreens(void){
|
||||
|
||||
void loadSplash(void){
|
||||
clearScreens();
|
||||
|
||||
//Don't delay boot if no splash image is on the SD
|
||||
if(fileRead(fb->top_left, "/aurei/splash.bin", 0x46500) +
|
||||
fileRead(fb->bottom, "/aurei/splashbottom.bin", 0x38400)){
|
||||
u64 i = 0x1300000; while(--i) __asm("mov r0, r0"); //Less Ghetto sleep func
|
||||
}
|
||||
}
|
||||
|
||||
void drawCharacter(char character, int pos_x, int pos_y, u32 color){
|
||||
u8 *select = fb->top_left;
|
||||
|
||||
for(int y = 0; y < 8; y++){
|
||||
unsigned char char_pos = font[character * 8 + y];
|
||||
|
||||
for(int x = 7; x >= 0; x--){
|
||||
int screen_pos = (pos_x * SCREEN_TOP_HEIGHT * 3 + (SCREEN_TOP_HEIGHT - y - pos_y - 1) * 3) + (7 - x) * 3 * SCREEN_TOP_HEIGHT;
|
||||
|
||||
if ((char_pos >> x) & 1) {
|
||||
select[screen_pos] = color >> 16;
|
||||
select[screen_pos + 1] = color >> 8;
|
||||
select[screen_pos + 2] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int drawString(const char *string, int pos_x, int pos_y, u32 color){
|
||||
int length = strlen(string);
|
||||
|
||||
for(int i = 0, line_i = 0; i < length; i++, line_i++){
|
||||
if(string[i] == '\n'){
|
||||
pos_y += SPACING_VERT;
|
||||
line_i = 0;
|
||||
i++;
|
||||
} else if(line_i >= (SCREEN_TOP_WIDTH - pos_x) / SPACING_HORIZ){
|
||||
// Make sure we never get out of the screen.
|
||||
pos_y += SPACING_VERT;
|
||||
line_i = 2; // Little offset so we know the same string continues.
|
||||
if(string[i] == ' ') i++; // Spaces at the start look weird
|
||||
}
|
||||
|
||||
drawCharacter(string[i], pos_x + line_i * SPACING_HORIZ, pos_y, color);
|
||||
}
|
||||
|
||||
return pos_y;
|
||||
}
|
@ -1,12 +1,19 @@
|
||||
/*
|
||||
* draw.h
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Code to print to the screen by mid-kid @CakesFW
|
||||
*
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define SPACING_VERT 10
|
||||
#define SPACING_HORIZ 8
|
||||
|
||||
void loadSplash(void);
|
||||
void __attribute__((naked)) shutdownLCD(void);
|
||||
void clearScreens(void);
|
||||
void drawCharacter(char character, int pos_x, int pos_y, u32 color);
|
||||
int drawString(const char *string, int pos_x, int pos_y, u32 color);
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* emunand.c
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "emunand.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* emunand.h
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -23,7 +23,7 @@
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 3
|
||||
#define _FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
|
117
source/firm.c
117
source/firm.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* firm.c
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "firm.h"
|
||||
@ -11,18 +11,28 @@
|
||||
#include "emunand.h"
|
||||
#include "crypto.h"
|
||||
#include "draw.h"
|
||||
#include "screeninit.h"
|
||||
#include "loader.h"
|
||||
#include "config.h"
|
||||
#include "buttons.h"
|
||||
|
||||
//FIRM patches version
|
||||
#define PATCH_VER 1
|
||||
|
||||
static firmHeader *const firmLocation = (firmHeader *)0x24000000;
|
||||
static const firmSectionHeader *section;
|
||||
static u8 *arm9Section;
|
||||
static const char *patchedFirms[] = { "/aurei/patched_firmware_sys.bin",
|
||||
"/aurei/patched_firmware_emu.bin",
|
||||
"/aurei/patched_firmware_em2.bin",
|
||||
"/aurei/patched_firmware90.bin" };
|
||||
static u32 firmSize,
|
||||
mode = 1,
|
||||
console = 1,
|
||||
emuNAND = 0,
|
||||
a9lhSetup = 0,
|
||||
usePatchedFirm = 0;
|
||||
static u8 *arm9Section;
|
||||
static const char *firmPathPatched = NULL;
|
||||
usePatchedFirm = 0,
|
||||
selectedFirm = 0;
|
||||
|
||||
void setupCFW(void){
|
||||
|
||||
@ -30,46 +40,51 @@ void setupCFW(void){
|
||||
u32 a9lhBoot = (PDN_SPI_CNT == 0x0) ? 1 : 0;
|
||||
//Retrieve the last booted FIRM
|
||||
u8 previousFirm = CFG_BOOTENV;
|
||||
u32 updatedSys = 0;
|
||||
u32 overrideConfig = 0;
|
||||
const char lastConfigPath[] = "aurei/lastbootcfg";
|
||||
|
||||
//Detect the console being used
|
||||
if(PDN_MPCORE_CFG == 1) console = 0;
|
||||
|
||||
//Get pressed buttons
|
||||
u16 pressed = HID_PAD;
|
||||
u32 updatedSys = 0;
|
||||
|
||||
//Attempt to read the configuration file
|
||||
const char configPath[] = "aurei/config.bin";
|
||||
u16 config = 0;
|
||||
u32 needConfig = fileRead((u8 *)&config, configPath, 2) ? 1 : 2;
|
||||
|
||||
//Determine if A9LH is installed
|
||||
if(a9lhBoot || fileExists("/aurei/installeda9lh")){
|
||||
if(a9lhBoot || (config >> 2) & 0x1){
|
||||
a9lhSetup = 1;
|
||||
//Check flag for > 9.2 SysNAND
|
||||
if(fileExists("/aurei/updatedsysnand")) updatedSys = 1;
|
||||
//Check setting for > 9.2 SysNAND
|
||||
updatedSys = config & 0x1;
|
||||
}
|
||||
|
||||
//If booting with A9LH and it's a MCU reboot, try to force boot options
|
||||
if(a9lhBoot && previousFirm && fileExists(lastConfigPath)){
|
||||
u8 tempConfig;
|
||||
fileRead(&tempConfig, lastConfigPath, 1);
|
||||
|
||||
/* If booting with A9LH, it's a MCU reboot and a previous configuration exists,
|
||||
try to force boot options */
|
||||
if(a9lhBoot && previousFirm && needConfig == 1){
|
||||
//Always force a sysNAND boot when quitting AGB_FIRM
|
||||
if(previousFirm == 0x7){
|
||||
if(!updatedSys) mode = tempConfig & 0x1;
|
||||
overrideConfig = 1;
|
||||
if(!updatedSys) mode = (config >> 8) & 0x1;
|
||||
needConfig = 0;
|
||||
//Else, force the last used boot options unless A is pressed
|
||||
} else if(!(pressed & BUTTON_A)){
|
||||
mode = tempConfig & 0x1;
|
||||
emuNAND = (tempConfig >> 1) & 0x1;
|
||||
overrideConfig = 1;
|
||||
mode = (config >> 8) & 0x1;
|
||||
emuNAND = (config >> 9) & 0x1;
|
||||
needConfig = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(!overrideConfig){
|
||||
if(needConfig){
|
||||
|
||||
//If L and R are pressed, chainload an external payload
|
||||
if(a9lhBoot && (pressed & BUTTON_L1R1) == BUTTON_L1R1) loadPayload();
|
||||
|
||||
//Check if it's a no-screen-init A9LH boot
|
||||
//If no configuration file exists or SELECT is held, load configuration menu
|
||||
if(needConfig == 2 || (pressed & BUTTON_SELECT)){
|
||||
if(PDN_GPU_CNT == 0x1) initScreens();
|
||||
configureCFW(configPath);
|
||||
}
|
||||
|
||||
//If screens are inited, load splash screen
|
||||
if(PDN_GPU_CNT != 0x1) loadSplash();
|
||||
|
||||
/* If L is pressed, and on an updated SysNAND setup the SAFE MODE combo
|
||||
@ -85,22 +100,30 @@ void setupCFW(void){
|
||||
else emuNAND = 1;
|
||||
}
|
||||
|
||||
//Write the current boot options on A9LH
|
||||
if(a9lhBoot){
|
||||
u8 tempConfig = (mode | (emuNAND << 1)) & 0x3;
|
||||
fileWrite(&tempConfig, lastConfigPath, 1);
|
||||
/* If tha FIRM patches version is different or user switched to/from A9LH,
|
||||
and "Use pre-patched FIRMs" is set, delete all patched FIRMs */
|
||||
u16 bootConfig = (PATCH_VER << 11) | (!a9lhSetup << 10);
|
||||
if ((config >> 1) & 0x1 && bootConfig != (config & 0xFC00))
|
||||
deleteFirms(patchedFirms, sizeof(patchedFirms) / sizeof(char *));
|
||||
|
||||
//We also need to remember the used boot mode on A9LH
|
||||
if(a9lhBoot) bootConfig |= (mode << 8) | (emuNAND << 9);
|
||||
|
||||
//If boot configuration is different from previously, overwrite it
|
||||
if(bootConfig != (config & 0xFF00)){
|
||||
//Preserve used settings (first byte)
|
||||
u16 tempConfig = ((config & 0xFF) | bootConfig);
|
||||
fileWrite((u8 *)&tempConfig, configPath, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if(mode) firmPathPatched = emuNAND ? (emuNAND == 1 ? "/aurei/patched_firmware_emu.bin" :
|
||||
"/aurei/patched_firmware_em2.bin") :
|
||||
"/aurei/patched_firmware_sys.bin";
|
||||
if(mode) selectedFirm = emuNAND ? (emuNAND == 1 ? 2 : 3) : 1;
|
||||
|
||||
//Skip decrypting and patching FIRM
|
||||
if(fileExists("/aurei/usepatchedfw")){
|
||||
//Only needed with this flag
|
||||
if(!mode) firmPathPatched = "/aurei/patched_firmware90.bin";
|
||||
if(fileExists(firmPathPatched)) usePatchedFirm = 1;
|
||||
if((config >> 1) & 0x1){
|
||||
//Only needed with this setting
|
||||
if(!mode) selectedFirm = 4;
|
||||
if(fileExists(patchedFirms[selectedFirm - 1])) usePatchedFirm = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +140,7 @@ u32 loadFirm(void){
|
||||
}
|
||||
//Load FIRM from SD
|
||||
else{
|
||||
const char *path = usePatchedFirm ? firmPathPatched :
|
||||
const char *path = usePatchedFirm ? patchedFirms[selectedFirm - 1] :
|
||||
(mode ? "/aurei/firmware.bin" : "/aurei/firmware90.bin");
|
||||
firmSize = fileSize(path);
|
||||
if(!firmSize) return 0;
|
||||
@ -220,8 +243,8 @@ u32 patchFirm(void){
|
||||
|
||||
if(a9lhSetup && !emuNAND){
|
||||
//Patch FIRM partitions writes on SysNAND to protect A9LH
|
||||
void *writeOffset = getFIRMWrite(arm9Section, section[2].size);
|
||||
memcpy(writeOffset, FIRMblock, sizeof(FIRMblock));
|
||||
void *writeOffset = getFirmWrite(arm9Section, section[2].size);
|
||||
memcpy(writeOffset, writeBlock, sizeof(writeBlock));
|
||||
}
|
||||
|
||||
//Disable signature checks
|
||||
@ -237,8 +260,8 @@ u32 patchFirm(void){
|
||||
firmLocation->arm9Entry = (u8 *)0x801B01C;
|
||||
|
||||
//Write patched FIRM to SD if needed
|
||||
if(firmPathPatched)
|
||||
if(!fileWrite((u8 *)firmLocation, firmPathPatched, firmSize)) return 0;
|
||||
if(selectedFirm)
|
||||
if(!fileWrite((u8 *)firmLocation, patchedFirms[selectedFirm - 1], firmSize)) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -252,14 +275,12 @@ void launchFirm(void){
|
||||
memcpy(section[1].address, (u8 *)firmLocation + section[1].offset, section[1].size);
|
||||
memcpy(section[2].address, arm9Section, section[2].size);
|
||||
|
||||
//Run ARM11 screen stuff
|
||||
vu32 *const arm11 = (u32 *)0x1FFFFFF8;
|
||||
*arm11 = (u32)shutdownLCD;
|
||||
while(*arm11);
|
||||
//Fixes N3DS 3D
|
||||
deinitScreens();
|
||||
|
||||
//Set ARM11 kernel
|
||||
*arm11 = (u32)firmLocation->arm11Entry;
|
||||
//Set ARM11 kernel entrypoint
|
||||
*(vu32 *)0x1FFFFFF8 = (u32)firmLocation->arm11Entry;
|
||||
|
||||
//Final jump to arm9 binary
|
||||
//Final jump to arm9 kernel
|
||||
((void (*)())firmLocation->arm9Entry)();
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* firm.h
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -9,16 +9,8 @@
|
||||
#include "types.h"
|
||||
|
||||
#define PDN_MPCORE_CFG (*(vu8 *)0x10140FFC)
|
||||
#define HID_PAD ((~*(vu16 *)0x10146000) & 0xFFF)
|
||||
#define PDN_SPI_CNT (*(vu8 *)0x101401C0)
|
||||
#define CFG_BOOTENV (*(vu8 *)0x10010000)
|
||||
#define PDN_GPU_CNT (*(vu8 *)0x10141200)
|
||||
#define BUTTON_R1 (1 << 8)
|
||||
#define BUTTON_L1 (1 << 9)
|
||||
#define BUTTON_L1R1 (BUTTON_R1 | BUTTON_L1)
|
||||
#define BUTTON_A 1
|
||||
#define BUTTON_B (1 << 1)
|
||||
#define SAFEMODE (BUTTON_L1R1 | BUTTON_A | (1 << 6))
|
||||
|
||||
//FIRM Header layout
|
||||
typedef struct firmSectionHeader {
|
||||
|
144
source/font.h
Normal file
144
source/font.h
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
This file was autogenerated by raw2c.
|
||||
Visit http://www.devkitpro.org
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
#ifndef _font_h_
|
||||
#define _font_h_
|
||||
//---------------------------------------------------------------------------------
|
||||
static const unsigned char font[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
|
||||
0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
|
||||
0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x3c, 0x3c, 0x18, 0xff, 0xe7, 0x18, 0x3c, 0x00,
|
||||
0x10, 0x38, 0x7c, 0xfe, 0xee, 0x10, 0x38, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00,
|
||||
0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00,
|
||||
0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
|
||||
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x08, 0x0c, 0x0a, 0x0a, 0x08, 0x78, 0xf0, 0x00,
|
||||
0x18, 0x14, 0x1a, 0x16, 0x72, 0xe2, 0x0e, 0x1c, 0x10, 0x54, 0x38, 0xee, 0x38, 0x54, 0x10, 0x00,
|
||||
0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
|
||||
0x18, 0x3c, 0x5a, 0x18, 0x5a, 0x3c, 0x18, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
|
||||
0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x00, 0x1c, 0x22, 0x38, 0x44, 0x44, 0x38, 0x88, 0x70,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x5a, 0x18, 0x5a, 0x3c, 0x18, 0x7e,
|
||||
0x18, 0x3c, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x5a, 0x3c, 0x18, 0x00,
|
||||
0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00,
|
||||
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x24, 0x42, 0xff, 0x42, 0x24, 0x00, 0x00,
|
||||
0x00, 0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00,
|
||||
0x6c, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
|
||||
0x10, 0x7c, 0xd0, 0x7c, 0x16, 0xfc, 0x10, 0x00, 0x00, 0x66, 0xac, 0xd8, 0x36, 0x6a, 0xcc, 0x00,
|
||||
0x38, 0x4c, 0x38, 0x78, 0xce, 0xcc, 0x7a, 0x00, 0x30, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
|
||||
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x20, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x00,
|
||||
0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xe6, 0x7c, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x7e, 0x00,
|
||||
0x7c, 0xc6, 0x06, 0x1c, 0x70, 0xc6, 0xfe, 0x00, 0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00,
|
||||
0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, 0xfe, 0xc0, 0xfc, 0x06, 0x06, 0xc6, 0x7c, 0x00,
|
||||
0x7c, 0xc6, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00, 0xfe, 0xc6, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00,
|
||||
0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00, 0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0xc6, 0x7c, 0x00,
|
||||
0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x10, 0x20,
|
||||
0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00,
|
||||
0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00,
|
||||
0x7c, 0x82, 0x9e, 0xa6, 0x9e, 0x80, 0x7c, 0x00, 0x7c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00,
|
||||
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00,
|
||||
0xfc, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00,
|
||||
0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, 0x7c, 0xc6, 0xc6, 0xc0, 0xce, 0xc6, 0x7e, 0x00,
|
||||
0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
||||
0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00,
|
||||
0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x82, 0xc6, 0xee, 0xfe, 0xd6, 0xc6, 0xc6, 0x00,
|
||||
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
||||
0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x06,
|
||||
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xe6, 0x00, 0x7c, 0xc6, 0xc0, 0x7c, 0x06, 0xc6, 0x7c, 0x00,
|
||||
0x7e, 0x5a, 0x5a, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
||||
0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x82, 0x00,
|
||||
0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x00,
|
||||
0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00,
|
||||
0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00,
|
||||
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
||||
0x30, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
||||
0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x00,
|
||||
0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
|
||||
0x1c, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x78,
|
||||
0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
||||
0x00, 0x0c, 0x00, 0x1c, 0x0c, 0x0c, 0xcc, 0x78, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00,
|
||||
0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0xcc, 0xfe, 0xd6, 0xd6, 0xd6, 0x00,
|
||||
0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
||||
0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x7c, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e,
|
||||
0x00, 0x00, 0xde, 0x76, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0xc0, 0x7c, 0x06, 0x7c, 0x00,
|
||||
0x10, 0x30, 0xfc, 0x30, 0x30, 0x34, 0x18, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
|
||||
0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00,
|
||||
0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
|
||||
0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00, 0x0e, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0e, 0x00,
|
||||
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, 0xe0, 0x30, 0x30, 0x18, 0x30, 0x30, 0xe0, 0x00,
|
||||
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00,
|
||||
0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x70, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
|
||||
0x0e, 0x10, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, 0x7c, 0x82, 0x38, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
||||
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, 0xe0, 0x10, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
||||
0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x7c, 0xc0, 0xc0, 0x7c, 0x18, 0x70,
|
||||
0x7c, 0x82, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
|
||||
0xe0, 0x10, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
||||
0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xe0, 0x10, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
||||
0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, 0x38, 0x38, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00,
|
||||
0x0e, 0x10, 0xfe, 0x60, 0x78, 0x60, 0xfe, 0x00, 0x00, 0x00, 0x7c, 0x12, 0x7e, 0xd0, 0x7e, 0x00,
|
||||
0x7e, 0xc8, 0xc8, 0xfe, 0xc8, 0xc8, 0xce, 0x00, 0x7c, 0x82, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
||||
0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0xe0, 0x10, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
||||
0x7c, 0x82, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0xe0, 0x10, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
|
||||
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
||||
0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x18, 0x7c, 0xd6, 0xd0, 0xd6, 0x7c, 0x18, 0x00,
|
||||
0x38, 0x6c, 0x60, 0xf0, 0x60, 0xf2, 0xdc, 0x00, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x00,
|
||||
0xf8, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0x06, 0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70,
|
||||
0x0e, 0x10, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, 0x0e, 0x10, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
||||
0x0e, 0x10, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x0e, 0x10, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
|
||||
0x66, 0x98, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x98, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0x00,
|
||||
0x38, 0x0c, 0x3c, 0x34, 0x00, 0x7e, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00,
|
||||
0x30, 0x00, 0x30, 0x60, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00, 0xc0, 0xc8, 0xd0, 0xfe, 0x46, 0x8c, 0x1e, 0x00,
|
||||
0xc0, 0xc8, 0xd0, 0xec, 0x5c, 0xbe, 0x0c, 0x00, 0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00,
|
||||
0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00,
|
||||
0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
|
||||
0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0xdb, 0xee, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36,
|
||||
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
|
||||
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x74, 0xcc, 0xc8, 0xdc, 0x76, 0x00, 0x78, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xdc, 0x40,
|
||||
0xfe, 0x62, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x02, 0x7e, 0xec, 0x6c, 0x6c, 0x48, 0x00,
|
||||
0xfe, 0x62, 0x30, 0x18, 0x30, 0x62, 0xfe, 0x00, 0x00, 0x00, 0x7e, 0xd0, 0xc8, 0xc8, 0x70, 0x00,
|
||||
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xf8, 0x80, 0x00, 0x00, 0x7e, 0xd8, 0x18, 0x18, 0x10, 0x00,
|
||||
0x38, 0x10, 0x7c, 0xd6, 0xd6, 0x7c, 0x10, 0x38, 0x7c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x7c, 0x00,
|
||||
0x7c, 0xc6, 0xc6, 0xc6, 0x6c, 0x28, 0xee, 0x00, 0x3c, 0x22, 0x18, 0x7c, 0xcc, 0xcc, 0x78, 0x00,
|
||||
0x00, 0x00, 0x66, 0x99, 0x99, 0x66, 0x00, 0x00, 0x00, 0x06, 0x7c, 0x9e, 0xf2, 0x7c, 0xc0, 0x00,
|
||||
0x00, 0x00, 0x7c, 0xc0, 0xf8, 0xc0, 0x7c, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00,
|
||||
0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00,
|
||||
0x30, 0x18, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0x00, 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0x7c, 0x00,
|
||||
0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70,
|
||||
0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00,
|
||||
0x38, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x00,
|
||||
0xd8, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x30, 0xc0, 0xf0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
};
|
||||
const int font_size = sizeof(font);
|
||||
//---------------------------------------------------------------------------------
|
||||
#endif //_font_h_
|
||||
//---------------------------------------------------------------------------------
|
@ -1,5 +1,7 @@
|
||||
/*
|
||||
* fs.c
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
@ -59,3 +61,7 @@ u32 fileExists(const char *path){
|
||||
f_close(&fp);
|
||||
return exists;
|
||||
}
|
||||
|
||||
void fileDelete(const char *path){
|
||||
f_unlink(path);
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
/*
|
||||
* fs.h
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -11,3 +13,4 @@ u32 fileRead(u8 *dest, const char *path, u32 size);
|
||||
u32 fileWrite(const u8 *buffer, const char *path, u32 size);
|
||||
u32 fileSize(const char *path);
|
||||
u32 fileExists(const char *path);
|
||||
void fileDelete(const char *path);
|
@ -1,14 +1,23 @@
|
||||
/*
|
||||
* loader.c
|
||||
* by Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "loader.h"
|
||||
#include "fs.h"
|
||||
#include "screeninit.h"
|
||||
#include "draw.h"
|
||||
|
||||
#define PAYLOAD_ADDRESS 0x24F00000
|
||||
|
||||
void loadPayload(void){
|
||||
if(fileExists("aurei/payloads/default.bin") &&
|
||||
fileRead((u8 *)PAYLOAD_ADDRESS, "aurei/loader.bin", 0))
|
||||
fileRead((u8 *)PAYLOAD_ADDRESS, "aurei/loader.bin", 0)){
|
||||
if(PDN_GPU_CNT == 0x1){
|
||||
initScreens();
|
||||
clearScreens();
|
||||
}
|
||||
((void (*)())PAYLOAD_ADDRESS)();
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
/*
|
||||
* loader.h
|
||||
* by Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* main.c
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*
|
||||
* Minimalist CFW for N3DS
|
||||
* Minimalist CFW for (N)3DS
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* memory.c
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "memory.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* memory.h
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* patches.c
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "patches.h"
|
||||
@ -11,11 +11,11 @@
|
||||
* Patches
|
||||
**************************************************/
|
||||
|
||||
const u8 mpu[0x2C] = { //MPU shit
|
||||
const u8 mpu[0x2C] = {
|
||||
0x03, 0x00, 0x36, 0x00, 0x00, 0x00, 0x10, 0x10, 0x01, 0x00, 0x00, 0x01, 0x03, 0x00, 0x36, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x01, 0x01, 0x01, 0x01, 0x03, 0x06, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||
0x01, 0x01, 0x01, 0x01, 0x03, 0x06, 0x1C, 0x00, 0x00, 0x00, 0x02, 0x08
|
||||
};
|
||||
};
|
||||
|
||||
//Branch to emunand function. To be filled in
|
||||
u8 nandRedir[0x08] = {0x00, 0x4C, 0xA0, 0x47, 0x00, 0x00, 0x00, 0x00};
|
||||
@ -23,7 +23,7 @@ u8 nandRedir[0x08] = {0x00, 0x4C, 0xA0, 0x47, 0x00, 0x00, 0x00, 0x00};
|
||||
const u8 sigPat1[2] = {0x00, 0x20};
|
||||
const u8 sigPat2[4] = {0x00, 0x20, 0x70, 0x47};
|
||||
|
||||
const u8 FIRMblock[4] = {0x00, 0x20, 0xC0, 0x46};
|
||||
const u8 writeBlock[4] = {0x00, 0x20, 0xC0, 0x46};
|
||||
|
||||
/**************************************************
|
||||
* Functions
|
||||
@ -61,7 +61,7 @@ u32 getfOpen(void *pos, u32 size, u8 *proc9Offset){
|
||||
return (u32)memsearch(pos, pattern, size, 4) - 2 - p9CodeOff + p9MemAddr;
|
||||
}
|
||||
|
||||
void *getFIRMWrite(void *pos, u32 size){
|
||||
void *getFirmWrite(void *pos, u32 size){
|
||||
//Look for FIRM writing code
|
||||
u8 *firmwrite = (u8 *)memsearch(pos, "exe:", size, 4);
|
||||
const unsigned char pattern[] = {0x00, 0x28, 0x01, 0xDA};
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* patches.h
|
||||
* by Reisyukaku
|
||||
* Copyright (c) 2015 All Rights Reserved
|
||||
* by Reisyukaku / Aurora Wright
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -15,7 +15,7 @@ const u8 mpu[0x2C];
|
||||
u8 nandRedir[0x08];
|
||||
const u8 sigPat1[2];
|
||||
const u8 sigPat2[4];
|
||||
const u8 FIRMblock[4];
|
||||
const u8 writeBlock[4];
|
||||
|
||||
/**************************************************
|
||||
* Functions
|
||||
@ -24,4 +24,4 @@ u8 *getProc9(void *pos, u32 size);
|
||||
void getSignatures(void *pos, u32 size, u32 *off, u32 *off2);
|
||||
u8 *getReboot(void *pos, u32 size);
|
||||
u32 getfOpen(void *pos, u32 size, u8 *proc9Offset);
|
||||
void *getFIRMWrite(void *pos, u32 size);
|
||||
void *getFirmWrite(void *pos, u32 size);
|
@ -1,11 +1,45 @@
|
||||
/*
|
||||
* screeninit.c
|
||||
* by Aurora Wright
|
||||
* Screen init code by dark_samus, bil1s, Normmatt, delebile and others.
|
||||
* Screen deinit code by tiniVi.
|
||||
*
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#include "screeninit.h"
|
||||
#include "i2c.h"
|
||||
|
||||
void initLCD(void){
|
||||
vu32 *const arm11 = (vu32 *)0x1FFFFFF8;
|
||||
static vu32 *const arm11 = (vu32 *)0x1FFFFFF8;
|
||||
|
||||
void deinitScreens(void){
|
||||
void __attribute__((naked)) ARM11(void){
|
||||
//Disable interrupts
|
||||
__asm(".word 0xF10C01C0");
|
||||
|
||||
//Clear ARM11 entry offset
|
||||
*arm11 = 0;
|
||||
|
||||
//Shutdown LCDs
|
||||
*(vu32 *)0x10202A44 = 0;
|
||||
*(vu32 *)0x10202244 = 0;
|
||||
*(vu32 *)0x10202014 = 0;
|
||||
|
||||
//Wait for the entry to be set
|
||||
while(!*arm11);
|
||||
//Jump to it
|
||||
((void (*)())*arm11)();
|
||||
}
|
||||
|
||||
*arm11 = (u32)ARM11;
|
||||
while(*arm11);
|
||||
}
|
||||
|
||||
void initScreens(void){
|
||||
void __attribute__((naked)) ARM11(void){
|
||||
//Disable interrupts
|
||||
__asm(".word 0xF10C01C0");
|
||||
|
||||
*(vu32 *)0x10141200 = 0x1007F;
|
||||
*(vu32 *)0x10202014 = 0x00000001;
|
||||
*(vu32 *)0x1020200C &= 0xFFFEFFFE;
|
17
source/screeninit.h
Normal file
17
source/screeninit.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* screeninit.h
|
||||
* by Aurora Wright
|
||||
* Screen init code by dark_samus, bil1s, Normmatt, delebile and others.
|
||||
* Screen deinit code by tiniVi.
|
||||
*
|
||||
* Copyright (c) 2016 All Rights Reserved
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define PDN_GPU_CNT (*(vu8 *)0x10141200)
|
||||
|
||||
void deinitScreens(void);
|
||||
void initScreens(void);
|
Reference in New Issue
Block a user