diff --git a/thermosphere/src/exceptions.c b/thermosphere/src/exceptions.c
index ad2fcc4e6..cb25a86ba 100644
--- a/thermosphere/src/exceptions.c
+++ b/thermosphere/src/exceptions.c
@@ -14,10 +14,10 @@
* along with this program. If not, see .
*/
-#include "exceptions.h"
+#include "hvc.h"
#include "log.h"
-static void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
+void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
{
#ifndef NDEBUG
for (u32 i = 0; i < 30; i += 2) {
@@ -38,8 +38,17 @@ static void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
void handleLowerElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
{
- serialLog("Lower EL sync exception, EC = 0x%02llx IL=%llu ISS=0x%06llx\r\n", (u64)esr.ec, esr.il, esr.iss);
- dumpStackFrame(frame, false);
+
+ switch (esr.ec) {
+ case Exception_HypervisorCallA64:
+ case Exception_HypervisorCallA32:
+ handleHypercall(frame, esr);
+ break;
+ default:
+ serialLog("Lower EL sync exception, EC = 0x%02llx IL=%llu ISS=0x%06llx\r\n", (u64)esr.ec, esr.il, esr.iss);
+ dumpStackFrame(frame, false);
+ break;
+ }
}
void handleSameElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
diff --git a/thermosphere/src/exceptions.h b/thermosphere/src/exceptions.h
index 7af350af5..fd71d9a30 100644
--- a/thermosphere/src/exceptions.h
+++ b/thermosphere/src/exceptions.h
@@ -78,3 +78,5 @@ typedef struct ExceptionSyndromeRegister {
ExceptionClass ec : 6; // Exception Class
u32 res0 : 32;
} ExceptionSyndromeRegister;
+
+void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl);
diff --git a/thermosphere/src/hvc.c b/thermosphere/src/hvc.c
new file mode 100644
index 000000000..300d2f75f
--- /dev/null
+++ b/thermosphere/src/hvc.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2019 Atmosphère-NX
+ *
+ * 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 .
+ */
+
+#include "hvc.h"
+#include "log.h"
+
+void handleHypercall(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
+{
+ u32 id = esr.iss;
+ switch (id) {
+ default:
+ serialLog("Unhandled hypercall: 0x%x.\r\n");
+ dumpStackFrame(frame, false);
+ break;
+ }
+}
diff --git a/thermosphere/src/hvc.h b/thermosphere/src/hvc.h
new file mode 100644
index 000000000..f26ffb045
--- /dev/null
+++ b/thermosphere/src/hvc.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2019 Atmosphère-NX
+ *
+ * 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 .
+ */
+
+#pragma once
+#include "exceptions.h"
+
+void handleHypercall(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr);
diff --git a/thermosphere/src/utils.h b/thermosphere/src/utils.h
index 3685f6a98..a8e565508 100644
--- a/thermosphere/src/utils.h
+++ b/thermosphere/src/utils.h
@@ -105,3 +105,7 @@ static inline u32 get_spsr(void) {
static inline bool check_32bit_additive_overflow(u32 a, u32 b) {
return __builtin_add_overflow_p(a, b, (u32)0);
}
+
+static inline void panic(void) {
+ for (;;);
+}