NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
OSThread.h
1#ifndef RVL_SDK_OS_THREAD_H
2#define RVL_SDK_OS_THREAD_H
3#include <revolution/OS/OSContext.h>
4#include <types.h>
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#define OS_PRIORITY_MIN 0
10#define OS_PRIORITY_MAX 31
11
12#define OS_THREAD_STACK_MAGIC 0xDEADBABE
13
14typedef enum {
15 OS_THREAD_STATE_EXITED = 0,
16 OS_THREAD_STATE_READY = 1,
17 OS_THREAD_STATE_RUNNING = 2,
18 OS_THREAD_STATE_SLEEPING = 4,
19 OS_THREAD_STATE_MORIBUND = 8
20} OSThreadState;
21
22typedef enum { OS_THREAD_DETACHED = (1 << 0) } OSThreadFlag;
23
24typedef struct OSThreadQueue {
25 struct OSThread* head; // at 0x0
26 struct OSThread* tail; // at 0x4
28
29typedef struct OSMutexQueue {
30 struct OSMutex* head; // at 0x0
31 struct OSMutex* tail; // at 0x4
33
34typedef struct OSThread {
35 OSContext context;
36 u16 state; // at 0x2C8
37 u16 flags; // at 0x2CA
38 s32 suspend; // at 0x2CC
39 s32 priority; // at 0x2D0
40 s32 base; // at 0x2D4
41 u32 val; // at 0x2D8
42 OSThreadQueue* queue; // at 0x2DC
43 struct OSThread* next; // at 0x2E0
44 struct OSThread* prev; // at 0x2E4
45 OSThreadQueue joinQueue; // at 0x2E8
46 struct OSMutex* mutex; // at 0x2F0
47 OSMutexQueue mutexQueue; // at 0x2F4
48 struct OSThread* nextActive; // at 0x2FC
49 struct OSThread* prevActive; // at 0x300
50 u32* stackBegin; // at 0x304
51 u32* stackEnd; // at 0x308
52 s32 error; // at 0x30C
53 void* specific[2]; // at 0x310
54} OSThread;
55
56typedef void (*OSSwitchThreadCallback)(OSThread* currThread,
57 OSThread* newThread);
58typedef void* (*OSThreadFunc)(void* arg);
59
60OSSwitchThreadCallback
61OSSetSwitchThreadCallback(OSSwitchThreadCallback callback);
62void __OSThreadInit(void);
63void OSSetCurrentThread(OSThread* thread);
64void OSInitMutexQueue(OSMutexQueue* queue);
65void OSInitThreadQueue(OSThreadQueue* queue);
66OSThread* OSGetCurrentThread(void);
67BOOL OSIsThreadTerminated(OSThread* thread);
68s32 OSDisableScheduler(void);
69s32 OSEnableScheduler(void);
70s32 __OSGetEffectivePriority(OSThread* thread);
71void __OSPromoteThread(OSThread* thread, s32 prio);
72void __OSReschedule(void);
73void OSYieldThread(void);
74BOOL OSCreateThread(OSThread* thread, OSThreadFunc func, void* funcArg,
75 void* stackBegin, u32 stackSize, s32 prio, u16 flags);
76void OSExitThread(OSThread* thread);
77void OSCancelThread(OSThread* thread);
78BOOL OSJoinThread(OSThread* thread, void* val);
79void OSDetachThread(OSThread* thread);
80s32 OSResumeThread(OSThread* thread);
81s32 OSSuspendThread(OSThread* thread);
82void OSSleepThread(OSThreadQueue* queue);
83void OSWakeupThread(OSThreadQueue* queue);
84BOOL OSSetThreadPriority(OSThread* thread, s32 prio);
85void OSClearStack(u8 val);
86void OSSleepTicks(s64 ticks);
87
88#ifdef __cplusplus
89}
90#endif
91#endif