PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ssbusc.c
1
2#include "irx_imports.h"
3#include "ssbusc.h"
4
5extern struct irx_export_table _exp_ssbusc;
6
7#ifdef _IOP
8IRX_ID("ssbus_service", 1, 1);
9#endif
10
11int _start(int argc, char *argv[])
12{
13 int state;
14
15 (void)argc;
16 (void)argv;
17
18 CpuSuspendIntr(&state);
19 if (RegisterLibraryEntries(&_exp_ssbusc)) {
20 CpuResumeIntr(state);
21 return MODULE_NO_RESIDENT_END;
22 }
23 else {
24 CpuResumeIntr(state);
25 return MODULE_RESIDENT_END;
26 }
27}
28
29static vu32 *delay_table[13] =
30{
31 (vu32 *)0xBF801008,
32 (vu32 *)0xBF80100C,
33 (vu32 *)0xBF801010,
34 (vu32 *)0,
35 (vu32 *)0xBF801014,
36 (vu32 *)0xBF801018,
37 (vu32 *)0,
38 (vu32 *)0,
39 (vu32 *)0xBF80101C,
40 (vu32 *)0xBF801414,
41 (vu32 *)0xBF801418,
42 (vu32 *)0xBF80141C,
43 (vu32 *)0xBF801420,
44};
45
46int SetDelay(int device, unsigned int value)
47{
48 vu32 *v1;
49
50 if (device >= (sizeof(delay_table) / sizeof(delay_table[0]))) {
51 return -1;
52 }
53 v1 = delay_table[device];
54 if (v1 == NULL) {
55 return -1;
56 }
57 *v1 = value;
58 return value;
59}
60
61int GetDelay(int device)
62{
63 vu32 *v1;
64
65 if (device >= (sizeof(delay_table) / sizeof(delay_table[0]))) {
66 return -1;
67 }
68 v1 = delay_table[device];
69 if (v1 == NULL) {
70 return -1;
71 }
72 return *v1;
73}
74
75static vu32 *base_address_table[13] =
76{
77 (vu32 *)0xBF801000,
78 (vu32 *)0xBF801400,
79 (vu32 *)0,
80 (vu32 *)0,
81 (vu32 *)0xBF801404,
82 (vu32 *)0xBF801408,
83 (vu32 *)0,
84 (vu32 *)0,
85 (vu32 *)0xBF801004,
86 (vu32 *)0xBF80140C,
87 (vu32 *)0,
88 (vu32 *)0xBF801410,
89 (vu32 *)0,
90};
91
92int SetBaseAddress(int device, unsigned int value)
93{
94 vu32 *v1;
95
96 if (device >= (sizeof(base_address_table) / sizeof(base_address_table[0]))) {
97 return -1;
98 }
99 v1 = base_address_table[device];
100 if (v1 == NULL) {
101 return -1;
102 }
103 *v1 = value;
104 return value;
105}
106
107int GetBaseAddress(int device)
108{
109 vu32 *v1;
110
111 if (device >= (sizeof(base_address_table) / sizeof(base_address_table[0]))) {
112 return -1;
113 }
114 v1 = base_address_table[device];
115 if (v1 == NULL) {
116 return -1;
117 }
118 return *v1;
119}
120
121int SetRecoveryTime(unsigned int value)
122{
123 unsigned int result;
124
125 result = (*((vu32 *)0xBF801020) & (~0xF)) | (value & 0xF);
126 *((vu32 *)0xBF801020) = result;
127 return result;
128}
129
130int GetRecoveryTime(void)
131{
132 return *((vu32 *)0xBF801020) & 0xF;
133}
134
135int SetHoldTime(unsigned int value)
136{
137 unsigned int result;
138
139 result = (*((vu32 *)0xBF801020) & (~0xF0)) | ((value << 4) & 0xF0);
140 *((vu32 *)0xBF801020) = result;
141 return result;
142}
143
144int GetHoldTime(void)
145{
146 return (*((vu32 *)0xBF801020) >> 4) & 0xF;
147}
148
149int SetFloatTime(unsigned int value)
150{
151 unsigned int result;
152
153 result = (*((vu32 *)0xBF801020) & (~0xF00)) | ((value << 8) & 0xF00);
154 *((vu32 *)0xBF801020) = result;
155 return result;
156}
157
158int GetFloatTime(void)
159{
160 return (*((vu32 *)0xBF801020) >> 8) & 0xF;
161}
162
163int SetStrobeTime(unsigned int value)
164{
165 unsigned int result;
166
167 result = (*((vu32 *)0xBF801020) & (~0xF000)) | ((value << 12) & 0xF000);
168 *((vu32 *)0xBF801020) = result;
169 return result;
170}
171
172int GetStrobeTime(void)
173{
174 return (*((vu32 *)0xBF801020) >> 12) & 0xF;
175}
176
177int SetCommonDelay(unsigned int value)
178{
179 unsigned int result;
180
181 result = value;
182 *((vu32 *)0xBF801020) = value;
183 return result;
184}
185
186int GetCommonDelay(void)
187{
188 return *((vu32 *)0xBF801020);
189}
int CpuResumeIntr(int state)
Definition intrman.c:227
int CpuSuspendIntr(int *state)
Definition intrman.c:205