sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
kernel_util.c
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
11
#include <
kernel.h
>
12
#include <
timer_alarm.h
>
13
#include <
kernel_util.h
>
14
15
static
u64 WaitSemaEx_callback(s32
id
, u64 scheduled_time, u64 actual_time,
void
*arg,
void
*pc_value)
16
{
17
(void)
id
;
18
(void)scheduled_time;
19
(void)actual_time;
20
(void)pc_value;
21
iReleaseWaitThread((s32)arg);
22
return
0;
23
}
24
26
s32
WaitSemaEx
(s32 semaid,
int
signal, u64 *timeout)
27
{
28
int
ret;
29
int
timerid;
30
31
timerid = -1;
32
33
// TODO: other values NYI
34
if
(signal != 1)
35
{
36
return
-100;
37
}
38
39
if
(timeout != NULL && *timeout == 0)
40
{
41
ret = PollSema(semaid);
42
if
(ret < 0)
43
{
44
return
ret;
45
}
46
return
semaid;
47
}
48
49
if
(timeout != NULL)
50
{
51
timerid =
SetTimerAlarm
(USec2TimerBusClock(*timeout), &WaitSemaEx_callback, (
void
*)GetThreadId());
52
}
53
54
ret = WaitSema(semaid);
55
56
if
(timerid >= 0)
57
{
58
ReleaseTimerAlarm(timerid);
59
}
60
61
return
ret;
62
}
kernel.h
kernel_util.h
WaitSemaEx
s32 WaitSemaEx(s32 semaid, int signal, u64 *timeout)
Definition
kernel_util.c:26
timer_alarm.h
SetTimerAlarm
s32 SetTimerAlarm(u64 clock_cycles, timer_alarm_handler_t callback_handler, void *arg)
Definition
timer_alarm.c:120
core
kernel
src
kernel_util.c
Generated by
1.18.0