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