diff --git a/asm/os/__osException.s b/asm/os/__osException.s index 97181ebb8..12705b941 100644 --- a/asm/os/__osException.s +++ b/asm/os/__osException.s @@ -361,8 +361,8 @@ glabel L800D1668 /* 0D22B0 800D16B0 AD3A0000 */ sw $k0, ($t1) .L800D16B4: -/* 0D22B4 800D16B4 3C01800F */ lui $at, %hi(D_800EB3B4) # $at, 0x800f -/* 0D22B8 800D16B8 AC3AB3B4 */ sw $k0, %lo(D_800EB3B4)($at) +/* 0D22B4 800D16B4 3C01800F */ lui $at, %hi(__osFaultedThread) # $at, 0x800f +/* 0D22B8 800D16B8 AC3AB3B4 */ sw $k0, %lo(__osFaultedThread)($at) /* 0D22BC 800D16BC 24090001 */ li $t1, 1 /* 0D22C0 800D16C0 A7490010 */ sh $t1, 0x10($k0) /* 0D22C4 800D16C4 24090002 */ li $t1, 2 diff --git a/data/data_0DD0A0_2_1.s b/data/data_0DD0A0_2_1.s deleted file mode 100644 index dec478cac..000000000 --- a/data/data_0DD0A0_2_1.s +++ /dev/null @@ -1,55 +0,0 @@ -.include "macros.inc" - -.section .data - -# osPiStartDma .data - -#glabel __osPiDevMgr -#.word 0x00000000 - -#.word 0x00000000 - -#.word 0x00000000 - -#.word 0x00000000 - -#.word 0x00000000 - -#.word 0x00000000 - -#.word 0x00000000 - -#glabel __osPiTable -#.word 0x00000000 - -#glabel D_800EB360 -#.word 0x00000000, 0x00000000, 0x00000000, 0x00000000 - -glabel D_800EB370 -.word 0x00000000, 0x00000000, 0x00000000, 0x00000000 - -glabel __osHwIntTable -.word 0x00000000, 0x00000000, 0x00000000, 0x00000000 -.word 0x00000000, 0x00000000, 0x00000000, 0x00000000 - -glabel D_800EB3A0 -.word 0x00000000, 0xffffffff - -glabel __osRunQueue -.word D_800EB3A0 - -glabel __osActiveQueue -.word D_800EB3A0 - -glabel __osRunningThread -.word 0x00000000 - -glabel D_800EB3B4 -.word 0x00000000 - -.balign 16 - -# glabel __osTimerList -# .word __osBaseTimer - -# .word 0x00000000, 0x00000000, 0x00000000 diff --git a/mk64.ld b/mk64.ld index bcfb61981..b13de4f22 100644 --- a/mk64.ld +++ b/mk64.ld @@ -256,7 +256,9 @@ SECTIONS BUILD_DIR/src/os/osViTable.o(.data); BUILD_DIR/src/os/osCreatePiManager.o(.data); BUILD_DIR/src/os/osContInit.o(.data); - BUILD_DIR/data/data_0DD0A0_2_1.o(.data); + BUILD_DIR/src/os/osAiSetNextBuffer.o(.data); + BUILD_DIR/src/os/__osSetHWIntrRoutine.o(.data); + BUILD_DIR/src/os/__osDequeueThread.o(.data); BUILD_DIR/src/os/osTimer.o(.data); BUILD_DIR/src/os/__osViInit.o(.data); BUILD_DIR/src/os/__osPiCreateAccessQueue.o(.data); diff --git a/src/os/__osDequeueThread.c b/src/os/__osDequeueThread.c index 3f5eafc75..a9b01fcfc 100644 --- a/src/os/__osDequeueThread.c +++ b/src/os/__osDequeueThread.c @@ -1,13 +1,10 @@ #include "libultra_internal.h" -// these don't feel like they belong here -// but it makes the most logical since there was printf data before -// OSThread *D_800EB3A0 = NULL; -// u32 D_80334894 = -1; -// OSThread *__osRunQueue = (OSThread *) &D_800EB3A0; -// OSThread *__osActiveQueue = (OSThread *) &D_800EB3A0; -// OSThread *__osRunningThread = NULL; -// u32 D_803348A4 = 0; // UNKNOWN +OSThreadTail __osThreadTail = {NULL, -1}; +OSThread *__osRunQueue = (OSThread *) &__osThreadTail; +OSThread *__osActiveQueue = (OSThread *) &__osThreadTail; +OSThread *__osRunningThread = NULL; +OSThread *__osFaultedThread = NULL; void __osDequeueThread(OSThread **queue, OSThread *thread) { register OSThread **a2; diff --git a/src/os/__osSetHWIntrRoutine.c b/src/os/__osSetHWIntrRoutine.c index 182dc8cb4..87e35034a 100755 --- a/src/os/__osSetHWIntrRoutine.c +++ b/src/os/__osSetHWIntrRoutine.c @@ -1,6 +1,10 @@ #include "libultra_internal.h" -extern s32 (*__osHwIntTable[])(void); +// Its not clear how big this array should be. +// In order for file alignment to be correct, it needs to be +// at least 5 but no more than 8. Beyond that its not clear +// what its size should be +s32 (*__osHwIntTable[5])(void) = {NULL}; void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void)) { register u32 saveMask; diff --git a/src/os/libultra_internal.h b/src/os/libultra_internal.h index 19ec7d934..9d2fbd010 100644 --- a/src/os/libultra_internal.h +++ b/src/os/libultra_internal.h @@ -3,15 +3,20 @@ #include #include "macros.h" -/* - * This define is needed because the original definitions in __osDequeueThread.c are declared - * seperately instead of part of a single struct, however some code alises over this memory - * assuming a unified structure. To fix this, we declare the full type here and then alias the - * symbol names to the correct members in AVOID_UB. - */ +typedef struct __OSEventState +{ + OSMesgQueue *messageQueue; + OSMesg message; +} __OSEventState; + +typedef struct __osThreadTail +{ + OSThread *next; + OSPri priority; +} OSThreadTail; // Original OSThread_ListHead definitions -extern OSThread *D_800EB3A0; +extern OSThreadTail __osThreadTail; extern OSThread *__osActiveQueue; extern OSThread *__osRunQueue; extern OSThread *__osRunningThread; diff --git a/src/os/osAiSetNextBuffer.c b/src/os/osAiSetNextBuffer.c index 155df560c..782bd72dd 100644 --- a/src/os/osAiSetNextBuffer.c +++ b/src/os/osAiSetNextBuffer.c @@ -2,8 +2,7 @@ #include "osAi.h" #include "hardware.h" -// hdwrBugFlag on libreultra -extern u8 D_800EB370; // = 0; +u8 hdwrBugFlag = 0; /** * It is worth noting that a previous hardware bug has been fixed by a software @@ -21,14 +20,14 @@ extern u8 D_800EB370; // = 0; s32 osAiSetNextBuffer(void *buff, u32 len) { u8 *sp1c = buff; - if (D_800EB370 != 0) { + if (hdwrBugFlag != 0) { sp1c -= 0x2000; } if ((((uintptr_t) buff + len) & 0x3fff) == 0x2000) { - D_800EB370 = 1; + hdwrBugFlag = 1; } else { - D_800EB370 = 0; + hdwrBugFlag = 0; } if (__osAiDeviceBusy()) { diff --git a/src/os/osCreateMesgQueue.c b/src/os/osCreateMesgQueue.c index 93e4f058c..3e99739b8 100644 --- a/src/os/osCreateMesgQueue.c +++ b/src/os/osCreateMesgQueue.c @@ -1,8 +1,8 @@ #include "libultra_internal.h" void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msgBuf, s32 count) { - mq->mtqueue = (OSThread *) &D_800EB3A0; //? - mq->fullqueue = (OSThread *) &D_800EB3A0; + mq->mtqueue = (OSThread *) &__osThreadTail; //? + mq->fullqueue = (OSThread *) &__osThreadTail; mq->validCount = 0; mq->first = 0; mq->msgCount = count; diff --git a/src/os/osint.h b/src/os/osint.h index f2220f4db..f607d6a6e 100644 --- a/src/os/osint.h +++ b/src/os/osint.h @@ -2,17 +2,6 @@ #define _OSINT_H #include "libultra_internal.h" -typedef struct __OSEventState -{ - OSMesgQueue *messageQueue; - OSMesg message; -} __OSEventState; -extern struct __osThreadTail -{ - OSThread *next; - OSPri priority; -} __osThreadTail; - //maybe should be in exceptasm.h? extern void __osEnqueueAndYield(OSThread **); extern void __osDequeueThread(OSThread **, OSThread *);