Moved and specialized error code for the exception vectors

This commit is contained in:
Aurora 2016-05-03 17:05:19 +02:00
parent 169b12fc20
commit f55fc421ea
2 changed files with 18 additions and 21 deletions

View File

@ -6,15 +6,18 @@
#include "exceptions.h" #include "exceptions.h"
#include "fs.h" #include "fs.h"
#include "memory.h" #include "memory.h"
#include "screeninit.h"
#include "draw.h"
#include "i2c.h"
#include "utils.h" #include "utils.h"
#include "../build/arm9_exceptions.h" #include "../build/arm9_exceptions.h"
#define PAYLOAD_ADDRESS 0x01FF8000
void installArm9Handlers(void) void installArm9Handlers(void)
{ {
memcpy((void *)PAYLOAD_ADDRESS, arm9_exceptions, arm9_exceptions_size); void *payloadAddress = (void *)0x01FF8000;
((void (*)())PAYLOAD_ADDRESS)();
memcpy(payloadAddress, arm9_exceptions, arm9_exceptions_size);
((void (*)())payloadAddress)();
} }
void detectAndProcessExceptionDumps(void) void detectAndProcessExceptionDumps(void)
@ -33,6 +36,16 @@ void detectAndProcessExceptionDumps(void)
fileWrite((void *)dump, path, dump[5]); fileWrite((void *)dump, path, dump[5]);
error("An ARM9 exception occured.\nPlease check your /luma/dumps/arm9 folder."); initScreens();
drawString("An ARM9 exception occured", 10, 10, COLOR_RED);
int posY = drawString("You can find a dump in the following file:", 10, 30, COLOR_WHITE);
posY = drawString(path, posY + SPACING_Y, 30, COLOR_WHITE);
drawString("Press any button to shutdown", 10, posY + 2 * SPACING_Y, COLOR_WHITE);
waitInput();
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1);
while(1);
} }
} }

View File

@ -4,8 +4,6 @@
#include "utils.h" #include "utils.h"
#include "i2c.h" #include "i2c.h"
#include "screeninit.h"
#include "draw.h"
#include "buttons.h" #include "buttons.h"
u32 waitInput(void) u32 waitInput(void)
@ -40,17 +38,3 @@ void mcuReboot(void)
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
while(1); while(1);
} }
void error(const char *message)
{
initScreens();
drawString("An error has occurred:", 10, 10, COLOR_RED);
int posY = drawString(message, 10, 30, COLOR_WHITE);
drawString("Press any button to shutdown", 10, posY + 2 * SPACING_Y, COLOR_WHITE);
waitInput();
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1);
while(1);
}