diff options
| author | MegaMech <inkstudios1@hotmail.com> | 2024-05-02 12:21:35 -0600 |
|---|---|---|
| committer | MegaMech <inkstudios1@hotmail.com> | 2024-05-02 12:21:35 -0600 |
| commit | e3774dc3771aae8f4b8f775b0afe38ce935393fd (patch) | |
| tree | ebbb4e1d54a4a258d239efb2b52a09138f5fc16c /src/os | |
| parent | c76d7d4b9bd3fd5999a3bf2c2ddd7cda4f1a9b14 (diff) | |
Fixes
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/__osDevMgrMain.c | 12 | ||||
| -rw-r--r-- | src/os/__osSpDeviceBusy.c | 2 | ||||
| -rw-r--r-- | src/os/__osSpSetPc.c | 2 | ||||
| -rw-r--r-- | src/os/__osViInit.c | 11 | ||||
| -rw-r--r-- | src/os/__osViSwapContext.c | 28 | ||||
| -rw-r--r-- | src/os/contramread.c | 2 | ||||
| -rw-r--r-- | src/os/contramwrite.c | 2 | ||||
| -rw-r--r-- | src/os/controller.h | 2 | ||||
| -rw-r--r-- | src/os/libultra_internal.h | 25 | ||||
| -rw-r--r-- | src/os/math/llmuldiv.c | 53 | ||||
| -rw-r--r-- | src/os/osCreatePiManager.c | 4 | ||||
| -rw-r--r-- | src/os/osCreateViManager.c | 4 | ||||
| -rw-r--r-- | src/os/osInitialize.c | 3 | ||||
| -rw-r--r-- | src/os/osViBlack.c | 5 | ||||
| -rw-r--r-- | src/os/osViSetMode.c | 2 | ||||
| -rw-r--r-- | src/os/osViSetSpecialFeatures.c | 2 | ||||
| -rw-r--r-- | src/os/osViSwapBuffer.c | 2 | ||||
| -rw-r--r-- | src/os/piint.h | 3 |
18 files changed, 51 insertions, 113 deletions
diff --git a/src/os/__osDevMgrMain.c b/src/os/__osDevMgrMain.c index 10e074d29..37c2b7a31 100644 --- a/src/os/__osDevMgrMain.c +++ b/src/os/__osDevMgrMain.c @@ -23,7 +23,7 @@ void __osDevMgrMain(void *args) { ret = 0; sp34 = (OSMgrArgs *) args; while (true) { - osRecvMesg(sp34->cmdQueue, (OSMesg) &mb, OS_MESG_BLOCK); + osRecvMesg(sp34->cmdQueue, (OSMesg *) &mb, OS_MESG_BLOCK); if (mb->piHandle != NULL && mb->piHandle->type == 2 && (mb->piHandle->transferInfo.cmdType == 0 || mb->piHandle->transferInfo.cmdType == 1)) { @@ -43,7 +43,7 @@ void __osDevMgrMain(void *args) { __osEPiRawWriteIo(mb->piHandle, 0x05000510, (sp24->bmCtlShadow | 0x80000000)); while (true) { osRecvMesg(sp34->eventQueue, &em, OS_MESG_BLOCK); - sp30 = osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); + sp30 = osSendMesg(mb->hdr.retQueue, (OSMesg)mb, OS_MESG_NOBLOCK); if (sp2c != 1 || mb->piHandle->transferInfo.errStatus != 0) { break; } @@ -57,20 +57,20 @@ void __osDevMgrMain(void *args) { switch (mb->hdr.type) { case 11: osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->dma_func(OS_READ, mb->devAddr, mb->dramAddr, mb->size); + ret = sp34->piDmaCallback(OS_READ, mb->devAddr, mb->dramAddr, mb->size); break; case 12: osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->dma_func(OS_WRITE, mb->devAddr, mb->dramAddr, mb->size); + ret = sp34->piDmaCallback(OS_WRITE, mb->devAddr, mb->dramAddr, mb->size); break; case 15: osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->edma_func(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, + ret = sp34->epiDmaCallback(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, mb->size); break; case 16: osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->edma_func(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, + ret = sp34->epiDmaCallback(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, mb->size); break; case 10: diff --git a/src/os/__osSpDeviceBusy.c b/src/os/__osSpDeviceBusy.c index a40c402a2..e2bb83f4f 100644 --- a/src/os/__osSpDeviceBusy.c +++ b/src/os/__osSpDeviceBusy.c @@ -3,7 +3,7 @@ s32 __osSpDeviceBusy() { register u32 status = HW_REG(SP_STATUS_REG, u32); - if (status & (SPSTATUS_IO_FULL | SPSTATUS_DMA_FULL | SPSTATUS_DMA_BUSY)) { + if (status & (SP_STATUS_IO_FULL | SP_STATUS_DMA_FULL | SP_STATUS_DMA_BUSY)) { return 1; } return 0; diff --git a/src/os/__osSpSetPc.c b/src/os/__osSpSetPc.c index d074590c9..6a3933048 100644 --- a/src/os/__osSpSetPc.c +++ b/src/os/__osSpSetPc.c @@ -3,7 +3,7 @@ s32 __osSpSetPc(void *pc) { register u32 status = HW_REG(SP_STATUS_REG, u32); - if (!(status & SPSTATUS_HALT)) { + if (!(status & SP_CLR_HALT)) { return -1; } else { HW_REG(SP_PC_REG, void *) = pc; diff --git a/src/os/__osViInit.c b/src/os/__osViInit.c index c4e39e475..65b78ac6a 100644 --- a/src/os/__osViInit.c +++ b/src/os/__osViInit.c @@ -1,7 +1,8 @@ +#include <libultraship.h> +#include <libultra/vi.h> #include "libultra_internal.h" #include "hardware.h" - -extern u32 osTvType; +#include <stubs.h> OSViContext sViContexts[2] = { 0 }; OSViContext *__osViCurr = &sViContexts[0]; @@ -20,10 +21,10 @@ void __osViInit(void) { __osViNext->retraceCount = 1; __osViCurr->retraceCount = 1; - if (osTvType == TV_TYPE_PAL) { + if (osTvType == OS_TV_PAL) { __osViNext->modep = &osViModePalLan1; osViClock = 0x02F5B2D2; - } else if (osTvType == TV_TYPE_MPAL) { + } else if (osTvType == OS_TV_MPAL) { __osViNext->modep = &osViModeMpalLan1; osViClock = 0x02E6025C; } else { @@ -31,7 +32,7 @@ void __osViInit(void) { osViClock = 0x02E6D354; } - __osViNext->unk00 = 0x20; + __osViNext->state = 0x20; __osViNext->features = __osViNext->modep->comRegs.ctrl; while (HW_REG(VI_CURRENT_REG, u32) > 0xa) { ; diff --git a/src/os/__osViSwapContext.c b/src/os/__osViSwapContext.c index 990cb11fd..a7008681b 100644 --- a/src/os/__osViSwapContext.c +++ b/src/os/__osViSwapContext.c @@ -18,28 +18,28 @@ void __osViSwapContext() { field = HW_REG(VI_V_CURRENT_LINE_REG, u32) & 1; s2 = osVirtualToPhysical(s1->buffer); origin = (s0->fldRegs[field].origin) + s2; - if (s1->unk00 & 2) { - s1->unk20 |= s0->comRegs.xScale & ~0xfff; + if (s1->state & 2) { + s1->x.scale |= s0->comRegs.xScale & ~0xfff; } else { - s1->unk20 = s0->comRegs.xScale; + s1->x.scale = s0->comRegs.xScale; } - if (s1->unk00 & 4) { + if (s1->state & 4) { sp34 = (u32)(s0->fldRegs[field].yScale & 0xfff); - s1->unk2c = s1->unk24 * sp34; - s1->unk2c |= s0->fldRegs[field].yScale & ~0xfff; + s1->y.scale = s1->y.factor * sp34; + s1->y.scale |= s0->fldRegs[field].yScale & ~0xfff; } else { - s1->unk2c = s0->fldRegs[field].yScale; + s1->y.scale = s0->fldRegs[field].yScale; } hStart = s0->comRegs.hStart; - if (s1->unk00 & 0x20) { + if (s1->state & 0x20) { hStart = 0; } - if (s1->unk00 & 0x40) { - s1->unk2c = 0; + if (s1->state & 0x40) { + s1->y.scale = 0; origin = osVirtualToPhysical(s1->buffer); } - if (s1->unk00 & 0x80) { - s1->unk2c = (s1->unk28 << 0x10) & 0x3ff0000; + if (s1->state & 0x80) { + s1->y.scale = (s1->y.offset << 0x10) & 0x3ff0000; origin = osVirtualToPhysical(s1->buffer); } HW_REG(VI_ORIGIN_REG, u32) = origin; @@ -52,8 +52,8 @@ void __osViSwapContext() { HW_REG(VI_V_START_REG, u32) = s0->fldRegs[field].vStart; HW_REG(VI_V_BURST_REG, u32) = s0->fldRegs[field].vBurst; HW_REG(VI_INTR_REG, u32) = s0->fldRegs[field].vIntr; - HW_REG(VI_X_SCALE_REG, u32) = s1->unk20; - HW_REG(VI_Y_SCALE_REG, u32) = s1->unk2c; + HW_REG(VI_X_SCALE_REG, u32) = s1->x.scale; + HW_REG(VI_Y_SCALE_REG, u32) = s1->y.scale; HW_REG(VI_CONTROL_REG, u32) = s1->features; __osViNext = __osViCurr; __osViCurr = s1; diff --git a/src/os/contramread.c b/src/os/contramread.c index 5f3b6e68d..b08409690 100644 --- a/src/os/contramread.c +++ b/src/os/contramread.c @@ -1,5 +1,5 @@ +#include <libultraship.h> #include "libultra_internal.h" -#include "PR/rcp.h" #include "controller.h" extern s32 __osPfsGetStatus(OSMesgQueue *, s32); diff --git a/src/os/contramwrite.c b/src/os/contramwrite.c index ebb8d77c5..c26fbfccb 100644 --- a/src/os/contramwrite.c +++ b/src/os/contramwrite.c @@ -1,5 +1,5 @@ +#include <libultraship.h> #include "libultra_internal.h" -#include "PR/rcp.h" #include "controller.h" extern s32 __osPfsGetStatus(OSMesgQueue *, s32); diff --git a/src/os/controller.h b/src/os/controller.h index 92af3d4bd..9035f6ffc 100644 --- a/src/os/controller.h +++ b/src/os/controller.h @@ -1,8 +1,6 @@ #ifndef _CONTROLLER_H #define _CONTROLLER_H -#include "PR/os_internal.h" #include <libultraship.h> -#include "PR/rcp.h" //should go somewhere else but #define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0]))) diff --git a/src/os/libultra_internal.h b/src/os/libultra_internal.h index dafdbd8a9..dd1ac555f 100644 --- a/src/os/libultra_internal.h +++ b/src/os/libultra_internal.h @@ -1,15 +1,8 @@ #ifndef _LIBULTRA_INTERNAL_H_ #define _LIBULTRA_INTERNAL_H_ #include <libultraship.h> -#include <PR/os_thread.h> #include "macros.h" -typedef struct __OSEventState -{ - OSMesgQueue *messageQueue; - OSMesg message; -} __OSEventState; - typedef struct __osThreadTail { OSThread *next; @@ -53,15 +46,15 @@ extern OSThread *__osRunningThread; extern u32 D_80365E00[15]; extern u32 D_80365E3C; -typedef struct { - u32 initialized; // probably something like initialized? - OSThread *mgrThread; - OSMesgQueue *cmdQueue; - OSMesgQueue *eventQueue; - OSMesgQueue *accessQueue; - s32 (*dma_func)(s32, u32, void *, size_t); - s32 (*edma_func)(OSPiHandle*, s32, u32, void *, size_t); -} OSMgrArgs; +// typedef struct { +// u32 initialized; // probably something like initialized? +// OSThread *mgrThread; +// OSMesgQueue *cmdQueue; +// OSMesgQueue *eventQueue; +// OSMesgQueue *accessQueue; +// s32 (*dma_func)(s32, u32, void *, size_t); +// s32 (*edma_func)(OSPiHandle*, s32, u32, void *, size_t); +// } OSMgrArgs; s32 __osDisableInt(void); void __osRestoreInt(s32); diff --git a/src/os/math/llmuldiv.c b/src/os/math/llmuldiv.c deleted file mode 100644 index 2af91aae5..000000000 --- a/src/os/math/llmuldiv.c +++ /dev/null @@ -1,53 +0,0 @@ -unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1) -{ - return a0 >> a1; -} -unsigned long long __ull_rem(unsigned long long a0, unsigned long long a1) -{ - return a0 % a1; -} -unsigned long long __ull_div(unsigned long long a0, unsigned long long a1) -{ - return a0 / a1; -} - -unsigned long long __ll_lshift(unsigned long long a0, unsigned long long a1) -{ - return a0 << a1; -} - -long long __ll_rem(unsigned long long a0, long long a1) -{ - return a0 % a1; -} - -long long __ll_div(long long a0, long long a1) -{ - return a0 / a1; -} - -unsigned long long __ll_mul(unsigned long long a0, unsigned long long a1) -{ - return a0 * a1; -} - -void __ull_divremi(unsigned long long *div, unsigned long long *rem, unsigned long long a2, unsigned short a3) -{ - *div = a2 / a3; - *rem = a2 % a3; -} -long long __ll_mod(long long a0, long long a1) -{ - long long tmp = a0 % a1; - if ((tmp < 0 && a1 > 0) || (tmp > 0 && a1 < 0)) - { - - tmp += a1; - } - return tmp; -} - -long long __ll_rshift(long long a0, long long a1) -{ - return a0 >> a1; -} diff --git a/src/os/osCreatePiManager.c b/src/os/osCreatePiManager.c index c65201934..a9a9888cc 100644 --- a/src/os/osCreatePiManager.c +++ b/src/os/osCreatePiManager.c @@ -44,8 +44,8 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC __osPiDevMgr.cmdQueue = cmdQ; __osPiDevMgr.eventQueue = &__osPiMesgQueue; __osPiDevMgr.accessQueue = &gOsPiMessageQueue; - __osPiDevMgr.dma_func = osPiRawStartDma; - __osPiDevMgr.edma_func = osEPiRawStartDma; + __osPiDevMgr.piDmaCallback = osPiRawStartDma; + __osPiDevMgr.epiDmaCallback = osEPiRawStartDma; osCreateThread(&piMgrThread, 0, __osDevMgrMain, (void *) &__osPiDevMgr, &piMgrStack[0x400], pri); osStartThread(&piMgrThread); __osRestoreInt(int_disabled); diff --git a/src/os/osCreateViManager.c b/src/os/osCreateViManager.c index 950f43d81..e2635fbba 100644 --- a/src/os/osCreateViManager.c +++ b/src/os/osCreateViManager.c @@ -46,8 +46,8 @@ void osCreateViManager(OSPri pri) { viMgrMainArgs.cmdQueue = &__osViMesgQueue; viMgrMainArgs.eventQueue = &__osViMesgQueue; viMgrMainArgs.accessQueue = NULL; - viMgrMainArgs.dma_func = NULL; - viMgrMainArgs.edma_func = NULL; + viMgrMainArgs.piDmaCallback = NULL; + viMgrMainArgs.epiDmaCallback = NULL; osCreateThread(&viMgrThread, 0, viMgrMain, (void *) &viMgrMainArgs, &viMgrStack[0x400], pri); __osViInit(); diff --git a/src/os/osInitialize.c b/src/os/osInitialize.c index 292cbbc1c..254b9a036 100644 --- a/src/os/osInitialize.c +++ b/src/os/osInitialize.c @@ -1,4 +1,5 @@ #include "libultra_internal.h" +#include <stubs.h> #include "hardware.h" #include <macros.h> @@ -58,7 +59,7 @@ void osInitialize(void) { } osClockRate = osClockRate * 3 / 4; if (osResetType == RESET_TYPE_COLD_RESET) { - bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer)); + //bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer)); } eu_sp30 = HW_REG(PI_STATUS_REG, u32); diff --git a/src/os/osViBlack.c b/src/os/osViBlack.c index 782e3b13c..3d0ffc0ca 100644 --- a/src/os/osViBlack.c +++ b/src/os/osViBlack.c @@ -1,3 +1,4 @@ +#include <libultraship.h> #include "libultra_internal.h" extern OSViContext *__osViNext; @@ -6,9 +7,9 @@ extern OSViContext *__osViNext; void osViBlack(u8 active) { register u32 int_disabled = __osDisableInt(); if (active) { - __osViNext->unk00 |= 0x20; + __osViNext->state |= 0x20; } else { - __osViNext->unk00 &= ~0x20; + __osViNext->state &= ~0x20; } __osRestoreInt(int_disabled); } diff --git a/src/os/osViSetMode.c b/src/os/osViSetMode.c index 716596fb5..ec6f7db8f 100644 --- a/src/os/osViSetMode.c +++ b/src/os/osViSetMode.c @@ -5,7 +5,7 @@ extern OSViContext *__osViNext; void osViSetMode(OSViMode *mode) { register u32 int_disabled = __osDisableInt(); __osViNext->modep = mode; - __osViNext->unk00 = 1; + __osViNext->state = 1; __osViNext->features = __osViNext->modep->comRegs.ctrl; __osRestoreInt(int_disabled); } diff --git a/src/os/osViSetSpecialFeatures.c b/src/os/osViSetSpecialFeatures.c index c1bf52b63..23eb98d89 100644 --- a/src/os/osViSetSpecialFeatures.c +++ b/src/os/osViSetSpecialFeatures.c @@ -30,6 +30,6 @@ void osViSetSpecialFeatures(u32 func) { __osViNext->features &= ~OS_VI_DITHER_FILTER; __osViNext->features |= __osViNext->modep->comRegs.ctrl & (OS_VI_UNK200 | OS_VI_UNK100); } - __osViNext->unk00 |= 8; + __osViNext->state |= 8; __osRestoreInt(int_disabled); } diff --git a/src/os/osViSwapBuffer.c b/src/os/osViSwapBuffer.c index eb341b6da..7908aeade 100644 --- a/src/os/osViSwapBuffer.c +++ b/src/os/osViSwapBuffer.c @@ -6,6 +6,6 @@ void osViSwapBuffer(void *vaddr) { u32 int_disabled = __osDisableInt(); __osViNext->buffer = vaddr; //! @todo figure out what this flag means - __osViNext->unk00 |= 0x10; + __osViNext->state |= 0x10; __osRestoreInt(int_disabled); } diff --git a/src/os/piint.h b/src/os/piint.h index 8b2a479a2..c636e274a 100644 --- a/src/os/piint.h +++ b/src/os/piint.h @@ -1,8 +1,5 @@ #ifndef _PIINT_H #define _PIINT_H -#include "PR/os_internal.h" -#include "PR/rcp.h" -#include "PR/os_pi.h" #include <libultraship.h> //https://github.com/LuigiBlood/64dd/wiki/Memory-Map |
