diff options
| author | Faris Awan <58312479+farisawan-2000@users.noreply.github.com> | 2021-04-28 00:35:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-27 22:35:30 -0600 |
| commit | 5c231135925adaf51e9ba366b95d4c5574c74ac8 (patch) | |
| tree | 81ba79e16a091332073a13b2de3dfaf6a44ad1ac /src/os/osCreateThread.c | |
| parent | f4532f26bb7c127f20d43983964236c891f3f419 (diff) | |
Match/split all of libultra (#23)
* libultra from sm64 integrated; 3 libultra functions matched
* All of libultra done!
authored-by: farisawan-2000 <farisawan.2000@gmail.com>
Diffstat (limited to 'src/os/osCreateThread.c')
| -rw-r--r-- | src/os/osCreateThread.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/os/osCreateThread.c b/src/os/osCreateThread.c new file mode 100644 index 000000000..d714a8eba --- /dev/null +++ b/src/os/osCreateThread.c @@ -0,0 +1,36 @@ +#include "libultra_internal.h" + +void __osCleanupThread(void); +extern OSThread *__osActiveQueue; + + +// 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 |
