12#define DEBUG_FLAGS (8)
14#define TAG_THREAD 0x7f01
15#define TAG_SEMA 0x7f02
21#define MAKE_HANDLE(ptr) (((u32)(ptr) << 5) | ((((struct heaptag *)(ptr))->id & 0x3f) << 1) | 1)
22#define HANDLE_PTR(handle) ((void *)((((u32)handle) >> 7) << 2))
23#define HANDLE_ID(handle) (((handle) >> 1) & 0x3f)
24#define HANDLE_VERIFY(handle, t) (((struct heaptag *)(HANDLE_PTR(handle)))->tag == (t) && \
25 HANDLE_ID(handle) == ((struct heaptag *)(HANDLE_PTR(handle)))->id)
27#define ALIGN(i) (((i) + 3) & (~3))
28#define ALIGN_256(i) (((i) + 0xff) & (~0xff))
30#define UNIMPLEMENTED() \
32 Kprintf("UNIMPLEMENTED FUNCTION %s\n", __PRETTY_FUNCTION__); \
39 Kprintf("TRACE %s\n", __PRETTY_FUNCTION__); \
42#define TRACE_ERROR() \
44 Kprintf("TRACE %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \
47#define RESERVED_REGCTX_SIZE 0xb8
52 u32 unk, at, v0, v1, a0,
58 sp, fp, ra, hi, lo, sr,
136 unsigned int (*cb)(
void *);
146 struct regctx *saved_regs;
153 struct event *wait_event;
175 u32 irq_preemption_count;
176 u32 thread_preemption_count;
182 struct thread *current_thread;
195 struct thread *idle_thread;
207 u32 unused_or_padding;
217 s32 sytem_status_flag;
218 u32 thread_switch_count;
219 u32 thread_resume_count;
228static inline u64 add64(u32 hi1, u32 lo1, u32 hi2, u32 lo2)
232 u32 hi = hi1 + hi2 + (lo1 > (lo1 + lo2));
233 return lo | ((u64)hi << 32);
236static inline u64 as_u64(u32 a1, u32 a2)
238 return (u64)a1 << 32 | a2;
246static inline void readyq_insert_back(
struct thread *
thread)
248 u32 prio =
thread->priority;
249 thctx.queue_map[prio >> 5] |= 1 << (prio & 0x1f);
250 list_insert(&thctx.ready_queue[prio], &
thread->queue);
256static inline void readyq_insert_front(
struct thread *
thread)
258 u32 prio =
thread->priority;
259 thctx.queue_map[prio >> 5] |= 1 << (prio & 0x1f);
260 list_insert(thctx.ready_queue[prio].next, &
thread->queue);
266static inline void readyq_remove(
struct thread *
thread, u32 prio)
268 if (list_node_is_last(&
thread->queue)) {
269 thctx.queue_map[prio >> 5] &= ~(1 << (prio & 0x1f));
272 list_remove(&
thread->queue);
277struct alarm *alarm_alloc();
281void update_timer_compare(
int timid, u64 time,
struct list_head *alarm_list);
283void *heap_alloc(u16 tag, u32 bytes);
284int heap_free(
struct heaptag *tag);
287int thread_init_and_start(
struct thread *
thread,
int intr_state);
288int thread_leave(
int unk,
int unk2,
int intr_state,
int release);
290unsigned int thread_delay_cb(
void *user);
296int check_thread_stack();
u32 count
start sector of fragmented bd/file