mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-07 10:11:43 -04:00
copy dolsdk2004 to tp / b_bh + e_mb done (#2299)
* move dolsdk2004 over * cleanup some temp work * finish and cleanup gf * b_bh done * d_a_e_mb done
This commit is contained in:
@@ -1,115 +1,112 @@
|
||||
#ifndef OSTHREAD_H
|
||||
#define OSTHREAD_H
|
||||
#ifndef _DOLPHIN_OSTHREAD_H_
|
||||
#define _DOLPHIN_OSTHREAD_H_
|
||||
|
||||
#include "dolphin/os/OSContext.h"
|
||||
#include <dolphin/os/OSContext.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef u16 OSThreadState;
|
||||
typedef s32 OSPriority; // 0 highest, 31 lowest
|
||||
|
||||
#define OS_THREAD_STATE_UNINITIALIZED 0
|
||||
#define OS_THREAD_STATE_READY 1
|
||||
#define OS_THREAD_STATE_RUNNING 2
|
||||
#define OS_THREAD_STATE_WAITING 4
|
||||
#define OS_THREAD_STATE_DEAD 8
|
||||
|
||||
#define OS_THREAD_ATTR_DETACH 0x0001u
|
||||
|
||||
#define OS_THREAD_STACK_MAGIC 0xDEADBABE
|
||||
|
||||
#define OS_PRIORITY_MIN 0 // highest
|
||||
#define OS_PRIORITY_MAX 31 // lowest
|
||||
#define OS_PRIORITY_IDLE OS_PRIORITY_MAX
|
||||
typedef s32 OSPriority;
|
||||
|
||||
typedef struct OSThread OSThread;
|
||||
typedef struct OSThreadQueue OSThreadQueue;
|
||||
typedef struct OSThreadLink OSThreadLink;
|
||||
|
||||
typedef struct OSMutex OSMutex;
|
||||
typedef struct OSThreadQueue OSThreadQueue;
|
||||
typedef struct OSMutexQueue OSMutexQueue;
|
||||
typedef struct OSThreadLink OSThreadLink;
|
||||
typedef struct OSMutexLink OSMutexLink;
|
||||
typedef struct OSCond OSCond;
|
||||
|
||||
struct OSThreadQueue {
|
||||
OSThread* head;
|
||||
OSThread* tail;
|
||||
};
|
||||
|
||||
struct OSThreadLink {
|
||||
OSThread* next;
|
||||
OSThread* prev;
|
||||
};
|
||||
|
||||
struct OSThreadQueue {
|
||||
/* 0x0 */ OSThread* head;
|
||||
/* 0x4 */ OSThread* tail;
|
||||
};
|
||||
|
||||
struct OSMutexLink {
|
||||
OSMutex* next;
|
||||
OSMutex* prev;
|
||||
};
|
||||
|
||||
struct OSMutexQueue {
|
||||
OSMutex* head;
|
||||
OSMutex* tail;
|
||||
};
|
||||
|
||||
struct OSThread {
|
||||
OSContext context;
|
||||
OSThreadState state;
|
||||
u16 attributes;
|
||||
s32 suspend_count;
|
||||
s32 effective_priority;
|
||||
u32 base_priority;
|
||||
void* exit_value;
|
||||
OSThreadQueue* queue;
|
||||
OSThreadLink link;
|
||||
OSThreadQueue join_queue;
|
||||
OSMutex* mutex;
|
||||
OSMutexQueue owned_mutexes;
|
||||
OSThreadLink active_threads_link;
|
||||
u8* stack_base;
|
||||
u32* stack_end;
|
||||
u8* error_code;
|
||||
void* data[2];
|
||||
struct OSMutexLink {
|
||||
OSMutex* next;
|
||||
OSMutex* prev;
|
||||
};
|
||||
|
||||
typedef void (*OSSwitchThreadCallback)(OSThread* from, OSThread* to);
|
||||
struct OSThread {
|
||||
/* 0x000 */ OSContext context;
|
||||
/* 0x2C8 */ u16 state;
|
||||
/* 0x2CA */ u16 attr;
|
||||
/* 0x2CC */ s32 suspend;
|
||||
/* 0x2D0 */ OSPriority priority;
|
||||
/* 0x2D4 */ OSPriority base;
|
||||
/* 0x2D8 */ void* val;
|
||||
/* 0x2DC */ OSThreadQueue* queue;
|
||||
/* 0x2E0 */ OSThreadLink link;
|
||||
/* 0x2E8 */ OSThreadQueue queueJoin;
|
||||
/* 0x2F0 */ OSMutex* mutex;
|
||||
/* 0x2F4 */ OSMutexQueue queueMutex;
|
||||
/* 0x2FC */ OSThreadLink linkActive;
|
||||
/* 0x304 */ u8* stackBase;
|
||||
/* 0x308 */ u32* stackEnd;
|
||||
/* 0x30C */ s32 error;
|
||||
/* 0x310 */ void* specific[2];
|
||||
};
|
||||
|
||||
OSThreadQueue OS_THREAD_QUEUE AT_ADDRESS(0x800000DC);
|
||||
OSThread* OS_CURRENT_THREAD AT_ADDRESS(0x800000E4);
|
||||
enum OS_THREAD_STATE {
|
||||
OS_THREAD_STATE_READY = 1,
|
||||
OS_THREAD_STATE_RUNNING = 2,
|
||||
OS_THREAD_STATE_WAITING = 4,
|
||||
OS_THREAD_STATE_MORIBUND = 8,
|
||||
};
|
||||
|
||||
#define OS_PRIORITY_MIN 0 // highest
|
||||
#define OS_PRIORITY_MAX 31 // lowest
|
||||
#define OS_PRIORITY_IDLE OS_PRIORITY_MAX
|
||||
|
||||
#define OS_THREAD_SPECIFIC_MAX 2
|
||||
|
||||
#define OS_THREAD_ATTR_DETACH 0x0001u
|
||||
|
||||
#define OS_THREAD_STACK_MAGIC 0xDEADBABE
|
||||
|
||||
typedef void (*OSSwitchThreadCallback)(OSThread*, OSThread*);
|
||||
typedef void (*OSIdleFunction)(void*);
|
||||
|
||||
static void DefaultSwitchThreadCallback(OSThread* from, OSThread* to);
|
||||
OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback func);
|
||||
void __OSThreadInit(void);
|
||||
void OSInitThreadQueue(OSThreadQueue* queue);
|
||||
OSThread* OSGetCurrentThread(void);
|
||||
BOOL OSIsThreadTerminated(OSThread* thread);
|
||||
s32 OSDisableScheduler(void);
|
||||
s32 OSEnableScheduler(void);
|
||||
static void UnsetRun(OSThread* thread);
|
||||
s32 __OSGetEffectivePriority(OSThread* thread);
|
||||
static OSThread* SetEffectivePriority(OSThread* thread, s32 priority);
|
||||
void __OSPromoteThread(OSThread* thread, s32 priority);
|
||||
static OSThread* SelectThread(BOOL yield);
|
||||
void __OSReschedule(void);
|
||||
void OSYieldThread(void);
|
||||
BOOL OSCreateThread(OSThread* thread, void* func, void* param, void* stackBase, u32 stackSize,
|
||||
s32 priority, u16 attribute);
|
||||
void OSExitThread(void* exitValue);
|
||||
void OSCancelThread(OSThread* thread);
|
||||
void OSDetachThread(OSThread* thread);
|
||||
s32 OSResumeThread(OSThread* thread);
|
||||
s32 OSSuspendThread(OSThread* thread);
|
||||
void OSSleepThread(OSThreadQueue* queue);
|
||||
void OSWakeupThread(OSThreadQueue* queue);
|
||||
s32 OSSetThreadPriority(OSThread* thread, s32 priority);
|
||||
s32 OSSuspendThread(OSThread* thread);
|
||||
s32 OSResumeThread(OSThread* thread);
|
||||
OSThread* OSGetCurrentThread(void);
|
||||
s32 OSEnableScheduler(void);
|
||||
s32 OSDisableScheduler(void);
|
||||
void OSCancelThread(OSThread* thread);
|
||||
void OSClearStack(u8 val);
|
||||
BOOL OSIsThreadSuspended(OSThread* thread);
|
||||
BOOL OSIsThreadTerminated(OSThread* thread);
|
||||
void OSYieldThread(void);
|
||||
int OSCreateThread(OSThread* thread, void* (*func)(void*), void* param, void* stack, u32 stackSize, OSPriority priority, u16 attr);
|
||||
void OSExitThread(void* val);
|
||||
int OSJoinThread(OSThread* thread, void* val);
|
||||
void OSDetachThread(OSThread* thread);
|
||||
int OSSetThreadPriority(OSThread* thread, OSPriority priority);
|
||||
s32 OSGetThreadPriority(OSThread* thread);
|
||||
static s32 CheckThreadQueue(OSThreadQueue* thread);
|
||||
OSThread* OSSetIdleFunction(OSIdleFunction idleFunction, void* param, void* stack, u32 stackSize);
|
||||
OSThread* OSGetIdleFunction(void);
|
||||
s32 OSCheckActiveThreads(void);
|
||||
static void OSClearStack(u8 value);
|
||||
void OSSetThreadSpecific(s32 index, void* ptr);
|
||||
void* OSGetThreadSpecific(s32 index);
|
||||
|
||||
OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback callback);
|
||||
|
||||
#define IsSuspended(suspend) (suspend > 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OSTHREAD_H */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user