2021-08-21 19:10:13 +01:00
|
|
|
/*
|
2021-10-04 20:59:10 +01:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2021-08-21 19:10:13 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include <exosphere.hpp>
|
|
|
|
#include "fusee_exception_handler.hpp"
|
2021-09-06 04:57:04 +01:00
|
|
|
#include "fusee_fatal.hpp"
|
2021-08-21 19:10:13 +01:00
|
|
|
|
|
|
|
namespace ams::nxboot {
|
|
|
|
|
|
|
|
NORETURN void ExceptionHandlerImpl(s32 which, u32 lr, u32 svc_lr) {
|
2021-09-06 04:57:04 +01:00
|
|
|
ShowFatalError("Exception: which=%" PRId32 ", lr=%p, svc_lr=%p\n", which, reinterpret_cast<void *>(lr), reinterpret_cast<void *>(svc_lr));
|
2021-08-21 19:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ams::diag {
|
|
|
|
|
|
|
|
NORETURN void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
2021-09-06 04:57:04 +01:00
|
|
|
AMS_UNUSED(file, line, func, expr, format);
|
|
|
|
|
|
|
|
u32 lr;
|
|
|
|
__asm__ __volatile__("mov %0, lr" : "=r"(lr) :: "memory");
|
|
|
|
nxboot::ShowFatalError("Abort called, lr=%p, value=%" PRIx64 "\n", reinterpret_cast<void *>(lr), value);
|
2021-08-21 19:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NORETURN void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
2021-09-06 04:57:04 +01:00
|
|
|
AMS_UNUSED(file, line, func, expr);
|
|
|
|
|
|
|
|
u32 lr;
|
|
|
|
__asm__ __volatile__("mov %0, lr" : "=r"(lr) :: "memory");
|
|
|
|
nxboot::ShowFatalError("Abort called, lr=%p, value=%" PRIx64 "\n", reinterpret_cast<void *>(lr), value);
|
2021-08-21 19:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NORETURN void AbortImpl() {
|
2021-09-06 04:57:04 +01:00
|
|
|
u32 lr;
|
|
|
|
__asm__ __volatile__("mov %0, lr" : "=r"(lr) :: "memory");
|
|
|
|
nxboot::ShowFatalError("Abort called, lr=%p\n", reinterpret_cast<void *>(lr));
|
2021-08-21 19:10:13 +01:00
|
|
|
}
|
|
|
|
|
2021-09-06 04:57:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ams::result::impl {
|
|
|
|
|
|
|
|
NORETURN void OnResultAbort(const char *file, int line, const char *func, const char *expr, Result result) {
|
|
|
|
::ams::diag::AbortImpl(file, line, func, expr, result.GetValue(), "Result Abort: 2%03" PRId32 "-%04" PRId32 "", result.GetModule(), result.GetDescription());
|
|
|
|
AMS_INFINITE_LOOP();
|
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
NORETURN void OnResultAbort(Result result) {
|
|
|
|
OnResultAbort("", 0, "", "", result);
|
|
|
|
}
|
|
|
|
|
2021-08-21 19:10:13 +01:00
|
|
|
}
|