From 0694ea836744c97ea10eb2bbfe53a442cd889210 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 7 Jun 2017 17:36:53 -0700 Subject: [PATCH] Add config option to disable exception vectors. --- source/config.c | 9 +++++ source/config.h | 5 +-- sysmodules/loader/source/patcher.h | 3 +- .../kernel_extension/include/config.h | 36 +++++++++++++++++++ .../kernel_extension/include/globals.h | 1 + .../source/fatalExceptionHandlersMain.c | 2 ++ 6 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 sysmodules/rosalina/kernel_extension/include/config.h diff --git a/source/config.c b/source/config.c index 8db8a22..7149d71 100644 --- a/source/config.c +++ b/source/config.c @@ -94,6 +94,7 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) "( ) Show GBA boot screen in patched AGB_FIRM", "( ) Patch ARM9 access", "( ) Set developer UNITINFO", + "( ) Disable Exception Vectors", }; const char *optionsDescription[] = { "Select the default EmuNAND.\n\n" @@ -187,6 +188,13 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) "and booting some developer software).\n\n" "Only select this if you know what you\n" "are doing!", + + "Disables the fatal error exception\n" + "vectors for the ARM11 CPU\n" + "Note: Disabling the exception vectors\n" + "will disqualify you from submitting\n" + "issues or bug reports to the Luma3DS\n" + "GitHub repository!" }; struct multiOption { @@ -214,6 +222,7 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) { .visible = true }, { .visible = true }, { .visible = true }, + { .visible = true }, { .visible = true } }; diff --git a/source/config.h b/source/config.h index 7f82c63..7761e47 100644 --- a/source/config.h +++ b/source/config.h @@ -34,7 +34,7 @@ #define CONFIG_FILE "config.bin" #define CONFIG_VERSIONMAJOR 1 -#define CONFIG_VERSIONMINOR 12 +#define CONFIG_VERSIONMINOR 13 #define BOOTCFG_NAND BOOTCONFIG(0, 7) #define BOOTCFG_FIRM BOOTCONFIG(3, 7) @@ -58,7 +58,8 @@ enum singleOptions PATCHVERSTRING, SHOWGBABOOT, PATCHACCESS, - PATCHUNITINFO + PATCHUNITINFO, + DISABLEVECTORS }; typedef enum ConfigurationStatus diff --git a/sysmodules/loader/source/patcher.h b/sysmodules/loader/source/patcher.h index fa9454c..8246eaf 100644 --- a/sysmodules/loader/source/patcher.h +++ b/sysmodules/loader/source/patcher.h @@ -31,7 +31,8 @@ enum singleOptions PATCHVERSTRING, SHOWGBABOOT, PATCHACCESS, - PATCHUNITINFO + PATCHUNITINFO, + DISABLEVECTORS }; void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 roSize, u32 dataSize, u32 roAddress, u32 dataAddress); diff --git a/sysmodules/rosalina/kernel_extension/include/config.h b/sysmodules/rosalina/kernel_extension/include/config.h new file mode 100644 index 0000000..fef12b6 --- /dev/null +++ b/sysmodules/rosalina/kernel_extension/include/config.h @@ -0,0 +1,36 @@ +#pragma once + +#include "types.h" + +#define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) +#define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) + +#define CONFIG(a) (((cfwInfo.config >> (a + 17)) & 1) != 0) +#define MULTICONFIG(a) ((cfwInfo.config >> (a * 2 + 7)) & 3) +#define BOOTCONFIG(a, b) ((cfwInfo.config >> a) & b) + +#define BOOTCFG_NAND BOOTCONFIG(0, 7) +#define BOOTCFG_FIRM BOOTCONFIG(3, 7) +#define BOOTCFG_NOFORCEFLAG BOOTCONFIG(6, 1) + +enum multiOptions +{ + DEFAULTEMU = 0, + BRIGHTNESS, + SPLASH, + PIN, + NEWCPU +}; + +enum singleOptions +{ + AUTOBOOTEMU = 0, + USEEMUFIRM, + LOADEXTFIRMSANDMODULES, + PATCHGAMES, + PATCHVERSTRING, + SHOWGBABOOT, + PATCHACCESS, + PATCHUNITINFO, + DISABLEVECTORS +}; diff --git a/sysmodules/rosalina/kernel_extension/include/globals.h b/sysmodules/rosalina/kernel_extension/include/globals.h index c616164..bad4de0 100644 --- a/sysmodules/rosalina/kernel_extension/include/globals.h +++ b/sysmodules/rosalina/kernel_extension/include/globals.h @@ -26,6 +26,7 @@ #pragma once +#include "config.h" #include "kernel.h" extern KRecursiveLock *criticalSectionLock; diff --git a/sysmodules/rosalina/kernel_extension/source/fatalExceptionHandlersMain.c b/sysmodules/rosalina/kernel_extension/source/fatalExceptionHandlersMain.c index 295c898..9d7bd74 100644 --- a/sysmodules/rosalina/kernel_extension/source/fatalExceptionHandlersMain.c +++ b/sysmodules/rosalina/kernel_extension/source/fatalExceptionHandlersMain.c @@ -35,6 +35,8 @@ bool isExceptionFatal(u32 spsr, u32 *regs, u32 index) { + if (CONFIG(DISABLEVECTORS)) return false; + if((spsr & 0x1f) != 0x10) return true; KThread *thread = currentCoreContext->objectContext.currentThread;