Match and link OSThread.c

Former-commit-id: 1ccd29a1cd
This commit is contained in:
2022-11-05 03:21:17 -07:00
parent 6f932a5d48
commit c20c3e399c
8 changed files with 946 additions and 66 deletions

View File

@@ -67,10 +67,10 @@ OSTime OSGetTime();
OSTick OSGetTick();
typedef struct OSCalendarTime {
int sec; // seconds after the minute [0, 61]
int min; // minutes after the hour [0, 59]
int hour; // hours since midnight [0, 23]
int mday; // day of the month [1, 31]
int sec; // seconds after the minute [0, 61]
int min; // minutes after the hour [0, 59]
int hour; // hours since midnight [0, 23]
int mday; // day of the month [1, 31]
int mon; // month since January [0, 11]
int year; // years in AD [1, ...]
int wday; // days since Sunday [0, 6]
@@ -80,9 +80,8 @@ typedef struct OSCalendarTime {
int usec; // microseconds after the millisecond [0,999]
} OSCalendarTime;
OSTime OSCalendarTimeToTicks( OSCalendarTime* td );
void OSTicksToCalendarTime( OSTime ticks, OSCalendarTime* td );
OSTime OSCalendarTimeToTicks(OSCalendarTime* td);
void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* td);
#define OS_CONSOLE_MASK 0xf0000000
#define OS_CONSOLE_RETAIL 0x00000000
@@ -157,6 +156,7 @@ void OSFatal(GXColor fg, GXColor bg, const char* msg);
#include <dolphin/os/OSException.h>
#include <dolphin/os/OSFont.h>
#include <dolphin/os/OSInterrupt.h>
#include <dolphin/os/OSMutex.h>
#include <dolphin/os/OSReset.h>
#include <dolphin/os/OSSerial.h>
#include <dolphin/os/OSThread.h>

View File

@@ -80,7 +80,7 @@ extern "C" {
#define OS_CONTEXT_FPR30 384
#define OS_CONTEXT_FPR31 392
#define OS_CONTEXT_FPSCR 400
#define OS_CONTEXT_FPSCR 400
#define OS_CONTEXT_SRR0 408
#define OS_CONTEXT_SRR1 412
@@ -130,6 +130,7 @@ extern "C" {
#define OS_CONTEXT_PSF29 688
#define OS_CONTEXT_PSF30 696
#define OS_CONTEXT_PSF31 704
#define OS_CONTEXT_STATE_EXC 0x02u
typedef struct OSContext {
u32 gpr[32];
@@ -155,7 +156,7 @@ typedef struct OSContext {
} OSContext;
void OSSaveContext(OSContext* context);
u32 OSSaveContext(OSContext* context);
void OSClearContext(OSContext* context);
OSContext* OSGetCurrentContext();
void OSSetCurrentContext(OSContext* context);

View File

@@ -62,7 +62,49 @@ struct OSThread {
void* specific[OS_THREAD_SPECIFIC_MAX];
};
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_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
void OSInitThreadQueue(OSThreadQueue* queue);
OSThread* OSGetCurrentThread(void);
BOOL OSIsThreadSuspended(OSThread* thread);
BOOL OSIsThreadTerminated(OSThread* thread);
s32 OSDisableScheduler(void);
s32 OSEnableScheduler(void);
void OSYieldThread(void);
BOOL OSCreateThread(OSThread* thread, void* (*func)(void*), void* param, void* stack, u32 stackSize,
OSPriority priority, u16 attr);
void OSExitThread(void* val);
void OSCancelThread(OSThread* thread);
BOOL OSJoinThread(OSThread* thread, void** val);
void OSDetachThread(OSThread* thread);
s32 OSResumeThread(OSThread* thread);
s32 OSSuspendThread(OSThread* thread);
BOOL OSSetThreadPriority(OSThread* thread, OSPriority priority);
OSPriority OSGetThreadPriority(OSThread* thread);
void OSSleepThread(OSThreadQueue* queue);
void OSWakeupThread(OSThreadQueue* queue);
void* OSGetThreadSpecific(s32 index);
void OSSetThreadSpecific(s32 index, void* ptr);
OSThread* OSSetIdleFunction(OSIdleFunction idleFunction, void* param, void* stack, u32 stackSize);
OSThread* OSGetIdleFunction(void);
void OSClearStack(u8 val);
long OSCheckActiveThreads(void);
#ifdef __cplusplus
}