mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 14:34:32 +00:00
Message Queues, Threads, and surroundings cleanup (#1178)
* message queues, threads, and surroundings cleanup * Format, make the formatter prefer clang-format-11 if found * Fix __osThreadTail type * Q -> Queue, thread defines renamed * Reformat, add missing NULL * Suggested changes and further casting cleanup * Reformat * padmgr name fixes
This commit is contained in:
parent
9984c267d9
commit
7068ad3703
45 changed files with 311 additions and 296 deletions
|
@ -31,7 +31,7 @@ void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, cons
|
|||
const char* DmaMgr_GetFileNameImpl(u32 vrom);
|
||||
const char* DmaMgr_GetFileName(u32 vrom);
|
||||
void DmaMgr_ProcessMsg(DmaRequest* req);
|
||||
void DmaMgr_ThreadEntry(void* arg0);
|
||||
void DmaMgr_ThreadEntry(void* arg);
|
||||
s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg);
|
||||
s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size);
|
||||
void DmaMgr_Init(void);
|
||||
|
@ -79,7 +79,7 @@ s32 sprintf(char* dst, const char* fmt, ...);
|
|||
void __osPiCreateAccessQueue(void);
|
||||
void __osPiGetAccess(void);
|
||||
void __osPiRelAccess(void);
|
||||
s32 osSendMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag);
|
||||
s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flag);
|
||||
void osStopThread(OSThread* thread);
|
||||
void osViExtendVStart(u32 arg0);
|
||||
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag);
|
||||
|
@ -101,7 +101,7 @@ void __osSetSR(u32);
|
|||
u32 __osGetSR(void);
|
||||
void osWritebackDCache(void* vaddr, s32 nbytes);
|
||||
void* osViGetNextFramebuffer(void);
|
||||
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt);
|
||||
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQueue, OSMesg* cmdBuf, s32 cmdMsgCnt);
|
||||
void __osDevMgrMain(void* arg);
|
||||
s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size);
|
||||
u32 osVirtualToPhysical(void* vaddr);
|
||||
|
@ -122,7 +122,7 @@ void osInvalICache(void* vaddr, s32 nbytes);
|
|||
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 count);
|
||||
void osInvalDCache(void* vaddr, s32 nbytes);
|
||||
s32 __osSiDeviceBusy(void);
|
||||
s32 osJamMesg(OSMesgQueue* mq, OSMesg mesg, s32 flag);
|
||||
s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag);
|
||||
void osSetThreadPri(OSThread* thread, OSPri pri);
|
||||
OSPri osGetThreadPri(OSThread* thread);
|
||||
s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data);
|
||||
|
@ -1646,7 +1646,7 @@ void PadMgr_HandlePreNMI(PadMgr* padmgr);
|
|||
// This function must remain commented out, because it is called incorrectly in
|
||||
// fault.c (actual bug in game), and the compiler notices and won't compile it
|
||||
// void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode);
|
||||
void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* siIntMsgQ, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack);
|
||||
void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack);
|
||||
void Sched_SwapFrameBuffer(CfbInfo* cfbInfo);
|
||||
void func_800C84E4(SchedContext* sc, CfbInfo* cfbInfo);
|
||||
void Sched_HandleReset(SchedContext* sc);
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef struct {
|
|||
|
||||
void IrqMgr_Init(IrqMgr* irqMgr, void* stack, OSPri pri, u8 retraceCount);
|
||||
|
||||
void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQ);
|
||||
void IrqMgr_AddClient(IrqMgr* irqMgr, IrqMgrClient* client, OSMesgQueue* msgQueue);
|
||||
void IrqMgr_RemoveClient(IrqMgr* irqMgr, IrqMgrClient* client);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,12 +12,12 @@ typedef struct {
|
|||
|
||||
typedef struct PadMgr {
|
||||
/* 0x0000 */ OSContStatus padStatus[4];
|
||||
/* 0x0010 */ OSMesg serialMsgBuf[1];
|
||||
/* 0x0010 */ OSMesg serialLockMsgBuf[1];
|
||||
/* 0x0014 */ OSMesg lockMsgBuf[1];
|
||||
/* 0x0018 */ OSMesg interruptMsgBuf[4];
|
||||
/* 0x0028 */ OSMesgQueue serialMsgQ;
|
||||
/* 0x0040 */ OSMesgQueue lockMsgQ;
|
||||
/* 0x0058 */ OSMesgQueue interruptMsgQ;
|
||||
/* 0x0028 */ OSMesgQueue serialLockQueue;
|
||||
/* 0x0040 */ OSMesgQueue lockQueue;
|
||||
/* 0x0058 */ OSMesgQueue interruptQueue;
|
||||
/* 0x0070 */ IrqMgrClient irqClient;
|
||||
/* 0x0078 */ IrqMgr* irqMgr;
|
||||
/* 0x0080 */ OSThread thread;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "message.h"
|
||||
|
||||
#define SIAccessQueueSize 2
|
||||
#define BLOCKSIZE 32
|
||||
#define MAXCONTROLLERS 4
|
||||
#define PFS_ONE_PAGE 8
|
||||
|
|
|
@ -30,6 +30,7 @@ typedef union {
|
|||
/* 0x00 */ f32 f_odd;
|
||||
/* 0x04 */ f32 f_even;
|
||||
} f;
|
||||
f64 d;
|
||||
} __OSfp; // size = 0x08
|
||||
|
||||
typedef struct {
|
||||
|
@ -63,4 +64,9 @@ typedef struct OSThread {
|
|||
/* 0x20 */ __OSThreadContext context;
|
||||
} OSThread; // size = 0x1B0
|
||||
|
||||
typedef struct {
|
||||
OSThread* next;
|
||||
OSPri priority;
|
||||
} __OSThreadTail; // size = 0x8
|
||||
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@ typedef struct {
|
|||
/* 0x08 */ OSViMode* modep;
|
||||
/* 0x0C */ u32 features;
|
||||
/* 0x10 */ OSMesgQueue* mq;
|
||||
/* 0x14 */ OSMesg* msg;
|
||||
/* 0x14 */ OSMesg msg;
|
||||
/* 0x18 */ __OSViScale x;
|
||||
/* 0x24 */ __OSViScale y;
|
||||
} OSViContext; // size = 0x30
|
||||
|
|
|
@ -28,7 +28,7 @@ extern OSViMode osViModePalLan1;
|
|||
extern s32 osViClock;
|
||||
extern u32 __osShutdown;
|
||||
extern OSHWIntr __OSGlobalIntMask;
|
||||
extern OSThread* __osThreadTail[];
|
||||
extern __OSThreadTail __osThreadTail;
|
||||
extern OSThread* __osRunQueue;
|
||||
extern OSThread* __osActiveQueue;
|
||||
extern OSThread* __osRunningThread;
|
||||
|
@ -45,7 +45,7 @@ extern u32 __additional_scanline;
|
|||
extern u8 gBuildTeam[];
|
||||
extern u8 gBuildDate[];
|
||||
extern u8 gBuildMakeOption[];
|
||||
extern OSMesgQueue gPiMgrCmdQ;
|
||||
extern OSMesgQueue gPiMgrCmdQueue;
|
||||
extern OSViMode gViConfigMode;
|
||||
extern u8 D_80013960;
|
||||
extern OSMesgQueue __osPiAccessQueue;
|
||||
|
|
|
@ -42,13 +42,28 @@
|
|||
#define REGION_JP 2
|
||||
#define REGION_EU 3
|
||||
|
||||
#define Z_PRIORITY_MAIN 10
|
||||
#define Z_PRIORITY_GRAPH 11
|
||||
#define Z_PRIORITY_AUDIOMGR 12
|
||||
#define Z_PRIORITY_PADMGR 14
|
||||
#define Z_PRIORITY_SCHED 15
|
||||
#define Z_PRIORITY_DMAMGR 16
|
||||
#define Z_PRIORITY_IRQMGR 17
|
||||
#define THREAD_PRI_IDLE_INIT 10
|
||||
#define THREAD_PRI_MAIN_INIT 10
|
||||
#define THREAD_PRI_DMAMGR_LOW 10 // Used when decompressing files
|
||||
#define THREAD_PRI_GRAPH 11
|
||||
#define THREAD_PRI_AUDIOMGR 12
|
||||
#define THREAD_PRI_PADMGR 14
|
||||
#define THREAD_PRI_MAIN 15
|
||||
#define THREAD_PRI_SCHED 15
|
||||
#define THREAD_PRI_DMAMGR 16
|
||||
#define THREAD_PRI_IRQMGR 17
|
||||
#define THREAD_PRI_FAULT_CLIENT (OS_PRIORITY_APPMAX - 1)
|
||||
#define THREAD_PRI_FAULT OS_PRIORITY_APPMAX
|
||||
|
||||
#define THREAD_ID_IDLE 1
|
||||
#define THREAD_ID_FAULT 2
|
||||
#define THREAD_ID_MAIN 3
|
||||
#define THREAD_ID_GRAPH 4
|
||||
#define THREAD_ID_SCHED 5
|
||||
#define THREAD_ID_PADMGR 7
|
||||
#define THREAD_ID_AUDIOMGR 10
|
||||
#define THREAD_ID_DMAMGR 18
|
||||
#define THREAD_ID_IRQMGR 19
|
||||
|
||||
#define STACK(stack, size) \
|
||||
u64 stack[ALIGN8(size) / sizeof(u64)]
|
||||
|
@ -118,9 +133,10 @@ typedef struct OSScTask {
|
|||
/* 0x08 */ u32 flags;
|
||||
/* 0x0C */ CfbInfo* framebuffer;
|
||||
/* 0x10 */ OSTask list;
|
||||
/* 0x50 */ OSMesgQueue* msgQ;
|
||||
/* 0x50 */ OSMesgQueue* msgQueue;
|
||||
/* 0x54 */ OSMesg msg;
|
||||
} OSScTask;
|
||||
/* 0x58 */ char unk_58[0x10];
|
||||
} OSScTask; // size = 0x68
|
||||
|
||||
typedef struct GraphicsContext {
|
||||
/* 0x0000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0"
|
||||
|
@ -130,11 +146,11 @@ typedef struct GraphicsContext {
|
|||
/* 0x0014 */ u32 unk_014;
|
||||
/* 0x0018 */ char unk_018[0x20];
|
||||
/* 0x0038 */ OSMesg msgBuff[0x08];
|
||||
/* 0x0058 */ OSMesgQueue* schedMsgQ;
|
||||
/* 0x0058 */ OSMesgQueue* schedMsgQueue;
|
||||
/* 0x005C */ OSMesgQueue queue;
|
||||
/* 0x0074 */ char unk_074[0x04];
|
||||
/* 0x0078 */ OSScTask task; // size of OSScTask might be wrong
|
||||
/* 0x00D0 */ char unk_0D0[0xE0];
|
||||
/* 0x0078 */ OSScTask task;
|
||||
/* 0x00E0 */ char unk_0E0[0xD0];
|
||||
/* 0x01B0 */ Gfx* workBuffer;
|
||||
/* 0x01B4 */ TwoHeadGfxArena work;
|
||||
/* 0x01C4 */ char unk_01C4[0xC0];
|
||||
|
@ -1576,9 +1592,9 @@ typedef struct {
|
|||
} FrameBufferSwap;
|
||||
|
||||
typedef struct {
|
||||
/* 0x0000 */ OSMesgQueue interruptQ;
|
||||
/* 0x0018 */ OSMesg intBuf[8];
|
||||
/* 0x0038 */ OSMesgQueue cmdQ;
|
||||
/* 0x0000 */ OSMesgQueue interruptQueue;
|
||||
/* 0x0018 */ OSMesg interruptMsgBuf[8];
|
||||
/* 0x0038 */ OSMesgQueue cmdQueue;
|
||||
/* 0x0050 */ OSMesg cmdMsgBuf[8];
|
||||
/* 0x0070 */ OSThread thread;
|
||||
/* 0x0220 */ OSScTask* audioListHead;
|
||||
|
@ -1607,18 +1623,14 @@ typedef struct {
|
|||
/* 0x0000 */ IrqMgr* irqMgr;
|
||||
/* 0x0004 */ SchedContext* sched;
|
||||
/* 0x0008 */ OSScTask audioTask;
|
||||
/* 0x0060 */ char unk_60[0x10];
|
||||
/* 0x0070 */ AudioTask* rspTask;
|
||||
/* 0x0074 */ OSMesgQueue unk_74;
|
||||
/* 0x008C */ OSMesg unk_8C;
|
||||
/* 0x0090 */ OSMesgQueue unk_90;
|
||||
/* 0x00A8 */ OSMesg unk_A8;
|
||||
/* 0x00AC */ OSMesgQueue unk_AC;
|
||||
/* 0x00C4 */ OSMesg unk_C4;
|
||||
/* 0x00C8 */ OSMesgQueue unk_C8;
|
||||
/* 0x00E0 */ OSMesg unk_E0;
|
||||
/* 0x00E4 */ char unk_E4[0x04];
|
||||
/* 0x00E8 */ OSThread unk_E8;
|
||||
/* 0x0074 */ OSMesgQueue interruptQueue;
|
||||
/* 0x008C */ OSMesg interruptMsgBuf[8];
|
||||
/* 0x00AC */ OSMesgQueue taskQueue;
|
||||
/* 0x00C4 */ OSMesg taskMsgBuf[1];
|
||||
/* 0x00C8 */ OSMesgQueue lockQueue;
|
||||
/* 0x00E0 */ OSMesg lockMsgBuf[1];
|
||||
/* 0x00E8 */ OSThread thread;
|
||||
} AudioMgr; // size = 0x298
|
||||
|
||||
struct ArenaNode;
|
||||
|
@ -1626,7 +1638,7 @@ struct ArenaNode;
|
|||
typedef struct Arena {
|
||||
/* 0x00 */ struct ArenaNode* head;
|
||||
/* 0x04 */ void* start;
|
||||
/* 0x08 */ OSMesgQueue lock;
|
||||
/* 0x08 */ OSMesgQueue lockQueue;
|
||||
/* 0x20 */ u8 unk_20;
|
||||
/* 0x21 */ u8 isInit;
|
||||
/* 0x22 */ u8 flag;
|
||||
|
@ -1793,7 +1805,6 @@ typedef struct {
|
|||
/* 0x28 */ u32 mode; // 0 if Y V0 is 1 and 2 if Y V0 is 2
|
||||
/* 0x2C */ char unk_2C[4];
|
||||
/* 0x30 */ OSScTask scTask;
|
||||
/* 0x88 */ char unk_88[0x10];
|
||||
/* 0x98 */ OSMesgQueue mq;
|
||||
/* 0xB0 */ OSMesg msg;
|
||||
/* 0xB4 */ JpegWork* workBuf;
|
||||
|
|
|
@ -716,7 +716,7 @@ typedef struct {
|
|||
/* 0x18 */ s32 bytesRemaining;
|
||||
/* 0x1C */ s8* isDone;
|
||||
/* 0x20 */ SoundFontSample sample;
|
||||
/* 0x30 */ OSMesgQueue msgqueue;
|
||||
/* 0x30 */ OSMesgQueue msgQueue;
|
||||
/* 0x48 */ OSMesg msg;
|
||||
/* 0x4C */ OSIoMesg ioMesg;
|
||||
} AudioSlowLoad; // size = 0x64
|
||||
|
@ -741,7 +741,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
/* 0x00 */ OSTask task;
|
||||
/* 0x40 */ OSMesgQueue* taskQueue;
|
||||
/* 0x40 */ OSMesgQueue* msgQueue;
|
||||
/* 0x44 */ void* unk_44; // probably a message that gets unused.
|
||||
/* 0x48 */ char unk_48[0x8];
|
||||
} AudioTask; // size = 0x50
|
||||
|
@ -779,12 +779,12 @@ typedef struct {
|
|||
/* 0x1E18 */ OSPiHandle* cartHandle;
|
||||
/* 0x1E1C */ OSPiHandle* driveHandle;
|
||||
/* 0x1E20 */ OSMesgQueue externalLoadQueue;
|
||||
/* 0x1E38 */ OSMesg externalLoadMesgBuf[0x10];
|
||||
/* 0x1E38 */ OSMesg externalLoadMsgBuf[16];
|
||||
/* 0x1E78 */ OSMesgQueue preloadSampleQueue;
|
||||
/* 0x1E90 */ OSMesg preloadSampleMesgBuf[0x10];
|
||||
/* 0x1E90 */ OSMesg preloadSampleMsgBuf[16];
|
||||
/* 0x1ED0 */ OSMesgQueue currAudioFrameDmaQueue;
|
||||
/* 0x1EE8 */ OSMesg currAudioFrameDmaMesgBuf[0x40];
|
||||
/* 0x1FE8 */ OSIoMesg currAudioFrameDmaIoMesgBuf[0x40];
|
||||
/* 0x1EE8 */ OSMesg currAudioFrameDmaMsgBuf[64];
|
||||
/* 0x1FE8 */ OSIoMesg currAudioFrameDmaIoMsgBuf[64];
|
||||
/* 0x25E8 */ OSMesgQueue syncDmaQueue;
|
||||
/* 0x2600 */ OSMesg syncDmaMesg;
|
||||
/* 0x2604 */ OSIoMesg syncDmaIoMesg;
|
||||
|
@ -876,9 +876,9 @@ typedef struct {
|
|||
/* 0x5BF0 */ OSMesgQueue taskStartQueue;
|
||||
/* 0x5C08 */ OSMesgQueue cmdProcQueue;
|
||||
/* 0x5C20 */ OSMesgQueue audioResetQueue;
|
||||
/* 0x5C38 */ OSMesg taskStartMsgs[1];
|
||||
/* 0x5C3C */ OSMesg audioResetMesgs[1];
|
||||
/* 0x5C40 */ OSMesg cmdProcMsgs[4];
|
||||
/* 0x5C38 */ OSMesg taskStartMsgBuf[1];
|
||||
/* 0x5C3C */ OSMesg audioResetMsgBuf[1];
|
||||
/* 0x5C40 */ OSMesg cmdProcMsgBuf[4];
|
||||
/* 0x5C50 */ AudioCmd cmdBuf[0x100];
|
||||
} AudioContext; // size = 0x6450
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue