blob: 966386e4eaf6cda6d1ff69295b5b2cd8eee0c535 (
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
29
30
31
32
33
34
|
#include "libultra_internal.h"
void __osCleanupThread(void);
// Don't warn about pointer->u64 cast
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri pri) {
register u32 int_disabled;
u32 tmp;
thread->id = id;
thread->priority = pri;
thread->next = NULL;
thread->queue = NULL;
thread->context.pc = (u32) entry;
thread->context.a0 = (u64) arg;
thread->context.sp = (u64) sp - 16;
thread->context.ra = (u64) __osCleanupThread;
tmp = OS_IM_ALL;
thread->context.sr = 65283;
thread->context.rcp = (tmp & 0x3f0000) >> 16;
thread->context.fpcsr = (u32) 0x01000800;
thread->fp = 0;
thread->state = OS_STATE_STOPPED;
thread->flags = 0;
int_disabled = __osDisableInt();
thread->tlnext = __osActiveQueue;
__osActiveQueue = thread;
__osRestoreInt(int_disabled);
}
#pragma GCC diagnostic pop
|