sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
thcommon.h File Reference
#include "thbase.h"
#include "list.h"
#include "sysmem.h"
#include "thmsgbx.h"
#include <tamtypes.h>

Go to the source code of this file.

Classes

struct  regctx
struct  heaptag
struct  event
struct  event_flag
struct  semaphore
struct  mbox
struct  fpl_block
struct  fpool
struct  vpool
struct  alarm
struct  thread
struct  thread_context

Macros

#define DEBUG_FLAGS   (8)
#define TAG_THREAD   0x7f01
#define TAG_SEMA   0x7f02
#define TAG_EVF   0x7f03
#define TAG_MBX   0x7f04
#define TAG_VPL   0x7f05
#define TAG_FPL   0x7f06
#define MAKE_HANDLE(ptr)
#define HANDLE_PTR(handle)
#define HANDLE_ID(handle)
#define HANDLE_VERIFY(handle, t)
#define ALIGN(i)
#define ALIGN_256(i)
#define UNIMPLEMENTED()
#define TRACE()
#define TRACE_ERROR()
#define RESERVED_REGCTX_SIZE   0xb8

Functions

u32 readyq_highest ()
struct alarm * alarm_alloc ()
void alarm_free (struct alarm *alarm)
void alarm_insert (struct list_head *list, struct alarm *alarm)
void update_timer_compare (int timid, u64 time, struct list_head *alarm_list)
void * heap_alloc (u16 tag, u32 bytes)
int heap_free (struct heaptag *tag)
int thread_start (struct thread *thread, int intr_state)
int thread_init_and_start (struct thread *thread, int intr_state)
int thread_leave (int unk, int unk2, int intr_state, int release)
unsigned int thread_delay_cb (void *user)
int read_sys_time (iop_sys_clock_t *clock)
void waitlist_insert (struct thread *thread, struct event *event, s32 priority)
int check_thread_stack ()

Variables

struct thread_context thctx

Macro Definition Documentation

◆ ALIGN

#define ALIGN ( i)
Value:
(((i) + 3) & (~3))

Definition at line 34 of file thcommon.h.

◆ ALIGN_256

#define ALIGN_256 ( i)
Value:
(((i) + 0xff) & (~0xff))

Definition at line 35 of file thcommon.h.

◆ DEBUG_FLAGS

#define DEBUG_FLAGS   (8)

Definition at line 16 of file thcommon.h.

◆ HANDLE_ID

#define HANDLE_ID ( handle)
Value:
(((handle) >> 1) & 0x3f)

Definition at line 27 of file thcommon.h.

◆ HANDLE_PTR

#define HANDLE_PTR ( handle)
Value:
((void *)((((u32)handle) >> 7) << 2))

Definition at line 26 of file thcommon.h.

◆ HANDLE_VERIFY

#define HANDLE_VERIFY ( handle,
t )
Value:
(((struct heaptag *)(HANDLE_PTR(handle)))->tag == (t) && \
HANDLE_ID(handle) == ((struct heaptag *)(HANDLE_PTR(handle)))->id)

Definition at line 28 of file thcommon.h.

◆ MAKE_HANDLE

#define MAKE_HANDLE ( ptr)
Value:
(((u32)(ptr) << 5) | ((((struct heaptag *)(ptr))->id & 0x3f) << 1) | 1)

Definition at line 25 of file thcommon.h.

◆ RESERVED_REGCTX_SIZE

#define RESERVED_REGCTX_SIZE   0xb8

Definition at line 54 of file thcommon.h.

◆ TAG_EVF

#define TAG_EVF   0x7f03

Definition at line 20 of file thcommon.h.

◆ TAG_FPL

#define TAG_FPL   0x7f06

Definition at line 23 of file thcommon.h.

◆ TAG_MBX

#define TAG_MBX   0x7f04

Definition at line 21 of file thcommon.h.

◆ TAG_SEMA

#define TAG_SEMA   0x7f02

Definition at line 19 of file thcommon.h.

◆ TAG_THREAD

#define TAG_THREAD   0x7f01

Definition at line 18 of file thcommon.h.

◆ TAG_VPL

#define TAG_VPL   0x7f05

Definition at line 22 of file thcommon.h.

◆ TRACE

#define TRACE ( )
Value:
do { \
Kprintf("TRACE %s\n", __PRETTY_FUNCTION__); \
} while (0)

Definition at line 44 of file thcommon.h.

◆ TRACE_ERROR

#define TRACE_ERROR ( )
Value:
do { \
Kprintf("TRACE %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \
} while (0)

Definition at line 49 of file thcommon.h.

◆ UNIMPLEMENTED

#define UNIMPLEMENTED ( )
Value:
do { \
Kprintf("UNIMPLEMENTED FUNCTION %s\n", __PRETTY_FUNCTION__); \
while (1) \
; \
} while (0)

Definition at line 37 of file thcommon.h.

Function Documentation

◆ alarm_alloc()

struct alarm * alarm_alloc ( )
extern

Definition at line 26 of file thcommon.c.

◆ alarm_free()

void alarm_free ( struct alarm * alarm)
extern

Definition at line 41 of file thcommon.c.

◆ alarm_insert()

void alarm_insert ( struct list_head * list,
struct alarm * alarm )
extern

Definition at line 50 of file thcommon.c.

◆ check_thread_stack()

int check_thread_stack ( )
extern

Definition at line 119 of file thcommon.c.

◆ heap_alloc()

void * heap_alloc ( u16 tag,
u32 bytes )
extern

Definition at line 133 of file thcommon.c.

◆ heap_free()

int heap_free ( struct heaptag * tag)
extern

Definition at line 144 of file thcommon.c.

◆ read_sys_time()

int read_sys_time ( iop_sys_clock_t * clock)
extern

Definition at line 240 of file thcommon.c.

◆ readyq_highest()

u32 readyq_highest ( )
extern

Definition at line 287 of file thcommon.c.

◆ thread_delay_cb()

unsigned int thread_delay_cb ( void * user)
extern

Definition at line 107 of file thcommon.c.

◆ thread_init_and_start()

int thread_init_and_start ( struct thread * thread,
int intr_state )
extern

Definition at line 199 of file thcommon.c.

◆ thread_leave()

int thread_leave ( int ret1,
int ret2,
int intr_state,
int release )
extern

Exit the current thread, intrman will call us back to get a new context to switch to. The first two arguments will get saved into v0 and v1 in the stored context.

The current CpuDisableIntr state is passed so that it can be restored when resuming the next user thread.

Release indicates if it was a voluntary wait or not.

Definition at line 159 of file thcommon.c.

◆ thread_start()

int thread_start ( struct thread * thread,
int intr_state )
extern

Definition at line 181 of file thcommon.c.

◆ update_timer_compare()

void update_timer_compare ( int timid,
u64 time,
struct list_head * alarm_list )
extern

Definition at line 79 of file thcommon.c.

◆ waitlist_insert()

void waitlist_insert ( struct thread * thread,
struct event * event,
s32 priority )
extern

Definition at line 63 of file thcommon.c.

Variable Documentation

◆ thctx

struct thread_context thctx
extern

Definition at line 24 of file thcommon.c.