sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

os_thread.h (1943B)


      1 #ifndef _ULTRA64_THREAD_H_
      2 #define _ULTRA64_THREAD_H_
      3 #include "ultratypes.h"
      4 /* Recommended priorities for system threads */
      5 #define OS_PRIORITY_MAX      255
      6 #define OS_PRIORITY_VIMGR    254
      7 #define OS_PRIORITY_RMON     250
      8 #define OS_PRIORITY_RMONSPIN 200
      9 #define OS_PRIORITY_PIMGR    150
     10 #define OS_PRIORITY_SIMGR    140
     11 #define OS_PRIORITY_APPMAX   127
     12 #define OS_PRIORITY_IDLE       0
     13 
     14 #define OS_STATE_STOPPED    1
     15 #define OS_STATE_RUNNABLE    2
     16 #define OS_STATE_RUNNING    4
     17 #define OS_STATE_WAITING    8
     18 
     19 #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
     20 
     21 /* Types */
     22 
     23 typedef s32 OSPri;
     24 typedef s32 OSId;
     25 
     26 typedef union
     27 {
     28     struct {f32 f_odd; f32 f_even;} f;
     29 } __OSfp;
     30 
     31 typedef struct
     32 {
     33     /* registers */
     34     /*0x20*/  u64 at, v0, v1, a0, a1, a2, a3;
     35     /*0x58*/  u64 t0, t1, t2, t3, t4, t5, t6, t7;
     36     /*0x98*/  u64 s0, s1, s2, s3, s4, s5, s6, s7;
     37     /*0xD8*/  u64 t8, t9, gp, sp, s8, ra;
     38     /*0x108*/ u64 lo, hi;
     39     /*0x118*/ u32 sr, pc, cause, badvaddr, rcp;
     40     /*0x12C*/ u32 fpcsr;
     41     __OSfp  fp0,  fp2,  fp4,  fp6,  fp8, fp10, fp12, fp14;
     42     __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30;
     43 } __OSThreadContext;
     44 
     45 typedef struct
     46 {
     47     u32 flag;
     48     u32 count;
     49     u64 time;
     50 } __OSThreadprofile_s;
     51 
     52 typedef struct OSThread_s
     53 {
     54     /*0x00*/ struct OSThread_s *next;
     55     /*0x04*/ OSPri priority;
     56     /*0x08*/ struct OSThread_s **queue;
     57     /*0x0C*/ struct OSThread_s *tlnext;
     58     /*0x10*/ u16 state;
     59     /*0x12*/ u16 flags;
     60     /*0x14*/ OSId id;
     61     /*0x18*/ int fp;
     62     /*0x1C*/ __OSThreadprofile_s *thprof;
     63     /*0x20*/ __OSThreadContext context;
     64 } OSThread;
     65 
     66 
     67 /* Functions */
     68 
     69 void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *),
     70     void *arg, void *sp, OSPri pri);
     71 OSId osGetThreadId(OSThread *thread);
     72 OSPri osGetThreadPri(OSThread *thread);
     73 void osSetThreadPri(OSThread *thread, OSPri pri);
     74 void osStartThread(OSThread *thread);
     75 void osStopThread(OSThread *thread);
     76 
     77 #endif
     78 
     79 #endif