mirror of
https://github.com/zeldaret/oot
synced 2026-06-22 17:02:58 -04:00
7334ffa373
* Format all handwritten asm and document some * Use c preprocessor for constants * Fix * Fix PI_STATUS_ERROR, some label improvements * Avoid hi/lo for constants * Some more comments * Properly mark functions as functions and their sizes * Fix merge * Improvements * Review suggestions, rework procedure start/end macros to be more like libreultra * Move IPL3 symbol definitions into ipl3.s * Fix undefined_syms, add include and language guards to asm.h and fix the comment in gbi.h * Consistent hex capitalization, add some MIPS builtin defines to CC_CHECK to behave properly * Add -no-pad-sections assembler option and clean up alignment in gu files and bzero * Further suggestions and improvements * Matrix conversion function clarifications * Fix passing AVOID_UB to gcc * Suggestions * Suggestions, global interrupt mask improvements * Further suggestions, interrupt mask comments * Comments fixes, rdb.h * Switch from # comments to // comments, remove unnecesary .set gp=64 directives * Further review suggestions * Missed one
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
#include "global.h"
|
|
#include "ultra64/asm.h"
|
|
|
|
__OSThreadTail __osThreadTail = { NULL, OS_PRIORITY_THREADTAIL };
|
|
OSThread* __osRunQueue = (OSThread*)&__osThreadTail;
|
|
OSThread* __osActiveQueue = (OSThread*)&__osThreadTail;
|
|
OSThread* __osRunningThread = NULL;
|
|
OSThread* __osFaultedThread = NULL;
|
|
|
|
void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri pri) {
|
|
register u32 prevInt;
|
|
OSIntMask mask;
|
|
|
|
thread->id = id;
|
|
thread->priority = pri;
|
|
thread->next = NULL;
|
|
thread->queue = NULL;
|
|
thread->context.pc = (u32)entry;
|
|
thread->context.a0 = arg;
|
|
thread->context.sp = (u64)(s32)sp - FRAMESZ(SZREG * NARGSAVE);
|
|
thread->context.ra = __osCleanupThread;
|
|
|
|
mask = OS_IM_ALL;
|
|
thread->context.sr = (mask & OS_IM_CPU) | SR_EXL;
|
|
thread->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT;
|
|
thread->context.fpcsr = FPCSR_FS | FPCSR_EV;
|
|
thread->fp = 0;
|
|
thread->state = OS_STATE_STOPPED;
|
|
thread->flags = 0;
|
|
|
|
prevInt = __osDisableInt();
|
|
thread->tlnext = __osActiveQueue;
|
|
__osActiveQueue = thread;
|
|
__osRestoreInt(prevInt);
|
|
}
|