sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
timer_alarm.c File Reference
#include <kernel.h>
#include <timer.h>
#include <timer_alarm.h>

Go to the source code of this file.

Classes

struct  alarm_struct_

Macros

#define PTR_TO_ALARM_ID(ptr_, cid_)
#define ALARM_ID_TO_PTR(id_)
#define ALARM_ID_IS_VALID(id_)
#define ALARM_COUNT   64

Functions

struct alarm_struct_ __attribute__ ((aligned(16)))
 __attribute__ ((weak))
u64 AlarmHandler (s32 alarm_id, u64 scheduled_time, u64 actual_time, void *arg, void *last_pc)
s32 iSetTimerAlarm (u64 clock_cycles, timer_alarm_handler_t callback_handler, void *arg)
s32 SetTimerAlarm (u64 clock_cycles, timer_alarm_handler_t callback_handler, void *arg)
s32 iReleaseTimerAlarm (s32 id)
s32 ReleaseTimerAlarm (s32 id)

Variables

struct alarm_struct_ * alarm_next
vs32 timer_counter_id
timer_alarm_handler_t callback_handler
void * callback_handler_arg
alarm_struct_t * g_pFreeAlarm = NULL

Detailed Description

Some routines to do some timer alarm work

Definition in file timer_alarm.c.

Macro Definition Documentation

◆ ALARM_COUNT

#define ALARM_COUNT   64

Definition at line 32 of file timer_alarm.c.

◆ ALARM_ID_IS_VALID

#define ALARM_ID_IS_VALID ( id_)
Value:
((ALARM_ID_TO_PTR(id_) != NULL) && ((siptr)(id_) >= 0) && ((((((uiptr)id_) & 0xFF) == (((ALARM_ID_TO_PTR(id_))->timer_counter_id) & 0xFF)))))

Definition at line 30 of file timer_alarm.c.

◆ ALARM_ID_TO_PTR

#define ALARM_ID_TO_PTR ( id_)
Value:
((alarm_struct_t *)((((uiptr)(id_)) >> 8) << 4))

Definition at line 29 of file timer_alarm.c.

◆ PTR_TO_ALARM_ID

#define PTR_TO_ALARM_ID ( ptr_,
cid_ )
Value:
((s32)((((uiptr)(ptr_)) << 4) | ((cid_) & 0xFE) | 1))

Definition at line 28 of file timer_alarm.c.

Function Documentation

◆ __attribute__() [1/2]

struct alarm_struct_ __attribute__ ( (aligned(16)) )

Definition at line 14 of file sifcmd.c.

◆ __attribute__() [2/2]

__attribute__ ( (weak) )

Definition at line 37 of file timer_alarm.c.

◆ AlarmHandler()

u64 AlarmHandler ( s32 alarm_id,
u64 scheduled_time,
u64 actual_time,
void * arg,
void * last_pc )

Definition at line 65 of file timer_alarm.c.

◆ iReleaseTimerAlarm()

s32 iReleaseTimerAlarm ( s32 id)

Definition at line 134 of file timer_alarm.c.

◆ iSetTimerAlarm()

s32 iSetTimerAlarm ( u64 clock_cycles,
timer_alarm_handler_t callback_handler,
void * arg )

Definition at line 84 of file timer_alarm.c.

◆ ReleaseTimerAlarm()

s32 ReleaseTimerAlarm ( s32 id)

Definition at line 152 of file timer_alarm.c.

◆ SetTimerAlarm()

s32 SetTimerAlarm ( u64 clock_cycles,
timer_alarm_handler_t callback_handler,
void * arg )

Sets up alarm paramenters.

Parameters
clock_cyclesNumber of bus cycles when the alarm will trigger
callback_handlerFunction pointer to call when the alarm triggers (in IRQ)
argArgument to pass to callback_handler

Starts the alarm. If the alarm was already started, it does nothing.

Definition at line 120 of file timer_alarm.c.

Variable Documentation

◆ alarm_next

struct alarm_struct_* alarm_next

Definition at line 0 of file timer_alarm.c.

◆ callback_handler

timer_alarm_handler_t callback_handler

Definition at line 2 of file timer_alarm.c.

◆ callback_handler_arg

void* callback_handler_arg

Definition at line 3 of file timer_alarm.c.

◆ g_pFreeAlarm

alarm_struct_t* g_pFreeAlarm = NULL

Definition at line 35 of file timer_alarm.c.

◆ timer_counter_id

vs32 timer_counter_id

Definition at line 1 of file timer_alarm.c.