mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-06 14:20:11 +00:00
Fix most compiler warnings in the boot and code segments (#674)
* Less warnings in boot & code segments * few more warnings gone * Ran formatter * z_view warning gone * -> 1 * f31 -> 31 * Remove function casts * Few more small improvements * Separate declaration and assignment in func_80091738 and Item_Give Co-authored-by: Thar0 <maximilianc64@gmail.com>
This commit is contained in:
parent
d615ec4f31
commit
f9d96d9f73
208 changed files with 1702 additions and 1846 deletions
|
@ -1,10 +1,9 @@
|
|||
#include "global.h"
|
||||
|
||||
void __osDequeueThread(OSThread** queue, OSThread* thread) {
|
||||
register OSThread** a2;
|
||||
register OSThread* a3;
|
||||
a2 = queue;
|
||||
a3 = *a2;
|
||||
register OSThread** a2 = queue;
|
||||
register OSThread* a3 = *a2;
|
||||
|
||||
while (a3 != NULL) {
|
||||
if (a3 == thread) {
|
||||
*a2 = thread->next;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include "global.h"
|
||||
|
||||
void __osResetGlobalIntMask(u32 mask) {
|
||||
register s32 prevInt;
|
||||
register s32 prevInt = __osDisableInt();
|
||||
|
||||
prevInt = __osDisableInt();
|
||||
__OSGlobalIntMask &= ~(mask & ~0x401);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include "global.h"
|
||||
|
||||
void __osSetGlobalIntMask(u32 mask) {
|
||||
register s32 prevInt;
|
||||
register s32 prevInt = __osDisableInt();
|
||||
|
||||
prevInt = __osDisableInt();
|
||||
__OSGlobalIntMask |= mask;
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#include "ultra64/internal.h"
|
||||
|
||||
void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg) {
|
||||
register s32 prevInt;
|
||||
|
||||
prevInt = __osDisableInt();
|
||||
register s32 prevInt = __osDisableInt();
|
||||
|
||||
__osHwIntTable[idx].queue = queue;
|
||||
__osHwIntTable[idx].msg = msg;
|
||||
|
|
|
@ -80,5 +80,5 @@ void __osInitialize_common(void) {
|
|||
HW_REG(AI_BITRATE_REG, u32) = 0xf;
|
||||
}
|
||||
|
||||
void __osInitialize_autodetect() {
|
||||
void __osInitialize_autodetect(void) {
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "global.h"
|
||||
|
||||
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 count) {
|
||||
mq->mtqueue = __osThreadTail;
|
||||
mq->fullqueue = __osThreadTail;
|
||||
mq->mtqueue = (OSThread*)__osThreadTail;
|
||||
mq->fullqueue = (OSThread*)__osThreadTail;
|
||||
mq->validCount = 0;
|
||||
mq->first = 0;
|
||||
mq->msgCount = count;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
#include "global.h"
|
||||
|
||||
OSThread* __osThreadTail[2] = { NULL, (OSThread*)-1 };
|
||||
OSThread* __osRunQueue = __osThreadTail;
|
||||
OSThread* __osActiveQueue = __osThreadTail;
|
||||
OSThread* __osRunQueue = (OSThread*)__osThreadTail;
|
||||
OSThread* __osActiveQueue = (OSThread*)__osThreadTail;
|
||||
OSThread* __osRunningThread = NULL;
|
||||
OSThread* __osFaultedThread = NULL;
|
||||
|
||||
void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri pri) {
|
||||
register u32 s0;
|
||||
register u32 prevInt;
|
||||
u32 t8;
|
||||
|
||||
thread->id = id;
|
||||
thread->priority = pri;
|
||||
thread->next = (struct OSThread_s*)NULL;
|
||||
thread->queue = (struct OSThread_s**)NULL;
|
||||
thread->next = NULL;
|
||||
thread->queue = NULL;
|
||||
thread->context.pc = (u32)entry;
|
||||
thread->context.a0 = (u64)arg;
|
||||
thread->context.sp = (u64)sp - 16;
|
||||
thread->context.ra = (u64)__osCleanupThread;
|
||||
thread->context.a0 = arg;
|
||||
thread->context.sp = (u64)(s32)sp - 16;
|
||||
thread->context.ra = __osCleanupThread;
|
||||
t8 = 0x3FFF01;
|
||||
thread->context.sr = (t8 & 0xFF01) | 2;
|
||||
thread->context.rcp = (t8 & 0x3F0000) >> 16;
|
||||
|
@ -26,8 +26,8 @@ void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg,
|
|||
thread->state = 1;
|
||||
thread->flags = 0;
|
||||
|
||||
s0 = __osDisableInt();
|
||||
prevInt = __osDisableInt();
|
||||
thread->tlnext = __osActiveQueue;
|
||||
__osActiveQueue = thread;
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
#include "global.h"
|
||||
|
||||
void osDestroyThread(OSThread* thread) {
|
||||
register s32 int_disabled;
|
||||
|
||||
register s32 prevInt = __osDisableInt();
|
||||
register OSThread* s1;
|
||||
register OSThread* s2;
|
||||
|
||||
int_disabled = __osDisableInt();
|
||||
|
||||
if (thread == NULL) {
|
||||
thread = __osRunningThread;
|
||||
|
||||
|
@ -33,5 +30,5 @@ void osDestroyThread(OSThread* thread) {
|
|||
__osDispatchThread();
|
||||
}
|
||||
|
||||
__osRestoreInt(int_disabled);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -4,12 +4,10 @@
|
|||
|
||||
u32 osGetMemSize(void) {
|
||||
u32* ptr;
|
||||
u32 size;
|
||||
u32 size = 0x400000;
|
||||
u32 data0;
|
||||
u32 data1;
|
||||
|
||||
size = 0x400000;
|
||||
|
||||
while (size < 0x800000) {
|
||||
ptr = (u32*)(0xA0000000 + size);
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#include "global.h"
|
||||
|
||||
OSTime osGetTime(void) {
|
||||
u32 sp34;
|
||||
u32 sp30;
|
||||
u64 t1;
|
||||
register u32 s0;
|
||||
u32 count;
|
||||
u32 base;
|
||||
u64 t;
|
||||
register u32 prevInt = __osDisableInt();
|
||||
|
||||
s0 = __osDisableInt();
|
||||
sp34 = osGetCount();
|
||||
sp30 = sp34 - __osBaseCounter;
|
||||
t1 = __osCurrentTime;
|
||||
__osRestoreInt(s0);
|
||||
count = osGetCount();
|
||||
base = count - __osBaseCounter;
|
||||
t = __osCurrentTime;
|
||||
__osRestoreInt(prevInt);
|
||||
|
||||
return sp30 + t1;
|
||||
return base + t;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "global.h"
|
||||
|
||||
s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) {
|
||||
register s32 int_disabled;
|
||||
int_disabled = __osDisableInt();
|
||||
register s32 prevInt = __osDisableInt();
|
||||
|
||||
while (mq->validCount >= mq->msgCount) {
|
||||
if (flag == OS_MESG_BLOCK) {
|
||||
__osRunningThread->state = OS_STATE_WAITING;
|
||||
__osEnqueueAndYield(&mq->fullqueue);
|
||||
} else {
|
||||
__osRestoreInt(int_disabled);
|
||||
__osRestoreInt(prevInt);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) {
|
|||
if (mq->mtqueue->next != NULL) {
|
||||
osStartThread(__osPopThread(&mq->mtqueue));
|
||||
}
|
||||
__osRestoreInt(int_disabled);
|
||||
__osRestoreInt(prevInt);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include "global.h"
|
||||
|
||||
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) {
|
||||
register s32 s0 = __osDisableInt();
|
||||
register s32 prevInt = __osDisableInt();
|
||||
|
||||
while (mq->validCount == 0) {
|
||||
if (flag == OS_MESG_NOBLOCK) {
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
return -1;
|
||||
}
|
||||
__osRunningThread->state = 8;
|
||||
__osEnqueueAndYield(mq);
|
||||
__osEnqueueAndYield((OSThread**)mq);
|
||||
}
|
||||
|
||||
if (msg != NULL) {
|
||||
|
@ -23,7 +23,7 @@ s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) {
|
|||
osStartThread(__osPopThread(&mq->fullqueue));
|
||||
}
|
||||
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "global.h"
|
||||
|
||||
s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag) {
|
||||
register u32 s0 = __osDisableInt();
|
||||
register u32 prevInt = __osDisableInt();
|
||||
register u32 index;
|
||||
|
||||
while (mq->validCount >= mq->msgCount) {
|
||||
|
@ -9,7 +9,7 @@ s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag) {
|
|||
__osRunningThread->state = 8;
|
||||
__osEnqueueAndYield(&mq->fullqueue);
|
||||
} else {
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag) {
|
|||
osStartThread(__osPopThread(&mq->mtqueue));
|
||||
}
|
||||
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,20 +6,18 @@ __OSEventState __osEventStateTab[OS_NUM_EVENTS + 1];
|
|||
u32 __osPreNMI = 0;
|
||||
|
||||
void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg msg) {
|
||||
register u32 int_disabled;
|
||||
__OSEventState* msgs;
|
||||
register u32 prevInt = __osDisableInt();
|
||||
__OSEventState* msgs = __osEventStateTab + e;
|
||||
|
||||
int_disabled = __osDisableInt();
|
||||
msgs = __osEventStateTab + e;
|
||||
msgs->queue = mq;
|
||||
msgs->msg = msg;
|
||||
|
||||
if (e == OS_EVENT_PRENMI) {
|
||||
if (__osShutdown && !__osPreNMI) {
|
||||
osSendMesg(mq, msg, 0);
|
||||
osSendMesg(mq, msg, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
__osPreNMI = true;
|
||||
}
|
||||
__osRestoreInt(int_disabled);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "global.h"
|
||||
|
||||
void osSetThreadPri(OSThread* thread, OSPri pri) {
|
||||
register u32 s0 = __osDisableInt();
|
||||
register u32 prevInt = __osDisableInt();
|
||||
|
||||
if (thread == NULL) {
|
||||
thread = __osRunningThread;
|
||||
|
@ -19,5 +19,5 @@ void osSetThreadPri(OSThread* thread, OSPri pri) {
|
|||
}
|
||||
}
|
||||
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "global.h"
|
||||
|
||||
void osStartThread(OSThread* thread) {
|
||||
register u32 s0 = __osDisableInt();
|
||||
register u32 prevInt = __osDisableInt();
|
||||
|
||||
switch (thread->state) {
|
||||
case 8:
|
||||
|
@ -29,5 +29,5 @@ void osStartThread(OSThread* thread) {
|
|||
}
|
||||
}
|
||||
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "global.h"
|
||||
|
||||
void osStopThread(OSThread* thread) {
|
||||
register u32 s0 = __osDisableInt();
|
||||
register u32 prevInt = __osDisableInt();
|
||||
register u32 state;
|
||||
|
||||
if (thread == NULL) {
|
||||
|
@ -22,5 +22,5 @@ void osStopThread(OSThread* thread) {
|
|||
break;
|
||||
}
|
||||
|
||||
__osRestoreInt(s0);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include "global.h"
|
||||
|
||||
void osYieldThread() {
|
||||
register u32 prevInt;
|
||||
void osYieldThread(void) {
|
||||
register u32 prevInt = __osDisableInt();
|
||||
|
||||
prevInt = __osDisableInt();
|
||||
__osRunningThread->state = OS_STATE_RUNNABLE;
|
||||
__osEnqueueAndYield(&__osRunQueue);
|
||||
__osRestoreInt(prevInt);
|
||||
|
|
|
@ -22,5 +22,5 @@ void __osPiGetAccess(void) {
|
|||
}
|
||||
|
||||
void __osPiRelAccess(void) {
|
||||
osSendMesg(&__osPiAccessQueue, 0, OS_MESG_NOBLOCK);
|
||||
osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ u32 __osViIntrCount;
|
|||
u32 __osTimerCounter;
|
||||
OSTimer* __osTimerList = &__osBaseTimer;
|
||||
|
||||
void __osTimerServicesInit() {
|
||||
void __osTimerServicesInit(void) {
|
||||
__osCurrentTime = 0;
|
||||
__osBaseCounter = 0;
|
||||
__osViIntrCount = 0;
|
||||
|
@ -19,76 +19,83 @@ void __osTimerServicesInit() {
|
|||
__osTimerList->msg = NULL;
|
||||
}
|
||||
|
||||
void __osTimerInterrupt() {
|
||||
OSTimer* sp24;
|
||||
void __osTimerInterrupt(void) {
|
||||
OSTimer* timer;
|
||||
u32 sp20;
|
||||
u32 sp1c;
|
||||
|
||||
if (__osTimerList->next == __osTimerList) {
|
||||
return;
|
||||
}
|
||||
while (1) {
|
||||
sp24 = __osTimerList->next;
|
||||
if (sp24 == __osTimerList) {
|
||||
|
||||
while (true) {
|
||||
timer = __osTimerList->next;
|
||||
if (timer == __osTimerList) {
|
||||
__osSetCompare(0);
|
||||
__osTimerCounter = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
sp20 = osGetCount();
|
||||
sp1c = sp20 - __osTimerCounter;
|
||||
__osTimerCounter = sp20;
|
||||
if (sp1c < sp24->value) {
|
||||
sp24->value -= sp1c;
|
||||
__osSetTimerIntr(sp24->value);
|
||||
return;
|
||||
} else {
|
||||
sp24->prev->next = sp24->next;
|
||||
sp24->next->prev = sp24->prev;
|
||||
sp24->next = NULL;
|
||||
sp24->prev = NULL;
|
||||
if (sp24->mq != NULL) {
|
||||
osSendMesg(sp24->mq, sp24->msg, OS_MESG_NOBLOCK);
|
||||
}
|
||||
if (sp24->interval != 0) {
|
||||
sp24->value = sp24->interval;
|
||||
__osInsertTimer(sp24);
|
||||
}
|
||||
if (sp1c < timer->value) {
|
||||
timer->value -= sp1c;
|
||||
__osSetTimerIntr(timer->value);
|
||||
break;
|
||||
}
|
||||
|
||||
timer->prev->next = timer->next;
|
||||
timer->next->prev = timer->prev;
|
||||
timer->next = NULL;
|
||||
timer->prev = NULL;
|
||||
if (timer->mq != NULL) {
|
||||
osSendMesg(timer->mq, timer->msg, OS_MESG_NOBLOCK);
|
||||
}
|
||||
if (timer->interval != 0) {
|
||||
timer->value = timer->interval;
|
||||
__osInsertTimer(timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __osSetTimerIntr(OSTime tim) {
|
||||
OSTime NewTime;
|
||||
u32 savedMask;
|
||||
void __osSetTimerIntr(OSTime time) {
|
||||
OSTime newTime;
|
||||
u32 prevInt;
|
||||
|
||||
if (tim < 468) {
|
||||
tim = 468;
|
||||
if (time < 468) {
|
||||
time = 468;
|
||||
}
|
||||
|
||||
savedMask = __osDisableInt();
|
||||
prevInt = __osDisableInt();
|
||||
|
||||
__osTimerCounter = osGetCount();
|
||||
NewTime = tim + __osTimerCounter;
|
||||
__osSetCompare((u32)NewTime);
|
||||
__osRestoreInt(savedMask);
|
||||
newTime = time + __osTimerCounter;
|
||||
__osSetCompare((u32)newTime);
|
||||
__osRestoreInt(prevInt);
|
||||
}
|
||||
|
||||
OSTime __osInsertTimer(OSTimer* a0) {
|
||||
OSTimer* sp34;
|
||||
u64 sp28;
|
||||
s32 intDisabled;
|
||||
intDisabled = __osDisableInt();
|
||||
for (sp34 = __osTimerList->next, sp28 = a0->value; sp34 != __osTimerList && sp28 > sp34->value;
|
||||
sp28 -= sp34->value, sp34 = sp34->next) {
|
||||
OSTime __osInsertTimer(OSTimer* timer) {
|
||||
OSTimer* nextTimer;
|
||||
u64 timerValue;
|
||||
s32 prevInt = __osDisableInt();
|
||||
|
||||
for (nextTimer = __osTimerList->next, timerValue = timer->value;
|
||||
nextTimer != __osTimerList && timerValue > nextTimer->value;
|
||||
timerValue -= nextTimer->value, nextTimer = nextTimer->next) {
|
||||
;
|
||||
}
|
||||
a0->value = sp28;
|
||||
if (sp34 != __osTimerList) {
|
||||
sp34->value -= sp28;
|
||||
|
||||
timer->value = timerValue;
|
||||
if (nextTimer != __osTimerList) {
|
||||
nextTimer->value -= timerValue;
|
||||
}
|
||||
a0->next = sp34;
|
||||
a0->prev = sp34->prev;
|
||||
sp34->prev->next = a0;
|
||||
sp34->prev = a0;
|
||||
__osRestoreInt(intDisabled);
|
||||
return sp28;
|
||||
|
||||
timer->next = nextTimer;
|
||||
timer->prev = nextTimer->prev;
|
||||
nextTimer->prev->next = timer;
|
||||
nextTimer->prev = timer;
|
||||
__osRestoreInt(prevInt);
|
||||
|
||||
return timerValue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue