mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-07 00:14:38 +00:00
Format all src C files
This commit is contained in:
parent
251aea64ab
commit
8cfe7cce9f
652 changed files with 12488 additions and 19093 deletions
296
src/code/fault.c
296
src/code/fault.c
|
@ -3,9 +3,8 @@
|
|||
#include <alloca.h>
|
||||
#include <vt.h>
|
||||
|
||||
//data
|
||||
const char* sExceptionNames[] =
|
||||
{
|
||||
// data
|
||||
const char* sExceptionNames[] = {
|
||||
"Interrupt",
|
||||
"TLB modification",
|
||||
"TLB exception on load",
|
||||
|
@ -32,7 +31,7 @@ const char* sExceptionNames[] =
|
|||
"Inexact operation",
|
||||
};
|
||||
|
||||
//bss
|
||||
// bss
|
||||
FaultThreadStruct* sFaultStructPtr;
|
||||
u8 sFaultIsWaitingForInput;
|
||||
char sFaultStack[0x600];
|
||||
|
@ -41,23 +40,22 @@ FaultThreadStruct gFaultStruct;
|
|||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/pad_800D3F10.s")
|
||||
|
||||
void Fault_SleepImpl(u32 duration)
|
||||
{
|
||||
void Fault_SleepImpl(u32 duration) {
|
||||
u64 value = (duration * OS_CPU_COUNTER) / 1000ull;
|
||||
func_800FF3A0(value);
|
||||
}
|
||||
|
||||
void Fault_ClientProcessThread(FaultClientContext* ctx)
|
||||
{
|
||||
if (ctx->callback)
|
||||
void Fault_ClientProcessThread(FaultClientContext* ctx) {
|
||||
if (ctx->callback) {
|
||||
ctx->ret = ctx->callback(ctx->param0, ctx->param1);
|
||||
}
|
||||
|
||||
if (ctx->queue)
|
||||
if (ctx->queue) {
|
||||
osSendMesg(ctx->queue, ctx->msg, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Fault_ProcessClientContext(FaultClientContext* ctx)
|
||||
{
|
||||
void Fault_ProcessClientContext(FaultClientContext* ctx) {
|
||||
OSMesgQueue queue;
|
||||
OSMesg msg;
|
||||
OSMesg recMsg;
|
||||
|
@ -72,27 +70,23 @@ void Fault_ProcessClientContext(FaultClientContext* ctx)
|
|||
ctx->queue = &queue;
|
||||
ctx->msg = NULL;
|
||||
|
||||
if (sFaultStructPtr->currClientThreadSp != 0)
|
||||
{
|
||||
if (sFaultStructPtr->currClientThreadSp != 0) {
|
||||
thread = alloca(sizeof(OSThread));
|
||||
osCreateThread(thread, 2, Fault_ClientProcessThread, ctx, sFaultStructPtr->currClientThreadSp, 0x7E);
|
||||
osStartThread(thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Fault_ClientProcessThread(ctx);
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
osSetTimer(&timer, OS_USEC_TO_CYCLES(1000000), 0, &queue, (OSMesg)timerMsgVal);
|
||||
osRecvMesg(&queue, &recMsg, 1);
|
||||
|
||||
if (recMsg != (OSMesg)666)
|
||||
if (recMsg != (OSMesg)666) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!sFaultIsWaitingForInput)
|
||||
{
|
||||
if (!sFaultIsWaitingForInput) {
|
||||
ctx->ret = -1;
|
||||
break;
|
||||
}
|
||||
|
@ -100,15 +94,13 @@ void Fault_ProcessClientContext(FaultClientContext* ctx)
|
|||
|
||||
osStopTimer(&timer);
|
||||
|
||||
if (thread != NULL)
|
||||
{
|
||||
if (thread != NULL) {
|
||||
osStopThread(thread);
|
||||
osDestroyThread(thread);
|
||||
}
|
||||
}
|
||||
|
||||
u32 Fault_ProcessClient(u32 callback, u32 param0, u32 param1)
|
||||
{
|
||||
u32 Fault_ProcessClient(u32 callback, u32 param0, u32 param1) {
|
||||
FaultClientContext a;
|
||||
a.callback = callback;
|
||||
a.param0 = param0;
|
||||
|
@ -120,8 +112,7 @@ u32 Fault_ProcessClient(u32 callback, u32 param0, u32 param1)
|
|||
|
||||
#ifdef NON_MATCHING
|
||||
// minor ordering differences
|
||||
void Fault_AddClient(FaultClient* client, void* callback, void* param0, void* param1)
|
||||
{
|
||||
void Fault_AddClient(FaultClient* client, void* callback, void* param0, void* param1) {
|
||||
OSIntMask mask;
|
||||
u32 alreadyExists;
|
||||
FaultClient* iter;
|
||||
|
@ -130,10 +121,8 @@ void Fault_AddClient(FaultClient* client, void* callback, void* param0, void* pa
|
|||
mask = osSetIntMask(1);
|
||||
|
||||
iter = sFaultStructPtr->clients;
|
||||
while (iter)
|
||||
{
|
||||
if (iter == client)
|
||||
{
|
||||
while (iter) {
|
||||
if (iter == client) {
|
||||
alreadyExists = true;
|
||||
goto end;
|
||||
}
|
||||
|
@ -188,8 +177,9 @@ void Fault_RemoveClient(FaultClient* client) {
|
|||
|
||||
osSetIntMask(mask);
|
||||
|
||||
if (listIsEmpty)
|
||||
if (listIsEmpty) {
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "fault_RemoveClient: %08x リスト不整合です\n" VT_RST, client);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_AddAddrConvClient.s")
|
||||
|
@ -228,24 +218,23 @@ void Fault_RemoveAddrConvClient(FaultAddrConvClient* client) {
|
|||
osSetIntMask(mask);
|
||||
|
||||
if (listIsEmpty) {
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "fault_AddressConverterRemoveClient: %08x は既にリスト中にある\n" VT_RST, client);
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "fault_AddressConverterRemoveClient: %08x は既にリスト中にある\n" VT_RST,
|
||||
client);
|
||||
}
|
||||
}
|
||||
|
||||
u32 Fault_ConvertAddress(FaultAddrConvClient* client)
|
||||
{
|
||||
u32 Fault_ConvertAddress(FaultAddrConvClient* client) {
|
||||
u32 ret;
|
||||
FaultAddrConvClient* iter = sFaultStructPtr->addrConvClients;
|
||||
|
||||
while(iter)
|
||||
{
|
||||
if (iter->callback)
|
||||
{
|
||||
while (iter) {
|
||||
if (iter->callback) {
|
||||
ret = Fault_ProcessClient(iter->callback, client, iter->param);
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
Fault_RemoveAddrConvClient(iter);
|
||||
else if (ret)
|
||||
} else if (ret) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
iter = iter->next;
|
||||
}
|
||||
|
@ -253,35 +242,29 @@ u32 Fault_ConvertAddress(FaultAddrConvClient* client)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Fault_Sleep(u32 duration)
|
||||
{
|
||||
void Fault_Sleep(u32 duration) {
|
||||
Fault_SleepImpl(duration);
|
||||
}
|
||||
|
||||
void Fault_PadCallback(Input* input)
|
||||
{
|
||||
//BUG: this function is not called correctly and thus will crash from reading a bad pointer at 0x800C7E4C
|
||||
void Fault_PadCallback(Input* input) {
|
||||
// BUG: this function is not called correctly and thus will crash from reading a bad pointer at 0x800C7E4C
|
||||
func_800C7E08(input, 0);
|
||||
}
|
||||
|
||||
void Fault_UpdatePadImpl()
|
||||
{
|
||||
void Fault_UpdatePadImpl() {
|
||||
sFaultStructPtr->padCallback(&sFaultStructPtr->padInput);
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// ordering differences and possibly regalloc
|
||||
u32 Fault_WaitForInputImpl()
|
||||
{
|
||||
u32 Fault_WaitForInputImpl() {
|
||||
u16 kDown;
|
||||
u32 exitDebugger;
|
||||
s32 count = 600;
|
||||
Input* curInput = &sFaultStructPtr->padInput;
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
while (true) {
|
||||
Fault_Sleep(0x10);
|
||||
Fault_UpdatePadImpl();
|
||||
|
||||
|
@ -316,71 +299,63 @@ u32 Fault_WaitForInputImpl()
|
|||
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_WaitForInputImpl.s")
|
||||
#endif
|
||||
|
||||
void Fault_WaitForInput()
|
||||
{
|
||||
void Fault_WaitForInput() {
|
||||
sFaultIsWaitingForInput = 1;
|
||||
Fault_WaitForInputImpl();
|
||||
sFaultIsWaitingForInput = 0;
|
||||
}
|
||||
|
||||
void Fault_DrawRec(s32 x, s32 y, s32 w, s32 h, u16 color)
|
||||
{
|
||||
void Fault_DrawRec(s32 x, s32 y, s32 w, s32 h, u16 color) {
|
||||
FaultDrawer_DrawRecImpl(x, y, x + w - 1, y + h - 1, color);
|
||||
}
|
||||
|
||||
void Fault_FillScreenBlack()
|
||||
{
|
||||
void Fault_FillScreenBlack() {
|
||||
FaultDrawer_SetForeColor(0xFFFF);
|
||||
FaultDrawer_SetBackColor(1);
|
||||
FaultDrawer_FillScreen();
|
||||
FaultDrawer_SetBackColor(0);
|
||||
}
|
||||
|
||||
void Fault_FillScreenRed()
|
||||
{
|
||||
void Fault_FillScreenRed() {
|
||||
FaultDrawer_SetForeColor(0xFFFF);
|
||||
FaultDrawer_SetBackColor(0xF001);
|
||||
FaultDrawer_FillScreen();
|
||||
FaultDrawer_SetBackColor(0);
|
||||
}
|
||||
|
||||
void Fault_DrawCornerRec(u16 color)
|
||||
{
|
||||
void Fault_DrawCornerRec(u16 color) {
|
||||
Fault_DrawRec(0x16, 0x10, 8, 1, color);
|
||||
}
|
||||
|
||||
void Fault_PrintFReg(s32 idx, f32* value)
|
||||
{
|
||||
void Fault_PrintFReg(s32 idx, f32* value) {
|
||||
u32 raw = *(u32*)value;
|
||||
s32 v0 = ((raw & 0x7f800000) >> 0x17) - 0x7f;
|
||||
|
||||
if ((v0 >= -0x7e && v0 < 0x80) || raw == 0)
|
||||
if ((v0 >= -0x7e && v0 < 0x80) || raw == 0) {
|
||||
FaultDrawer_Printf("F%02d:%14.7e ", idx, *value);
|
||||
else
|
||||
} else {
|
||||
FaultDrawer_Printf("F%02d: %08x(16) ", idx, raw);
|
||||
}
|
||||
}
|
||||
|
||||
void Fault_LogFReg(s32 idx, f32* value)
|
||||
{
|
||||
void Fault_LogFReg(s32 idx, f32* value) {
|
||||
u32 raw = *(u32*)value;
|
||||
s32 v0 = ((raw & 0x7f800000) >> 0x17) - 0x7f;
|
||||
|
||||
if ((v0 >= -0x7e && v0 < 0x80) || raw == 0)
|
||||
if ((v0 >= -0x7e && v0 < 0x80) || raw == 0) {
|
||||
osSyncPrintf("F%02d:%14.7e ", idx, *value);
|
||||
else
|
||||
} else {
|
||||
osSyncPrintf("F%02d: %08x(16) ", idx, *(u32*)value);
|
||||
}
|
||||
}
|
||||
|
||||
void Fault_PrintFPCR(u32 value)
|
||||
{
|
||||
void Fault_PrintFPCR(u32 value) {
|
||||
s32 i;
|
||||
u32 flag = 0x20000;
|
||||
FaultDrawer_Printf("FPCSR:%08xH ", value);
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (value & flag)
|
||||
{
|
||||
FaultDrawer_Printf("(%s)", sExceptionNames[i+18]);
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (value & flag) {
|
||||
FaultDrawer_Printf("(%s)", sExceptionNames[i + 18]);
|
||||
break;
|
||||
}
|
||||
flag >>= 1;
|
||||
|
@ -388,30 +363,28 @@ void Fault_PrintFPCR(u32 value)
|
|||
FaultDrawer_Printf("\n");
|
||||
}
|
||||
|
||||
void Fault_LogFPCR(u32 value)
|
||||
{
|
||||
void Fault_LogFPCR(u32 value) {
|
||||
s32 i;
|
||||
u32 flag = 0x20000;
|
||||
osSyncPrintf("FPCSR:%08xH ", value);
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (value & flag)
|
||||
{
|
||||
osSyncPrintf("(%s)\n", sExceptionNames[i+18]);
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (value & flag) {
|
||||
osSyncPrintf("(%s)\n", sExceptionNames[i + 18]);
|
||||
break;
|
||||
}
|
||||
flag >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Fault_PrintThreadContext(OSThread* t)
|
||||
{
|
||||
__OSThreadContext *ctx;
|
||||
s32 causeStrIdx = (s32) ((((u32) t->context.cause >> 2) & 0x1f) << 0x10) >> 0x10;
|
||||
if (causeStrIdx == 0x17)
|
||||
void Fault_PrintThreadContext(OSThread* t) {
|
||||
__OSThreadContext* ctx;
|
||||
s32 causeStrIdx = (s32)((((u32)t->context.cause >> 2) & 0x1f) << 0x10) >> 0x10;
|
||||
if (causeStrIdx == 0x17) {
|
||||
causeStrIdx = 0x10;
|
||||
if (causeStrIdx == 0x1f)
|
||||
}
|
||||
if (causeStrIdx == 0x1f) {
|
||||
causeStrIdx = 0x11;
|
||||
}
|
||||
|
||||
FaultDrawer_FillScreen();
|
||||
FaultDrawer_SetCharPad(-2, 4);
|
||||
|
@ -462,14 +435,15 @@ void Fault_PrintThreadContext(OSThread* t)
|
|||
FaultDrawer_SetCharPad(0, 0);
|
||||
}
|
||||
|
||||
void Fault_LogThreadContext(OSThread* t)
|
||||
{
|
||||
__OSThreadContext *ctx;
|
||||
s32 causeStrIdx = (s32) ((((u32) t->context.cause >> 2) & 0x1f) << 0x10) >> 0x10;
|
||||
if (causeStrIdx == 0x17)
|
||||
void Fault_LogThreadContext(OSThread* t) {
|
||||
__OSThreadContext* ctx;
|
||||
s32 causeStrIdx = (s32)((((u32)t->context.cause >> 2) & 0x1f) << 0x10) >> 0x10;
|
||||
if (causeStrIdx == 0x17) {
|
||||
causeStrIdx = 0x10;
|
||||
if (causeStrIdx == 0x1f)
|
||||
}
|
||||
if (causeStrIdx == 0x1f) {
|
||||
causeStrIdx = 0x11;
|
||||
}
|
||||
|
||||
ctx = &t->context;
|
||||
osSyncPrintf("\n");
|
||||
|
@ -515,26 +489,23 @@ void Fault_LogThreadContext(OSThread* t)
|
|||
osSyncPrintf("\n");
|
||||
}
|
||||
|
||||
OSThread* Fault_FindFaultedThread()
|
||||
{
|
||||
OSThread* Fault_FindFaultedThread() {
|
||||
OSThread* iter = func_80104140();
|
||||
while (iter->priority != -1)
|
||||
{
|
||||
if (iter->priority > 0 && iter->priority < 0x7f && (iter->flags & 3))
|
||||
while (iter->priority != -1) {
|
||||
if (iter->priority > 0 && iter->priority < 0x7f && (iter->flags & 3)) {
|
||||
return iter;
|
||||
}
|
||||
iter = iter->tlnext;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Fault_Wait5Seconds(void)
|
||||
{
|
||||
OSTime start[2]; //to make the function allocate 0x28 bytes of stack instead of 0x20
|
||||
void Fault_Wait5Seconds(void) {
|
||||
OSTime start[2]; // to make the function allocate 0x28 bytes of stack instead of 0x20
|
||||
start[0] = osGetTime();
|
||||
do
|
||||
{
|
||||
do {
|
||||
Fault_Sleep(0x10);
|
||||
} while ((osGetTime() - start[0]) < OS_USEC_TO_CYCLES(5000000)+1); //0xdf84759
|
||||
} while ((osGetTime() - start[0]) < OS_USEC_TO_CYCLES(5000000) + 1); // 0xdf84759
|
||||
|
||||
sFaultStructPtr->faultActive = true;
|
||||
}
|
||||
|
@ -561,7 +532,7 @@ void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3) {
|
|||
Fault_FillScreenBlack();
|
||||
FaultDrawer_SetCharPad(-2, 0);
|
||||
|
||||
FaultDrawer_DrawText(0x24, 0x12, "%s %08x", title? title : "PrintDump", alignedAddr);
|
||||
FaultDrawer_DrawText(0x24, 0x12, "%s %08x", title ? title : "PrintDump", alignedAddr);
|
||||
if (alignedAddr >= (u32*)0x80000000 && alignedAddr < (u32*)0xC0000000) {
|
||||
for (y = 0x1C; y != 0xE2; y += 9) {
|
||||
FaultDrawer_DrawText(0x18, y, "%06x", writeAddr);
|
||||
|
@ -577,15 +548,13 @@ void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3) {
|
|||
#ifdef NON_MATCHING
|
||||
// saved register and stack usage differences
|
||||
// possibly some minor ordering and regalloc differences
|
||||
void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1)
|
||||
{
|
||||
void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) {
|
||||
Input* curInput = &sFaultStructPtr->padInput;
|
||||
u32 addr = pc;
|
||||
s32 count;
|
||||
s32 off;
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
if (addr < 0x80000000)
|
||||
addr = 0x80000000;
|
||||
if (addr > 0x807fff00)
|
||||
|
@ -595,8 +564,7 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1)
|
|||
Fault_DrawMemDumpPage("Dump", (u32*)addr, 0);
|
||||
count = 600;
|
||||
|
||||
while (sFaultStructPtr->faultActive)
|
||||
{
|
||||
while (sFaultStructPtr->faultActive) {
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
|
@ -607,8 +575,7 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1)
|
|||
sFaultStructPtr->faultActive = false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
Fault_Sleep(0x10);
|
||||
Fault_UpdatePadImpl();
|
||||
} while (curInput->padPressed == 0);
|
||||
|
@ -652,8 +619,7 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1)
|
|||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_LogStackTrace.s")
|
||||
|
||||
void Fault_ResumeThread(OSThread* t)
|
||||
{
|
||||
void Fault_ResumeThread(OSThread* t) {
|
||||
t->context.cause = 0;
|
||||
t->context.fpcsr = 0;
|
||||
t->context.pc += 4;
|
||||
|
@ -663,39 +629,39 @@ void Fault_ResumeThread(OSThread* t)
|
|||
osStartThread(t);
|
||||
}
|
||||
|
||||
void Fault_CommitFB()
|
||||
{
|
||||
void Fault_CommitFB() {
|
||||
u16* fb;
|
||||
osViSetYScale(1.0f);
|
||||
osViSetMode(&osViModeNtscLan1);
|
||||
osViSetSpecialFeatures(0x42); //gama_disable|dither_fliter_enable_aa_mode3_disable
|
||||
osViSetSpecialFeatures(0x42); // gama_disable|dither_fliter_enable_aa_mode3_disable
|
||||
osViBlack(false);
|
||||
|
||||
if (sFaultStructPtr->fb)
|
||||
if (sFaultStructPtr->fb) {
|
||||
fb = sFaultStructPtr->fb;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fb = (u16*)osViGetNextFramebuffer();
|
||||
if ((u32)fb == 0x80000000)
|
||||
if ((u32)fb == 0x80000000) {
|
||||
fb = (u16*)((osMemSize | 0x80000000) - 0x25800);
|
||||
}
|
||||
}
|
||||
|
||||
osViSwapBuffer(fb);
|
||||
FaultDrawer_SetDrawerFB(fb, 0x140, 0xf0);
|
||||
}
|
||||
|
||||
void Fault_ProcessClients(void)
|
||||
{
|
||||
void Fault_ProcessClients(void) {
|
||||
FaultClient* iter = sFaultStructPtr->clients;
|
||||
s32 idx = 0;
|
||||
|
||||
while(iter)
|
||||
{
|
||||
if (iter->callback)
|
||||
{
|
||||
while (iter) {
|
||||
if (iter->callback) {
|
||||
Fault_FillScreenBlack();
|
||||
FaultDrawer_SetCharPad(-2, 0);
|
||||
FaultDrawer_Printf("\x1a""8CallBack (%d) %08x %08x %08x\n""\x1a""7", idx++, iter, iter->param1, iter->param2);
|
||||
FaultDrawer_Printf("\x1a"
|
||||
"8CallBack (%d) %08x %08x %08x\n"
|
||||
"\x1a"
|
||||
"7",
|
||||
idx++, iter, iter->param1, iter->param2);
|
||||
FaultDrawer_SetCharPad(0, 0);
|
||||
Fault_ProcessClient(iter->callback, iter->param1, iter->param2);
|
||||
Fault_WaitForInput();
|
||||
|
@ -705,45 +671,34 @@ void Fault_ProcessClients(void)
|
|||
}
|
||||
}
|
||||
|
||||
void Fault_UpdatePad()
|
||||
{
|
||||
void Fault_UpdatePad() {
|
||||
Fault_UpdatePadImpl();
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// saved register and stack usage differences
|
||||
void Fault_ThreadEntry(void* arg)
|
||||
{
|
||||
void Fault_ThreadEntry(void* arg) {
|
||||
OSThread* faultedThread;
|
||||
OSMesg msg;
|
||||
|
||||
osSetEventMesg(OS_EVENT_CPU_BREAK, &sFaultStructPtr->queue, 1);
|
||||
osSetEventMesg(OS_EVENT_FAULT, &sFaultStructPtr->queue, 2);
|
||||
|
||||
while (true)
|
||||
{
|
||||
do
|
||||
{
|
||||
while (true) {
|
||||
do {
|
||||
osRecvMesg(&sFaultStructPtr->queue, &msg, 1);
|
||||
|
||||
if (msg == (OSMesg)1)
|
||||
{
|
||||
if (msg == (OSMesg)1) {
|
||||
sFaultStructPtr->msgId = 1;
|
||||
osSyncPrintf("フォルトマネージャ:OS_EVENT_CPU_BREAKを受信しました\n");
|
||||
}
|
||||
else if (1 && msg == (OSMesg)2)
|
||||
{
|
||||
} else if (1 && msg == (OSMesg)2) {
|
||||
sFaultStructPtr->msgId = 2;
|
||||
osSyncPrintf("フォルトマネージャ:OS_EVENT_FAULTを受信しました\n");
|
||||
}
|
||||
else if (msg == (OSMesg)3)
|
||||
{
|
||||
} else if (msg == (OSMesg)3) {
|
||||
Fault_UpdatePad();
|
||||
faultedThread = NULL;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sFaultStructPtr->msgId = 3;
|
||||
osSyncPrintf("フォルトマネージャ:不明なメッセージを受信しました\n");
|
||||
}
|
||||
|
@ -751,8 +706,7 @@ void Fault_ThreadEntry(void* arg)
|
|||
faultedThread = __osGetCurrFaultedThread();
|
||||
osSyncPrintf("__osGetCurrFaultedThread()=%08x\n", faultedThread);
|
||||
|
||||
if (faultedThread == NULL)
|
||||
{
|
||||
if (faultedThread == NULL) {
|
||||
faultedThread = Fault_FindFaultedThread();
|
||||
osSyncPrintf("FindFaultedThread()=%08x\n", faultedThread);
|
||||
}
|
||||
|
@ -769,8 +723,7 @@ void Fault_ThreadEntry(void* arg)
|
|||
|
||||
if (sFaultStructPtr->faultActive)
|
||||
Fault_Wait5Seconds();
|
||||
else
|
||||
{
|
||||
else {
|
||||
Fault_DrawCornerRec(0xF801);
|
||||
Fault_WaitForButtonCombo();
|
||||
}
|
||||
|
@ -779,8 +732,7 @@ void Fault_ThreadEntry(void* arg)
|
|||
FaultDrawer_SetForeColor(0xFFFF);
|
||||
FaultDrawer_SetBackColor(0);
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
Fault_PrintThreadContext(faultedThread);
|
||||
Fault_LogThreadContext(faultedThread);
|
||||
Fault_WaitForInput();
|
||||
|
@ -799,10 +751,7 @@ void Fault_ThreadEntry(void* arg)
|
|||
Fault_WaitForInput();
|
||||
} while (!sFaultStructPtr->exitDebugger);
|
||||
|
||||
while (!sFaultStructPtr->exitDebugger)
|
||||
{
|
||||
|
||||
}
|
||||
while (!sFaultStructPtr->exitDebugger) {}
|
||||
|
||||
Fault_ResumeThread(faultedThread);
|
||||
}
|
||||
|
@ -811,14 +760,12 @@ void Fault_ThreadEntry(void* arg)
|
|||
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_ThreadEntry.s")
|
||||
#endif
|
||||
|
||||
void Fault_SetFB(void* fb, u16 w, u16 h)
|
||||
{
|
||||
void Fault_SetFB(void* fb, u16 w, u16 h) {
|
||||
sFaultStructPtr->fb = fb;
|
||||
FaultDrawer_SetDrawerFB(fb, w, h);
|
||||
}
|
||||
|
||||
void Fault_Start(void)
|
||||
{
|
||||
void Fault_Start(void) {
|
||||
sFaultStructPtr = &gFaultStruct;
|
||||
bzero(sFaultStructPtr, sizeof(FaultThreadStruct));
|
||||
FaultDrawer_SetDefault();
|
||||
|
@ -832,13 +779,12 @@ void Fault_Start(void)
|
|||
sFaultStructPtr->faultActive = false;
|
||||
gFaultStruct.faultHandlerEnabled = true;
|
||||
osCreateMesgQueue(&sFaultStructPtr->queue, &sFaultStructPtr->msg, 1);
|
||||
StackCheck_Init(sFaultThreadInfo, &sFaultStack, sFaultStack+sizeof(sFaultStack), 0, 0x100, "fault");
|
||||
StackCheck_Init(sFaultThreadInfo, &sFaultStack, sFaultStack + sizeof(sFaultStack), 0, 0x100, "fault");
|
||||
osCreateThread(&sFaultStructPtr->thread, 2, &Fault_ThreadEntry, 0, sFaultThreadInfo, 0x7f);
|
||||
osStartThread(&sFaultStructPtr->thread);
|
||||
}
|
||||
|
||||
void Fault_HangupFaultClient(const char* arg0, const char* arg1)
|
||||
{
|
||||
void Fault_HangupFaultClient(const char* arg0, const char* arg1) {
|
||||
osSyncPrintf("HungUp on Thread %d\n", osGetThreadId(0));
|
||||
osSyncPrintf("%s\n", arg0 ? arg0 : "(NULL)");
|
||||
osSyncPrintf("%s\n", arg1 ? arg1 : "(NULL)");
|
||||
|
@ -847,16 +793,14 @@ void Fault_HangupFaultClient(const char* arg0, const char* arg1)
|
|||
FaultDrawer_Printf("%s\n", arg1 ? arg1 : "(NULL)");
|
||||
}
|
||||
|
||||
void Fault_AddHungupAndCrashImpl(const char* arg0, const char* arg1)
|
||||
{
|
||||
void Fault_AddHungupAndCrashImpl(const char* arg0, const char* arg1) {
|
||||
FaultClient client;
|
||||
char padd[4];
|
||||
Fault_AddClient(&client, &Fault_HangupFaultClient, arg0, arg1);
|
||||
*(u32*)0x11111111 = 0; //trigger an exception
|
||||
*(u32*)0x11111111 = 0; // trigger an exception
|
||||
}
|
||||
|
||||
void Fault_AddHungupAndCrash(const char* filename, u32 line)
|
||||
{
|
||||
void Fault_AddHungupAndCrash(const char* filename, u32 line) {
|
||||
char msg[256];
|
||||
sprintf(msg, "HungUp %s:%d", filename, line);
|
||||
Fault_AddHungupAndCrashImpl(msg, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue