From fdd8d104dc5817b21ca96276d8bc218e1de8dcff Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Wed, 22 Sep 2021 08:12:12 -0400 Subject: [PATCH] Fix files with now new line at end to resolve some warnings, and also minor style guide cleanup as well --- lib/src/os/osCreateThread.c | 5 ++--- lib/src/os/osGetThreadPri.c | 5 ++--- lib/src/os/osGetTime.c | 2 +- lib/src/os/osJamMesg.c | 17 ++++++--------- lib/src/os/osPfsFreeBlocks.c | 11 ++++------ lib/src/os/osPiGetCmdQueue.c | 5 ++--- lib/src/os/osPiStartDma.c | 5 ++--- lib/src/os/osRecvMesg.c | 17 ++++++--------- lib/src/os/osSendMesg.c | 17 ++++++--------- lib/src/os/osSetEventMesg.c | 9 +++----- lib/src/os/osSetTime.c | 4 ++-- lib/src/os/osSetTimer.c | 3 +-- lib/src/os/osStartThread.c | 42 ++++++++++++++++-------------------- lib/src/os/osStopThread.c | 32 ++++++++++++--------------- lib/src/os/osTimer.c | 19 ++++++---------- lib/src/os/osViMgr.c | 12 ++++------- lib/src/os/osViSwapBuffer.c | 2 +- 17 files changed, 81 insertions(+), 126 deletions(-) diff --git a/lib/src/os/osCreateThread.c b/lib/src/os/osCreateThread.c index 48463f0a..e74c1887 100644 --- a/lib/src/os/osCreateThread.c +++ b/lib/src/os/osCreateThread.c @@ -7,8 +7,7 @@ extern OSThread *__osActiveQueue; //__osActiveQueue; void __osCleanupThread(void); //__osCleanupThread -void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri p) -{ +void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri p) { register u32 saveMask; OSIntMask mask; t->id = id; @@ -30,4 +29,4 @@ void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void t->tlnext = __osActiveQueue; __osActiveQueue = t; __osRestoreInt(saveMask); -} \ No newline at end of file +} diff --git a/lib/src/os/osGetThreadPri.c b/lib/src/os/osGetThreadPri.c index 86124f0e..8526fa44 100644 --- a/lib/src/os/osGetThreadPri.c +++ b/lib/src/os/osGetThreadPri.c @@ -4,9 +4,8 @@ #include "libultra_internal.h" extern OSThread *__osRunningThread; -OSPri osGetThreadPri(OSThread *thread) -{ +OSPri osGetThreadPri(OSThread *thread) { if (thread == NULL) thread = __osRunningThread; return thread->priority; -} \ No newline at end of file +} diff --git a/lib/src/os/osGetTime.c b/lib/src/os/osGetTime.c index d613e0a6..a47f3c2a 100644 --- a/lib/src/os/osGetTime.c +++ b/lib/src/os/osGetTime.c @@ -18,4 +18,4 @@ OSTime osGetTime() currentCount = __osCurrentTime; __osRestoreInt(saveMask); return currentCount + elapseCount; -} \ No newline at end of file +} diff --git a/lib/src/os/osJamMesg.c b/lib/src/os/osJamMesg.c index 114eb44b..bb142355 100644 --- a/lib/src/os/osJamMesg.c +++ b/lib/src/os/osJamMesg.c @@ -6,18 +6,14 @@ extern OSThread *__osRunningThread; -s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) -{ +s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { register u32 saveMask = __osDisableInt(); - while (mq->validCount >= mq->msgCount) - { - if (flag == OS_MESG_BLOCK) - { + while (mq->validCount >= mq->msgCount) { + if (flag == OS_MESG_BLOCK) { __osRunningThread->state = OS_STATE_WAITING; __osEnqueueAndYield(&mq->fullqueue); } - else - { + else { __osRestoreInt(saveMask); return -1; } @@ -26,10 +22,9 @@ s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) mq->first = (mq->first + mq->msgCount - 1) % mq->msgCount; mq->msg[mq->first] = msg; mq->validCount++; - if (mq->mtqueue->next != NULL) - { + if (mq->mtqueue->next != NULL) { osStartThread(__osPopThread(&mq->mtqueue)); } __osRestoreInt(saveMask); return 0; -} \ No newline at end of file +} diff --git a/lib/src/os/osPfsFreeBlocks.c b/lib/src/os/osPfsFreeBlocks.c index f3934383..3f47e842 100644 --- a/lib/src/os/osPfsFreeBlocks.c +++ b/lib/src/os/osPfsFreeBlocks.c @@ -4,8 +4,7 @@ #include "libultra_internal.h" #include "controller.h" -s32 osPfsFreeBlocks(OSPfs *pfs, s32 *bytes_not_used) -{ +s32 osPfsFreeBlocks(OSPfs *pfs, s32 *bytes_not_used) { int j; int pages; __OSInode inode; @@ -16,19 +15,17 @@ s32 osPfsFreeBlocks(OSPfs *pfs, s32 *bytes_not_used) ret = 0; PFS_CHECK_STATUS; PFS_CHECK_ID; - for (bank = 0; bank < pfs->banks; bank++) - { + for (bank = 0; bank < pfs->banks; bank++) { ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); if (bank > 0) offset = 1; else offset = pfs->inodeStartPage; - for (j = offset; j < ARRLEN(inode.inodePage); j++) - { + for (j = offset; j < ARRLEN(inode.inodePage); j++) { if (inode.inodePage[j].ipage == 3) pages++; } } *bytes_not_used = pages * 8 * 32; return 0; -} \ No newline at end of file +} diff --git a/lib/src/os/osPiGetCmdQueue.c b/lib/src/os/osPiGetCmdQueue.c index 493221cd..f7f3b705 100644 --- a/lib/src/os/osPiGetCmdQueue.c +++ b/lib/src/os/osPiGetCmdQueue.c @@ -5,9 +5,8 @@ extern OSDevMgr __osPiDevMgr; -OSMesgQueue *osPiGetCmdQueue(void) -{ +OSMesgQueue *osPiGetCmdQueue(void) { if (!__osPiDevMgr.active) return NULL; return __osPiDevMgr.cmdQueue; -} \ No newline at end of file +} diff --git a/lib/src/os/osPiStartDma.c b/lib/src/os/osPiStartDma.c index 40626262..46ce2aaa 100644 --- a/lib/src/os/osPiStartDma.c +++ b/lib/src/os/osPiStartDma.c @@ -5,8 +5,7 @@ extern OSDevMgr __osPiDevMgr; //__osPiDevMgr; -s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) -{ +s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) { register s32 ret; if (!__osPiDevMgr.active) return -1; @@ -29,4 +28,4 @@ s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *d ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); } return ret; -} \ No newline at end of file +} diff --git a/lib/src/os/osRecvMesg.c b/lib/src/os/osRecvMesg.c index c8f3efc8..9d817688 100644 --- a/lib/src/os/osRecvMesg.c +++ b/lib/src/os/osRecvMesg.c @@ -7,15 +7,12 @@ extern OSThread *__osRunningThread; -s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) -{ +s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) { register u32 saveMask; saveMask = __osDisableInt(); - while (MQ_IS_EMPTY(mq)) - { - if (flags == OS_MESG_NOBLOCK) - { + while (MQ_IS_EMPTY(mq)) { + if (flags == OS_MESG_NOBLOCK) { __osRestoreInt(saveMask); return -1; } @@ -23,16 +20,14 @@ s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) __osEnqueueAndYield(&mq->mtqueue); } - if (msg != NULL) - { + if (msg != NULL) { *msg = mq->msg[mq->first]; } mq->first = (mq->first + 1) % mq->msgCount; mq->validCount--; - if (mq->fullqueue->next != NULL) - { + if (mq->fullqueue->next != NULL) { osStartThread(__osPopThread(&mq->fullqueue)); } __osRestoreInt(saveMask); return 0; -} \ No newline at end of file +} diff --git a/lib/src/os/osSendMesg.c b/lib/src/os/osSendMesg.c index 32a3eb97..5120f52a 100644 --- a/lib/src/os/osSendMesg.c +++ b/lib/src/os/osSendMesg.c @@ -4,20 +4,16 @@ extern OSThread *__osRunningThread; -s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) -{ +s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) { register u32 saveMask; register s32 last; saveMask = __osDisableInt(); - while (MQ_IS_FULL(mq)) - { - if (flags == OS_MESG_BLOCK) - { + while (MQ_IS_FULL(mq)) { + if (flags == OS_MESG_BLOCK) { __osRunningThread->state = OS_STATE_WAITING; __osEnqueueAndYield(&mq->fullqueue); } - else - { + else { __osRestoreInt(saveMask); return -1; } @@ -25,10 +21,9 @@ s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) last = (mq->first + mq->validCount) % mq->msgCount; mq->msg[last] = msg; mq->validCount++; - if (mq->mtqueue->next != NULL) - { + if (mq->mtqueue->next != NULL) { osStartThread(__osPopThread(&mq->mtqueue)); } __osRestoreInt(saveMask); return 0; -} \ No newline at end of file +} diff --git a/lib/src/os/osSetEventMesg.c b/lib/src/os/osSetEventMesg.c index 82424c45..5b33da27 100644 --- a/lib/src/os/osSetEventMesg.c +++ b/lib/src/os/osSetEventMesg.c @@ -3,16 +3,13 @@ #include "libultra_internal.h" -typedef struct __OSEventState -{ +typedef struct __OSEventState { OSMesgQueue *messageQueue; OSMesg message; } __OSEventState; - __OSEventState __osEventStateTab[15]; // __osEventStateTab[OS_NUM_EVENTS]; -void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) -{ +void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) { register u32 saveMask = __osDisableInt(); __OSEventState *es; @@ -20,4 +17,4 @@ void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) es->messageQueue = mq; es->message = msg; __osRestoreInt(saveMask); -} \ No newline at end of file +} diff --git a/lib/src/os/osSetTime.c b/lib/src/os/osSetTime.c index 82b1cdc7..c794f4ec 100644 --- a/lib/src/os/osSetTime.c +++ b/lib/src/os/osSetTime.c @@ -5,6 +5,6 @@ extern OSTime __osCurrentTime; -void osSetTime(OSTime time){ +void osSetTime(OSTime time) { __osCurrentTime = time; -} \ No newline at end of file +} diff --git a/lib/src/os/osSetTimer.c b/lib/src/os/osSetTimer.c index c969461b..528ec225 100644 --- a/lib/src/os/osSetTimer.c +++ b/lib/src/os/osSetTimer.c @@ -10,8 +10,7 @@ GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/osSetTimer.s") extern OSTimer *D_800E4910; -u32 osSetTimer(OSTimer *t, OSTime value, OSTime interval, OSMesgQueue *mq, OSMesg msg) -{ +u32 osSetTimer(OSTimer *t, OSTime value, OSTime interval, OSMesgQueue *mq, OSMesg msg) { OSTime time; t->next = NULL; t->prev = NULL; diff --git a/lib/src/os/osStartThread.c b/lib/src/os/osStartThread.c index 0d124761..f1325574 100644 --- a/lib/src/os/osStartThread.c +++ b/lib/src/os/osStartThread.c @@ -9,37 +9,31 @@ extern OSThread *__RunQueue; //__osRunQueue void osStartThread(OSThread *t) { register u32 saveMask = __osDisableInt(); - switch (t->state) - { - case OS_STATE_WAITING: - t->state = OS_STATE_RUNNABLE; - __osEnqueueThread(&__RunQueue, t); - break; - case OS_STATE_STOPPED: - if (t->queue == NULL || t->queue == &__RunQueue) - { + switch (t->state) { + case OS_STATE_WAITING: t->state = OS_STATE_RUNNABLE; __osEnqueueThread(&__RunQueue, t); - } - else - { - t->state = OS_STATE_WAITING; - __osEnqueueThread(t->queue, t); - __osEnqueueThread(&__RunQueue, __osPopThread(t->queue)); - } - break; + break; + case OS_STATE_STOPPED: + if (t->queue == NULL || t->queue == &__RunQueue) { + t->state = OS_STATE_RUNNABLE; + __osEnqueueThread(&__RunQueue, t); + } + else { + t->state = OS_STATE_WAITING; + __osEnqueueThread(t->queue, t); + __osEnqueueThread(&__RunQueue, __osPopThread(t->queue)); + } + break; } - if (__osRunningThread == NULL) - { + if (__osRunningThread == NULL) { __osDispatchThread(); } - else - { - if (__osRunningThread->priority < __RunQueue->priority) - { + else { + if (__osRunningThread->priority < __RunQueue->priority) { __osRunningThread->state = OS_STATE_RUNNABLE; __osEnqueueAndYield(&__RunQueue); } } __osRestoreInt(saveMask); -} \ No newline at end of file +} diff --git a/lib/src/os/osStopThread.c b/lib/src/os/osStopThread.c index 4d445397..5e163766 100644 --- a/lib/src/os/osStopThread.c +++ b/lib/src/os/osStopThread.c @@ -5,29 +5,25 @@ extern OSThread *__osRunningThread; -void osStopThread(OSThread *t) -{ +void osStopThread(OSThread *t) { register u32 saveMask = __osDisableInt(); register u16 state; - if (t == NULL) - { + if (t == NULL) { state = OS_STATE_RUNNING; } - else - { + else { state = t->state; } - switch (state) - { - case OS_STATE_RUNNING: - __osRunningThread->state = OS_STATE_STOPPED; - __osEnqueueAndYield(NULL); - break; - case OS_STATE_RUNNABLE: - case OS_STATE_WAITING: - t->state = OS_STATE_STOPPED; - __osDequeueThread(t->queue, t); - break; + switch (state) { + case OS_STATE_RUNNING: + __osRunningThread->state = OS_STATE_STOPPED; + __osEnqueueAndYield(NULL); + break; + case OS_STATE_RUNNABLE: + case OS_STATE_WAITING: + t->state = OS_STATE_STOPPED; + __osDequeueThread(t->queue, t); + break; } __osRestoreInt(saveMask); -} \ No newline at end of file +} diff --git a/lib/src/os/osTimer.c b/lib/src/os/osTimer.c index 14615318..c1859350 100644 --- a/lib/src/os/osTimer.c +++ b/lib/src/os/osTimer.c @@ -33,15 +33,14 @@ void __osTimerServicesInit(void) } #endif -void __osTimerInterrupt(void) -{ +void __osTimerInterrupt(void) { OSTimer *t; u32 count; u32 elapsed_cycles; if (D_800E4910->next == D_800E4910) return; - while (1){ + while (1) { t = D_800E4910->next; if (t == D_800E4910){ __osSetCompare(0); @@ -55,8 +54,7 @@ void __osTimerInterrupt(void) t->remaining -= elapsed_cycles; __osSetTimerIntr(t->remaining); return; - } - else{ + } else { t->prev->next = t->next; t->next->prev = t->prev; t->next = NULL; @@ -75,8 +73,7 @@ void __osTimerInterrupt(void) #if 1 GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSetTimerIntr.s") #else -void __osSetTimerIntr(OSTime tim) -{ +void __osSetTimerIntr(OSTime tim) { OSTime NewTime; u32 savedMask; savedMask = __osDisableInt(); @@ -88,16 +85,14 @@ void __osSetTimerIntr(OSTime tim) #endif -OSTime __osInsertTimer(OSTimer *t) -{ +OSTime __osInsertTimer(OSTimer *t) { OSTimer *timep; OSTime tim; u32 savedMask; savedMask = __osDisableInt(); for (timep = D_800E4910->next, tim = t->remaining; timep != D_800E4910 && tim > timep->remaining; - tim -= timep->remaining, timep = timep->next) - { + tim -= timep->remaining, timep = timep->next) { ; } t->remaining = tim; @@ -109,4 +104,4 @@ OSTime __osInsertTimer(OSTimer *t) timep->prev = t; __osRestoreInt(savedMask); return tim; -} \ No newline at end of file +} diff --git a/lib/src/os/osViMgr.c b/lib/src/os/osViMgr.c index f64bb24d..fceee4d8 100644 --- a/lib/src/os/osViMgr.c +++ b/lib/src/os/osViMgr.c @@ -25,13 +25,11 @@ extern OSIoMesg viCounterMsg; //viCounterMsg void viMgrMain(void *arg); -void osCreateViManager(OSPri pri) -{ +void osCreateViManager(OSPri pri) { u32 savedMask; OSPri oldPri; OSPri myPri; - if (__osViDevMgr.active == 0) - { + if (__osViDevMgr.active == 0) { __osTimerServicesInit(); osCreateMesgQueue(&viEventQueue, viEventBuf, 5); viRetraceMsg.hdr.type = OS_MESG_TYPE_VRETRACE; @@ -44,8 +42,7 @@ void osCreateViManager(OSPri pri) osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg); oldPri = -1; myPri = osGetThreadPri(NULL); - if (myPri < pri) - { + if (myPri < pri) { oldPri = myPri; osSetThreadPri(NULL, pri); } @@ -61,8 +58,7 @@ void osCreateViManager(OSPri pri) __osViInit(); osStartThread(&viThread); __osRestoreInt(savedMask); - if (oldPri != -1) - { + if (oldPri != -1) { osSetThreadPri(0, oldPri); } } diff --git a/lib/src/os/osViSwapBuffer.c b/lib/src/os/osViSwapBuffer.c index ad00dcae..f208cd62 100644 --- a/lib/src/os/osViSwapBuffer.c +++ b/lib/src/os/osViSwapBuffer.c @@ -5,7 +5,7 @@ extern OSViContext *__osViNext; -void osViSwapBuffer(void *frameBufPtr){ +void osViSwapBuffer(void *frameBufPtr) { u32 saveMask = __osDisableInt(); __osViNext->buffer = frameBufPtr; __osViNext->unk00 |= 0x10;