Match and link db

Former-commit-id: 2806b45058
This commit is contained in:
Phillip Stephens 2022-10-13 09:33:30 -07:00
parent 5334ac0aa1
commit f886907c07
5 changed files with 58 additions and 12 deletions

View File

@ -151,6 +151,8 @@ $(DTK_FILES): MWCC_VERSION := 1.2.5
$(DTK_FILES): CFLAGS := $(CFLAGS_BASE) $(DTK_FILES): CFLAGS := $(CFLAGS_BASE)
$(SI_FILES): MWCC_VERSION := 1.2.5 $(SI_FILES): MWCC_VERSION := 1.2.5
$(SI_FILES): CFLAGS := $(CFLAGS_BASE) $(SI_FILES): CFLAGS := $(CFLAGS_BASE)
$(DB_FILES): MWCC_VERSION := 1.2.5
$(DB_FILES): CFLAGS := $(CFLAGS_BASE)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Recipes # Recipes

View File

@ -731,7 +731,9 @@ LIBS = [
"lib": "db", "lib": "db",
"mwcc_version": "1.2.5", "mwcc_version": "1.2.5",
"cflags": "$cflags_base", "cflags": "$cflags_base",
"objects": ["Dolphin/db"], "objects": [
["Dolphin/db", True],
],
}, },
{ {
"lib": "dsp", "lib": "dsp",

View File

@ -7,18 +7,17 @@
extern "C" { extern "C" {
#endif #endif
#define ExceptionHookDestination 0x80000048 #define OS_DBINTERFACE_ADDR 0x00000040
#define IsDebuggerPresent 0x80000040
// static int __DBInterface; typedef struct DBInterface
{
u32 bPresent;
u32 exceptionMask;
void (*ExceptionDestination) ( void );
void *exceptionReturn;
} DBInterface;
struct DBInterface { extern DBInterface* __DBInterface;
u8 filler0[4];
u32 unk4;
};
static struct DBInterface* __DBInterface;
static int DBVerbose;
void DBInit(void); void DBInit(void);
void DBInitComm(int* inputFlagPtr, int* mtrCallback); void DBInitComm(int* inputFlagPtr, int* mtrCallback);

View File

@ -643,7 +643,7 @@ BASE_FILES :=\
$(BUILD_DIR)/src/Dolphin/PPCArch.o\ $(BUILD_DIR)/src/Dolphin/PPCArch.o\
DB_FILES :=\ DB_FILES :=\
$(BUILD_DIR)/asm/Dolphin/db.o\ $(BUILD_DIR)/src/Dolphin/db.ep.o\
DSP_FILES :=\ DSP_FILES :=\
$(BUILD_DIR)/asm/Dolphin/dsp/dsp.o\ $(BUILD_DIR)/asm/Dolphin/dsp/dsp.o\

43
src/Dolphin/db.c Normal file
View File

@ -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, ...) {}