From 42d3c32b37082998a769f045610554857dc19f75 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 11 Oct 2018 15:41:05 -0400 Subject: [PATCH] Use FatalType_ErrorReportAndErrorScreen instead of FatalType_ErrorScreen, on pre-3.0.0. FatalType_ErrorScreen is only available with 3.0.0+, this fixes a regression where using fatalSimple on pre-3.0.0 caused a system hang. --- nx/include/switch/services/fatal.h | 5 +++-- nx/source/services/fatal.c | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nx/include/switch/services/fatal.h b/nx/include/switch/services/fatal.h index 38475494..0e145780 100644 --- a/nx/include/switch/services/fatal.h +++ b/nx/include/switch/services/fatal.h @@ -11,18 +11,19 @@ typedef enum { FatalType_ErrorReportAndErrorScreen = 0, FatalType_ErrorReport = 1, - FatalType_ErrorScreen = 2 + FatalType_ErrorScreen = 2 ///< Only available with 3.0.0+. If specified, FatalType_ErrorReportAndErrorScreen will be used instead on pre-3.0.0. } FatalType; /** * @brief Triggers a system fatal error. * @param err[in] Result code to throw. * @note This function does not return. + * @note This uses \ref fatalWithType with \ref FatalType_ErrorScreen internally. */ void NORETURN fatalSimple(Result err); /** - * @brief Triggers a system fatal error with a custom FatalType. + * @brief Triggers a system fatal error with a custom \ref FatalType. * @param err[in] Result code to throw. * @param err[in] Type of fatal error to throw. * @note This function may not return, depending on \ref FatalType. diff --git a/nx/source/services/fatal.c b/nx/source/services/fatal.c index 1c812864..14f2ef7c 100644 --- a/nx/source/services/fatal.c +++ b/nx/source/services/fatal.c @@ -17,6 +17,9 @@ void NORETURN fatalSimple(Result err) { void fatalWithType(Result err, FatalType type) { Result rc = 0; + //Only 3.0.0+ supports FatalType_ErrorScreen, when specified on pre-3.0.0 use FatalType_ErrorReportAndErrorScreen instead. + if (type == FatalType_ErrorScreen && !kernelAbove300()) type = FatalType_ErrorReportAndErrorScreen; + if (detectDebugger()) { svcBreak(0x80000000, err, 0); }