summaryrefslogtreecommitdiff
path: root/src/Dolphin/db.c
blob: bcf8534d4f49e4aa25b22e225a3b7812e5675056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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, ...) {}