summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2021-11-28 12:50:35 +0000
committerGitHub <noreply@github.com>2021-11-28 07:50:35 -0500
commit982e7be1f7ed06dcd8a9026b461a5908747b8087 (patch)
treef9ed3f8e91de3d173e57328963ef8d6553d59c92 /src
parent09f0dc84b8e77cf2078442069bed5ee7db34af44 (diff)
Preliminary fixes for boot/libultra (#1032)
* Preliminary fixes * Missed a NULL
Diffstat (limited to 'src')
-rw-r--r--src/libultra_boot_O1/__osGetHWIntrRoutine.c6
-rw-r--r--src/libultra_boot_O1/__osResetGlobalIntMask.c2
-rw-r--r--src/libultra_boot_O1/__osSetGlobalIntMask.c2
-rw-r--r--src/libultra_boot_O1/__osSetHWIntrRoutine.c8
-rw-r--r--src/libultra_boot_O1/initialize.c2
-rw-r--r--src/libultra_boot_O1/osDestroyThread.c2
-rw-r--r--src/libultra_boot_O1/osJamMesg.c2
-rw-r--r--src/libultra_boot_O1/osRecvMesg.c2
-rw-r--r--src/libultra_boot_O2/__osEPiRawReadIo.c2
-rw-r--r--src/libultra_boot_O2/__osEPiRawStartDma.c2
-rw-r--r--src/libultra_boot_O2/__osEPiRawWriteIo.c2
-rw-r--r--src/libultra_boot_O2/__osPiRawStartDma.c2
-rw-r--r--src/libultra_boot_O2/osCartRomInit.c2
-rw-r--r--src/libultra_boot_O2/osDriveRomInit.c4
-rw-r--r--src/libultra_boot_O2/osViGetNextFramebuffer.c2
-rw-r--r--src/libultra_boot_O2/osViSetYScale.c2
-rw-r--r--src/libultra_boot_O2/vimgr.c30
-rw-r--r--src/libultra_code_O1/osSetTimer.c2
-rw-r--r--src/libultra_code_O1/osStopTimer.c2
19 files changed, 34 insertions, 44 deletions
diff --git a/src/libultra_boot_O1/__osGetHWIntrRoutine.c b/src/libultra_boot_O1/__osGetHWIntrRoutine.c
index 4ccfb032a..4c182a29d 100644
--- a/src/libultra_boot_O1/__osGetHWIntrRoutine.c
+++ b/src/libultra_boot_O1/__osGetHWIntrRoutine.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "ultra64/internal.h"
-void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg) {
- *outQueue = __osHwIntTable[idx].queue;
- *outMsg = __osHwIntTable[idx].msg;
+void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handlerOut)(void), void** spOut) {
+ *handlerOut = __osHwIntTable[interrupt].handler;
+ *spOut = __osHwIntTable[interrupt].sp;
}
diff --git a/src/libultra_boot_O1/__osResetGlobalIntMask.c b/src/libultra_boot_O1/__osResetGlobalIntMask.c
index c2561d712..0e4155797 100644
--- a/src/libultra_boot_O1/__osResetGlobalIntMask.c
+++ b/src/libultra_boot_O1/__osResetGlobalIntMask.c
@@ -1,7 +1,7 @@
#include "global.h"
void __osResetGlobalIntMask(u32 mask) {
- register s32 prevInt = __osDisableInt();
+ register u32 prevInt = __osDisableInt();
__OSGlobalIntMask &= ~(mask & ~0x401);
__osRestoreInt(prevInt);
diff --git a/src/libultra_boot_O1/__osSetGlobalIntMask.c b/src/libultra_boot_O1/__osSetGlobalIntMask.c
index 6b7895d6d..9dab2aaf1 100644
--- a/src/libultra_boot_O1/__osSetGlobalIntMask.c
+++ b/src/libultra_boot_O1/__osSetGlobalIntMask.c
@@ -1,7 +1,7 @@
#include "global.h"
void __osSetGlobalIntMask(u32 mask) {
- register s32 prevInt = __osDisableInt();
+ register u32 prevInt = __osDisableInt();
__OSGlobalIntMask |= mask;
__osRestoreInt(prevInt);
diff --git a/src/libultra_boot_O1/__osSetHWIntrRoutine.c b/src/libultra_boot_O1/__osSetHWIntrRoutine.c
index b7ba0066a..94255df33 100644
--- a/src/libultra_boot_O1/__osSetHWIntrRoutine.c
+++ b/src/libultra_boot_O1/__osSetHWIntrRoutine.c
@@ -1,11 +1,11 @@
#include "global.h"
#include "ultra64/internal.h"
-void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg) {
- register s32 prevInt = __osDisableInt();
+void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void* sp) {
+ register u32 prevInt = __osDisableInt();
- __osHwIntTable[idx].queue = queue;
- __osHwIntTable[idx].msg = msg;
+ __osHwIntTable[interrupt].handler = handler;
+ __osHwIntTable[interrupt].sp = sp;
__osRestoreInt(prevInt);
}
diff --git a/src/libultra_boot_O1/initialize.c b/src/libultra_boot_O1/initialize.c
index 0489067b0..d20659298 100644
--- a/src/libultra_boot_O1/initialize.c
+++ b/src/libultra_boot_O1/initialize.c
@@ -58,7 +58,7 @@ void __osInitialize_common(void) {
osClockRate = (u64)((osClockRate * 3ll) / 4ull);
if (!osResetType) {
- bzero(osAppNmiBuffer, 0x40);
+ bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer));
}
if (osTvType == OS_TV_PAL) {
diff --git a/src/libultra_boot_O1/osDestroyThread.c b/src/libultra_boot_O1/osDestroyThread.c
index 9d8fef254..6f1ffff13 100644
--- a/src/libultra_boot_O1/osDestroyThread.c
+++ b/src/libultra_boot_O1/osDestroyThread.c
@@ -1,7 +1,7 @@
#include "global.h"
void osDestroyThread(OSThread* thread) {
- register s32 prevInt = __osDisableInt();
+ register u32 prevInt = __osDisableInt();
register OSThread* s1;
register OSThread* s2;
diff --git a/src/libultra_boot_O1/osJamMesg.c b/src/libultra_boot_O1/osJamMesg.c
index 997c8fe65..5668c476e 100644
--- a/src/libultra_boot_O1/osJamMesg.c
+++ b/src/libultra_boot_O1/osJamMesg.c
@@ -1,7 +1,7 @@
#include "global.h"
s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) {
- register s32 prevInt = __osDisableInt();
+ register u32 prevInt = __osDisableInt();
while (mq->validCount >= mq->msgCount) {
if (flag == OS_MESG_BLOCK) {
diff --git a/src/libultra_boot_O1/osRecvMesg.c b/src/libultra_boot_O1/osRecvMesg.c
index d6de78adb..0f4c83cff 100644
--- a/src/libultra_boot_O1/osRecvMesg.c
+++ b/src/libultra_boot_O1/osRecvMesg.c
@@ -1,7 +1,7 @@
#include "global.h"
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) {
- register s32 prevInt = __osDisableInt();
+ register u32 prevInt = __osDisableInt();
while (mq->validCount == 0) {
if (flag == OS_MESG_NOBLOCK) {
diff --git a/src/libultra_boot_O2/__osEPiRawReadIo.c b/src/libultra_boot_O2/__osEPiRawReadIo.c
index 6aa0bf0b6..513a246ee 100644
--- a/src/libultra_boot_O2/__osEPiRawReadIo.c
+++ b/src/libultra_boot_O2/__osEPiRawReadIo.c
@@ -4,7 +4,7 @@ s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data) {
s32 status;
OSPiHandle* curHandle;
- while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
+ while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
;
}
diff --git a/src/libultra_boot_O2/__osEPiRawStartDma.c b/src/libultra_boot_O2/__osEPiRawStartDma.c
index 5ae4d9c30..c8f4de5fd 100644
--- a/src/libultra_boot_O2/__osEPiRawStartDma.c
+++ b/src/libultra_boot_O2/__osEPiRawStartDma.c
@@ -4,7 +4,7 @@ s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dr
s32 status;
OSPiHandle* curHandle;
- while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
+ while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
;
}
diff --git a/src/libultra_boot_O2/__osEPiRawWriteIo.c b/src/libultra_boot_O2/__osEPiRawWriteIo.c
index 7c5701e0d..dc169ecf7 100644
--- a/src/libultra_boot_O2/__osEPiRawWriteIo.c
+++ b/src/libultra_boot_O2/__osEPiRawWriteIo.c
@@ -4,7 +4,7 @@ s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) {
s32 status;
OSPiHandle* curHandle;
- while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
+ while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
;
}
diff --git a/src/libultra_boot_O2/__osPiRawStartDma.c b/src/libultra_boot_O2/__osPiRawStartDma.c
index f2c0a8488..b642b508f 100644
--- a/src/libultra_boot_O2/__osPiRawStartDma.c
+++ b/src/libultra_boot_O2/__osPiRawStartDma.c
@@ -3,7 +3,7 @@
s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size) {
register s32 status = HW_REG(PI_STATUS_REG, u32);
- while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
+ while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
status = HW_REG(PI_STATUS_REG, u32);
}
diff --git a/src/libultra_boot_O2/osCartRomInit.c b/src/libultra_boot_O2/osCartRomInit.c
index f87d3bd05..ab54c1931 100644
--- a/src/libultra_boot_O2/osCartRomInit.c
+++ b/src/libultra_boot_O2/osCartRomInit.c
@@ -27,7 +27,7 @@ OSPiHandle* osCartRomInit(void) {
__CartRomHandle.speed = 0;
bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
- while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) {
+ while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
;
}
diff --git a/src/libultra_boot_O2/osDriveRomInit.c b/src/libultra_boot_O2/osDriveRomInit.c
index a9f2ea02b..8aed46dd6 100644
--- a/src/libultra_boot_O2/osDriveRomInit.c
+++ b/src/libultra_boot_O2/osDriveRomInit.c
@@ -5,7 +5,7 @@ OSPiHandle __DriveRomHandle;
OSPiHandle* osDriveRomInit(void) {
register s32 status;
register u32 a;
- register s32 prevInt;
+ register u32 prevInt;
static u32 D_8000AC70 = 1;
__osPiGetAccess();
@@ -22,7 +22,7 @@ OSPiHandle* osDriveRomInit(void) {
__DriveRomHandle.speed = 0;
bzero(&__DriveRomHandle.transferInfo, sizeof(__OSTranxInfo));
- while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) {
+ while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
;
}
diff --git a/src/libultra_boot_O2/osViGetNextFramebuffer.c b/src/libultra_boot_O2/osViGetNextFramebuffer.c
index aaf44ce4a..a15a2db21 100644
--- a/src/libultra_boot_O2/osViGetNextFramebuffer.c
+++ b/src/libultra_boot_O2/osViGetNextFramebuffer.c
@@ -1,7 +1,7 @@
#include "global.h"
void* osViGetNextFramebuffer(void) {
- s32 prevInt = __osDisableInt();
+ u32 prevInt = __osDisableInt();
void* buff = __osViNext->buffer;
__osRestoreInt(prevInt);
diff --git a/src/libultra_boot_O2/osViSetYScale.c b/src/libultra_boot_O2/osViSetYScale.c
index 29128af76..0d7a5f968 100644
--- a/src/libultra_boot_O2/osViSetYScale.c
+++ b/src/libultra_boot_O2/osViSetYScale.c
@@ -1,7 +1,7 @@
#include "global.h"
void osViSetYScale(f32 scale) {
- register s32 prevInt = __osDisableInt();
+ register u32 prevInt = __osDisableInt();
__osViNext->y.factor = scale;
__osViNext->state |= 4;
diff --git a/src/libultra_boot_O2/vimgr.c b/src/libultra_boot_O2/vimgr.c
index b57b48d3b..5be0ba2e3 100644
--- a/src/libultra_boot_O2/vimgr.c
+++ b/src/libultra_boot_O2/vimgr.c
@@ -1,21 +1,12 @@
#include "global.h"
#include "ultra64/internal.h"
-typedef struct {
- u16 unk00;
- u8 unk02;
- u32 unk04;
- u8 pad[0xC];
- u16 unk14;
- u16 unk16;
-} viMesgStruct;
-
OSThread viThread;
u8 viThreadStack[0x1000];
OSMesgQueue viEventQueue;
OSMesg viEventBuf[6];
-viMesgStruct viRetraceMsg;
-viMesgStruct viCounterMsg;
+OSIoMesg viRetraceMsg;
+OSIoMesg viCounterMsg;
OSMgrArgs __osViDevMgr = { 0 };
u32 __additional_scanline = 0;
@@ -30,12 +21,12 @@ void osCreateViManager(OSPri pri) {
__osTimerServicesInit();
__additional_scanline = 0;
osCreateMesgQueue(&viEventQueue, viEventBuf, 5);
- viRetraceMsg.unk00 = 13;
- viRetraceMsg.unk02 = 0;
- viRetraceMsg.unk04 = 0;
- viCounterMsg.unk00 = 14;
- viCounterMsg.unk02 = 0;
- viCounterMsg.unk04 = 0;
+ viRetraceMsg.hdr.type = 13;
+ viRetraceMsg.hdr.pri = 0;
+ viRetraceMsg.hdr.retQueue = NULL;
+ viCounterMsg.hdr.type = 14;
+ viCounterMsg.hdr.pri = 0;
+ viCounterMsg.hdr.retQueue = NULL;
osSetEventMesg(OS_EVENT_VI, &viEventQueue, &viRetraceMsg);
osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg);
newPri = -1;
@@ -68,10 +59,9 @@ void viMgrMain(void* vargs) {
OSMgrArgs* args;
static u16 viRetrace;
u32 addTime;
- viMesgStruct* mesg;
+ OSIoMesg* mesg = NULL;
u32 temp = 0; // always 0
- mesg = NULL;
viRetrace = __osViGetCurrentContext()->retraceCount;
if (viRetrace == 0) {
viRetrace = 1;
@@ -81,7 +71,7 @@ void viMgrMain(void* vargs) {
while (true) {
osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK);
- switch (mesg->unk00) {
+ switch (mesg->hdr.type) {
case 13:
__osViSwapContext();
viRetrace--;
diff --git a/src/libultra_code_O1/osSetTimer.c b/src/libultra_code_O1/osSetTimer.c
index a14c9b23b..b0c4a05e9 100644
--- a/src/libultra_code_O1/osSetTimer.c
+++ b/src/libultra_code_O1/osSetTimer.c
@@ -5,7 +5,7 @@ s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* m
OSTimer* next;
u32 count;
u32 value;
- s32 prevInt;
+ u32 prevInt;
timer->next = NULL;
timer->prev = NULL;
diff --git a/src/libultra_code_O1/osStopTimer.c b/src/libultra_code_O1/osStopTimer.c
index 627d57b75..d6d20536a 100644
--- a/src/libultra_code_O1/osStopTimer.c
+++ b/src/libultra_code_O1/osStopTimer.c
@@ -1,7 +1,7 @@
#include "global.h"
s32 osStopTimer(OSTimer* timer) {
- register s32 prevInt;
+ register u32 prevInt;
OSTimer* next;
if (!timer->next) {