blob: eaddc088407154da1a2e70e6426717f9f355f29a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include "ultra64.h"
void osCreateThread(OSThread* thread, OSId id, void* entry, void* arg, void* sp, OSPri p) {
register u32 saveMask;
OSIntMask mask;
thread->id = id;
thread->priority = p;
thread->next = NULL;
thread->queue = NULL;
thread->context.pc = (u32)entry;
thread->context.a0 = (intptr_t)arg;
thread->context.sp = (u64)(s32)sp - 16;
thread->context.ra = (intptr_t)__osCleanupThread;
mask = OS_IM_ALL;
thread->context.sr = (mask & (SR_IMASK | SR_IE)) | SR_EXL;
thread->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT;
thread->context.fpcsr = (u32)(FPCSR_FS | FPCSR_EV);
thread->fp = 0;
thread->state = OS_STATE_STOPPED;
thread->flags = 0;
saveMask = __osDisableInt();
thread->tlnext = __osActiveQueue;
__osActiveQueue = thread;
__osRestoreInt(saveMask);
}
|