sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
thsemap.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16
17/*
18 * This file is based off of the work [RO]man, Herben, and any others involved
19 * in the "modules" project at http://ps2dev.pgamers.com/. It is also based
20 * off of the work of the many contributors to the ps2lib project at
21 * http://ps2dev.livemedia.com.au/.
22 */
23
24#ifndef __THSEMAP_H__
25#define __THSEMAP_H__
26
27#include <types.h>
28#include <irx.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34// Semaphore attributes
35#define SA_THFIFO 0x000
36#define SA_THPRI 0x001
37#define SA_IHTHPRI 0x100
38
39typedef struct
40{
41 u32 attr;
42 u32 option;
43 int initial;
44 int max;
46
47typedef struct
48{
49 u32 attr;
50 u32 option;
51 int initial;
52 int max;
53 int current;
54 int numWaitThreads;
55 int reserved[2];
57
58extern int CreateSema(iop_sema_t *sema);
59extern int DeleteSema(int semid);
60
61extern int SignalSema(int semid);
62extern int iSignalSema(int semid);
63extern int WaitSema(int semid);
64extern int PollSema(int semid);
65
66extern int ReferSemaStatus(int semid, iop_sema_info_t *info);
67extern int iReferSemaStatus(int semid, iop_sema_info_t *info);
68
69#define IOP_MUTEX_LOCKED 0
70#define IOP_MUTEX_UNLOCKED 1
71
72static inline int CreateMutex(int state)
73{
74 iop_sema_t sema;
75 sema.attr = 0;
76 sema.option = 0;
77 sema.initial = state;
78 sema.max = 1;
79 return CreateSema(&sema);
80}
81
82#define thsemap_IMPORTS_start DECLARE_IMPORT_TABLE(thsemap, 1, 2)
83#define thsemap_IMPORTS_end END_IMPORT_TABLE
84
85#define I_CreateSema DECLARE_IMPORT(4, CreateSema)
86#define I_DeleteSema DECLARE_IMPORT(5, DeleteSema)
87#define I_SignalSema DECLARE_IMPORT(6, SignalSema)
88#define I_iSignalSema DECLARE_IMPORT(7, iSignalSema)
89#define I_WaitSema DECLARE_IMPORT(8, WaitSema);
90#define I_PollSema DECLARE_IMPORT(9, PollSema);
91#define I_ReferSemaStatus DECLARE_IMPORT(11, ReferSemaStatus)
92#define I_iReferSemaStatus DECLARE_IMPORT(12, iReferSemaStatus)
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif /* __THSEMAP_H__ */