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