Add ARM9 exception vectors feature from @TuxSH

This commit is contained in:
Aurora
2016-04-26 22:06:19 +02:00
parent efd08ff731
commit f0e1937eeb
18 changed files with 556 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ void configureCFW(const char *configPath)
"( ) Force A9LH detection",
"( ) Use second EmuNAND as default",
"( ) Enable region/language emulation",
"( ) Use developer UNITINFO",
"( ) Enable developer features",
"( ) Show current NAND in System Settings",
"( ) Show GBA boot screen in patched AGB_FIRM",
"( ) Enable splash screen with no screen-init" };

38
source/exceptions.c Normal file
View File

@@ -0,0 +1,38 @@
/*
* exceptions.c
* by TuxSH
*/
#include "exceptions.h"
#include "fs.h"
#include "memory.h"
#include "utils.h"
#include "../build/arm9_exceptions.h"
#define PAYLOAD_ADDRESS 0x01FF8000
void installArm9Handlers(void)
{
memcpy((void *)PAYLOAD_ADDRESS, arm9_exceptions, arm9_exceptions_size);
((void (*)())PAYLOAD_ADDRESS)();
}
void detectAndProcessExceptionDumps(void)
{
vu32 *dump = (u32 *)0x25000000;
if(dump[0] == 0xDEADC0DE && dump[1] == 0xDEADCAFE && dump[3] == 9)
{
char path[41] = "/luma/dumps/arm9";
char fileName[] = "crash_dump_00000000.dmp";
findDumpFile(path, fileName);
path[16] = '/';
memcpy(&path[17], fileName, sizeof(fileName));
fileWrite((void *)dump, path, dump[5]);
error("An ARM9 exception occured.\nPlease check your /luma/dumps/arm9 folder.");
}
}

11
source/exceptions.h Normal file
View File

@@ -0,0 +1,11 @@
/*
* exceptions.h
* by TuxSH
*/
#pragma once
#include "types.h"
void installArm9Handlers(void);
void detectAndProcessExceptionDumps(void);

View File

@@ -13,6 +13,7 @@
#include "draw.h"
#include "screeninit.h"
#include "loader.h"
#include "exceptions.h"
#include "buttons.h"
#include "../build/patches.h"
@@ -67,6 +68,13 @@ void main(void)
}
else
{
//Only when "Enable developer features" is set
if(CONFIG(5))
{
detectAndProcessExceptionDumps();
installArm9Handlers();
}
bootType = 0;
firmType = 0;

View File

@@ -61,6 +61,27 @@ u32 defPayloadExists(void)
return (result == FR_OK && info.fname[0]);
}
void findDumpFile(const char *path, char *fileName)
{
DIR dir;
FILINFO info;
u32 n = 0;
while(f_findfirst(&dir, &info, path, fileName) == FR_OK && info.fname[0])
{
u32 i = 18,
tmp = ++n;
while(tmp)
{
fileName[i--] = '0' + (tmp % 10);
tmp /= 10;
}
}
f_closedir(&dir);
}
void firmRead(void *dest, const char *firmFolder)
{
char path[48] = "1:/title/00040138/00000000/content";

View File

@@ -10,4 +10,5 @@ u32 mountFs(void);
u32 fileRead(void *dest, const char *path, u32 size);
u32 fileWrite(const void *buffer, const char *path, u32 size);
u32 defPayloadExists(void);
void findDumpFile(const char *path, char *fileName);
void firmRead(void *dest, const char *firmFolder);