summaryrefslogtreecommitdiff
path: root/src/Dolphin/db.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-02-01 18:45:02 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-02-01 18:50:25 -0400
commit9fa0a7f1da1b70bee995f53c6c96c43189018772 (patch)
tree114548896790eaff23cdca84a025281de86bbb51 /src/Dolphin/db.c
parent2ba3289286bbfcf9fcc13fd135d976058d8b6c2e (diff)
global: Import Dolphin SDK
This version comes from the Metroid Prime decompilation project. https://github.com/PrimeDecomp/prime
Diffstat (limited to 'src/Dolphin/db.c')
-rw-r--r--src/Dolphin/db.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Dolphin/db.c b/src/Dolphin/db.c
new file mode 100644
index 0000000..bcf8534
--- /dev/null
+++ b/src/Dolphin/db.c
@@ -0,0 +1,43 @@
+#include <dolphin/db.h>
+#include <dolphin/os.h>
+
+DBInterface* __DBInterface = NULL;
+int DBVerbose;
+
+extern void __DBExceptionStart();
+extern void __DBExceptionEnd();
+extern void __DBExceptionSetNumber();
+
+void DBInit(void) {
+ __DBInterface = (DBInterface*)OSPhysicalToCached(OS_DBINTERFACE_ADDR);
+ __DBInterface->ExceptionDestination = (void (*)())OSCachedToPhysical(__DBExceptionDestination);
+ DBVerbose = TRUE;
+}
+
+void __DBExceptionDestinationAux(void) {
+ u32* contextAddr = (void*)0x00C0;
+ OSContext* context = (OSContext*)OSPhysicalToCached(*contextAddr);
+
+ OSReport("DBExceptionDestination\n");
+ OSDumpContext(context);
+ PPCHalt();
+}
+
+/* clang-format off */
+asm void __DBExceptionDestination(void) {
+ nofralloc
+ mfmsr r3
+ ori r3, r3, 0x10|0x20
+ mtmsr r3
+
+ b __DBExceptionDestinationAux
+}
+/* clang-format on */
+
+BOOL __DBIsExceptionMarked(__OSException exception) {
+ u32 mask = 1 << exception;
+
+ return (BOOL)(__DBInterface->exceptionMask & mask);
+}
+
+void DBPrintf(char* format, ...) {}