diff options
| author | Faris Awan <58312479+farisawan-2000@users.noreply.github.com> | 2021-04-28 00:35:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-27 22:35:30 -0600 |
| commit | 5c231135925adaf51e9ba366b95d4c5574c74ac8 (patch) | |
| tree | 81ba79e16a091332073a13b2de3dfaf6a44ad1ac /src/os/osCreatePiManager.c | |
| parent | f4532f26bb7c127f20d43983964236c891f3f419 (diff) | |
Match/split all of libultra (#23)
* libultra from sm64 integrated; 3 libultra functions matched
* All of libultra done!
authored-by: farisawan-2000 <farisawan.2000@gmail.com>
Diffstat (limited to 'src/os/osCreatePiManager.c')
| -rw-r--r-- | src/os/osCreatePiManager.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/os/osCreatePiManager.c b/src/os/osCreatePiManager.c new file mode 100644 index 000000000..7e182b748 --- /dev/null +++ b/src/os/osCreatePiManager.c @@ -0,0 +1,61 @@ +#include "libultra_internal.h" + +#define OS_PI_MGR_MESG_BUFF_SIZE 1 + +#ifdef VERSION_SH // TODO: In libreultra this is in an include +extern OSPiHandle *CartRomHandle; +extern OSPiHandle *LeoDiskHandle; +#endif + +OSMgrArgs __osPiDevMgr = { 0 }; +#if defined(VERSION_EU) || defined(VERSION_SH) +OSPiHandle *__osPiTable = NULL; +#endif +#ifdef VERSION_SH +OSPiHandle *__osCurrentHandle[2] = { &CartRomHandle, &LeoDiskHandle }; +#endif +OSThread piMgrThread; +u32 piMgrStack[0x400]; // stack bottom +OSMesgQueue __osPiMesgQueue; +OSMesg piMgrMesgBuff[OS_PI_MGR_MESG_BUFF_SIZE + 1]; + +extern u32 gOsPiAccessQueueCreated; +extern OSMesgQueue gOsPiMessageQueue; +void __osDevMgrMain(void *); + +void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt) { + u32 int_disabled; + OSPri newPri; + OSPri currentPri; + + if (!__osPiDevMgr.initialized) { + osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt); + osCreateMesgQueue(&__osPiMesgQueue, &piMgrMesgBuff[0], OS_PI_MGR_MESG_BUFF_SIZE); + if (!gOsPiAccessQueueCreated) { + __osPiCreateAccessQueue(); + } // what is this constant geez + osSetEventMesg(OS_EVENT_PI, &__osPiMesgQueue, (void *) 0x22222222); + newPri = -1; + currentPri = osGetThreadPri(NULL); + if (currentPri < pri) { + newPri = currentPri; + osSetThreadPri(NULL, pri); + } + int_disabled = __osDisableInt(); + __osPiDevMgr.initialized = TRUE; + __osPiDevMgr.mgrThread = &piMgrThread; + __osPiDevMgr.cmdQueue = cmdQ; + __osPiDevMgr.eventQueue = &__osPiMesgQueue; + __osPiDevMgr.accessQueue = &gOsPiMessageQueue; + __osPiDevMgr.dma_func = osPiRawStartDma; +#if defined(VERSION_EU) || defined(VERSION_SH) + __osPiDevMgr.edma_func = osEPiRawStartDma; +#endif + osCreateThread(&piMgrThread, 0, __osDevMgrMain, (void *) &__osPiDevMgr, &piMgrStack[0x400], pri); + osStartThread(&piMgrThread); + __osRestoreInt(int_disabled); + if (newPri != -1) { + osSetThreadPri(NULL, newPri); + } + } +} |
