PS2SDK
PS2 Homebrew Libraries
timrman.h
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright (c) 2005 linuzappz <linuzappz@hotmail.com>
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
16
#ifndef __TIMRMAN_H__
17
#define __TIMRMAN_H__
18
19
#include <types.h>
20
#include <
irx.h
>
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
/* Documentation on the old module's SetTimerCompare() and SetTimerMode() functions is difficult because SCE had replaced them
27
with a single function within later SDK versions: SetupHardTimer().
28
29
source = counter input (see below).
30
size = counter width (either 16 or 32).
31
prescale = counter input scale (e.g. for a prescale of 256 with a SYSCLOCK (36.8MHz) source, 36864000/256=144 ticks per msec)
32
33
Mode bits:
34
Value Bit(s) Description
35
0x0001 1 Enable gate
36
0x0002 2 Gate count mode
37
0x0004 3 Gate count mode
38
0x0008 4 Reset on target
39
0x0010 5 Interrupt on target
40
0x0020 6 Interrupt on overflow
41
0x0040 7 ??? (Repeat?)
42
0x0080 8 ??? (Clears interrupt bit on assertion?)
43
0x0100 9 "uses hblank on counters 1 and 3, and PSXCLOCK on counter 0"
44
0x0200 10 1/8 prescale (counters 0-2 only)
45
0x0400 11 Interrupt (status)
46
0x0800 12 Target (status)
47
0x1000 13 Overflow (status)
48
0x2000 14 1/8 prescale (counters 3-5 only)
49
0x4000 15 1/16 prescale
50
0x6000 14+15 1/256 prescale
51
52
Sources:
53
TC_SYSCLOCK 1 36.864MHz (MIPS R3000A in 36.864MHz IOP mode)
54
TC_PIXEL 2 13.5MHz (Note: regardless of the actual screen mode)
55
TC_HLINE 4 NTSC 15.73426573KHz (858 pixel clock), PAL 15.625KHz (864 pixel clock)
56
TC_HOLD 8 ??? (The FPS2BIOS code has this value too, but it isn't documented by Sony)
57
58
Available timers:
59
Name Source(s) Gate signal Width Prescale Notes
60
----------------------------------------------------------------------------------------
61
RTC0 SYSCLOCK|PIXEL|HOLD H-blank 16 1 In use by PADMAN
62
RTC1 SYSCLOCK|HLINE|HOLD V-blank 16 1 In use by PADMAN
63
RTC2 SYSCLOCK None 16 8
64
RTC3 SYSCLOCK|HLINE V-blank 32 1
65
RTC4 SYSCLOCK None 32 256
66
RTC5 SYSCLOCK None 32 256 */
67
68
extern
void
*GetTimersTable();
69
70
extern
int
AllocHardTimer(
int
source,
int
size,
int
prescale);
71
extern
int
ReferHardTimer(
int
source,
int
size,
int
mode,
int
modemask);
72
extern
int
FreeHardTimer(
int
timid);
73
74
extern
void
SetTimerMode(
int
timid,
int
mode);
75
76
extern
u32 GetTimerStatus(
int
timid);
77
78
extern
void
SetTimerCounter(
int
timid, u32
count
);
79
extern
u32 GetTimerCounter(
int
timid);
80
81
extern
void
SetTimerCompare(
int
timid, u32 compare);
82
extern
u32 GetTimerCompare(
int
timid);
83
84
extern
void
SetHoldMode(
int
holdnum,
int
mode);
85
extern
u32 GetHoldMode(
int
holdnum);
86
87
extern
u32 GetHoldReg(
int
holdnum);
88
89
extern
int
GetHardTimerIntrCode(
int
timid);
90
91
// guessed name
92
extern
u32 GetTimerMode(
int
timid);
93
extern
u32 (*GetTimerReadFunc(
int
timid))();
94
95
// clang-format off
96
#define timrman_IMPORTS \
97
timrman_IMPORTS_start \
98
\
99
I_AllocHardTimer \
100
I_ReferHardTimer \
101
I_FreeHardTimer \
102
\
103
I_SetTimerMode \
104
\
105
I_GetTimerStatus \
106
\
107
I_SetTimerCounter \
108
I_GetTimerCounter \
109
\
110
I_SetTimerCompare \
111
I_GetTimerCompare \
112
\
113
I_SetHoldMode \
114
I_GetHoldMode \
115
\
116
I_GetHardTimerIntrCode \
117
\
118
timrman_IMPORTS_end END_IMPORT_TABLE
119
// clang-format on
120
121
#define timrman_IMPORTS_start DECLARE_IMPORT_TABLE(timrman, 1, 1)
122
#define timrman_IMPORTS_end END_IMPORT_TABLE
123
124
#define I_GetTimersTable DECLARE_IMPORT(3, GetTimersTable)
125
#define I_AllocHardTimer DECLARE_IMPORT(4, AllocHardTimer)
126
#define I_ReferHardTimer DECLARE_IMPORT(5, ReferHardTimer)
127
#define I_FreeHardTimer DECLARE_IMPORT(6, FreeHardTimer)
128
#define I_SetTimerMode DECLARE_IMPORT(7, SetTimerMode)
129
#define I_GetTimerStatus DECLARE_IMPORT(8, GetTimerStatus)
130
#define I_SetTimerCounter DECLARE_IMPORT(9, SetTimerCounter)
131
#define I_GetTimerCounter DECLARE_IMPORT(10, GetTimerCounter)
132
#define I_SetTimerCompare DECLARE_IMPORT(11, SetTimerCompare)
133
#define I_GetTimerCompare DECLARE_IMPORT(12, GetTimerCompare)
134
#define I_SetHoldMode DECLARE_IMPORT(13, SetHoldMode)
135
#define I_GetHoldMode DECLARE_IMPORT(14, GetHoldMode)
136
#define I_GetHoldReg DECLARE_IMPORT(15, GetHoldReg)
137
#define I_GetHardTimerIntrCode DECLARE_IMPORT(16, GetHardTimerIntrCode)
138
#define I_GetTimerMode DECLARE_IMPORT(17, GetTimerMode)
139
#define I_GetTimerReadFunc DECLARE_IMPORT(18, GetTimerReadFunc)
140
141
#ifdef __cplusplus
142
}
143
#endif
144
145
#endif
/* __TIMRMAN_H__ */
count
u32 count
start sector of fragmented bd/file
Definition:
usbhdfsd-common.h:3
irx.h
iop
system
timrman
include
timrman.h
Generated on Fri May 29 2026 14:33:19 for PS2SDK by
1.8.17