ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
glue.c
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # (c) 2003 Marcus R. Brown (mrbrown@0xd6.org)
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #include "kernel.h"
17 
18 #ifdef F_DIntr
19 int DIntr()
20 {
21  int eie, res;
22 
23  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
24  eie &= 0x10000;
25  res = eie != 0;
26 
27  if (!eie)
28  return 0;
29 
30  asm (".p2align 3");
31  do {
32  asm volatile ("di");
33  asm volatile ("sync.p");
34  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
35  eie &= 0x10000;
36  } while (eie);
37 
38  return res;
39 }
40 #endif
41 
42 #ifdef F_EIntr
43 int EIntr()
44 {
45  int eie;
46 
47  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
48  eie &= 0x10000;
49  asm volatile ("ei");
50 
51  return eie != 0;
52 }
53 #endif
54 
55 #ifdef F_EnableIntc
56 int EnableIntc(int intc)
57 {
58  int eie, res;
59 
60  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
61  eie &= 0x10000;
62 
63  if (eie)
64  DI();
65 
66  res = _EnableIntc(intc);
67  EE_SYNC();
68 
69  if (eie)
70  EI();
71 
72  return res;
73 }
74 #endif
75 
76 #ifdef F_DisableIntc
77 int DisableIntc(int intc)
78 {
79  int eie, res;
80 
81  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
82  eie &= 0x10000;
83 
84  if (eie)
85  DI();
86 
87  res = _DisableIntc(intc);
88  EE_SYNC();
89 
90  if (eie)
91  EI();
92 
93  return res;
94 }
95 #endif
96 
97 #ifdef F_EnableDmac
98 int EnableDmac(int dmac)
99 {
100  int eie, res;
101 
102  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
103  eie &= 0x10000;
104 
105  if (eie)
106  DI();
107 
108  res = _EnableDmac(dmac);
109  EE_SYNC();
110 
111  if (eie)
112  EI();
113 
114  return res;
115 }
116 #endif
117 
118 #ifdef F_DisableDmac
119 int DisableDmac(int dmac)
120 {
121  int eie, res;
122 
123  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
124  eie &= 0x10000;
125 
126  if (eie)
127  DI();
128 
129  res = _DisableDmac(dmac);
130  EE_SYNC();
131 
132  if (eie)
133  EI();
134 
135  return res;
136 }
137 #endif
138 
139 #ifdef F_SetAlarm
140 int SetAlarm(u16 time, void (*callback)(s32 alarm_id, u16 time, void *common), void *common)
141 {
142  int eie, res;
143 
144  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
145  eie &= 0x10000;
146 
147  if (eie)
148  DI();
149 
150  res = _SetAlarm(time, callback, common);
151  EE_SYNC();
152 
153  if (eie)
154  EI();
155 
156  return res;
157 }
158 #endif
159 
160 #ifdef F_ReleaseAlarm
161 int ReleaseAlarm(int alarm_id)
162 {
163  int eie, res;
164 
165  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
166  eie &= 0x10000;
167 
168  if (eie)
169  DI();
170 
171  res = _ReleaseAlarm(alarm_id);
172  EE_SYNC();
173 
174  if (eie)
175  EI();
176 
177  return res;
178 }
179 #endif
180 
181 #ifdef F_iEnableIntc
182 int iEnableIntc(int intc)
183 {
184  int res = _iEnableIntc(intc);
185  EE_SYNC();
186 
187  return res;
188 }
189 #endif
190 
191 #ifdef F_iDisableIntc
192 int iDisableIntc(int intc)
193 {
194  int res = _iDisableIntc(intc);
195  EE_SYNC();
196 
197  return res;
198 }
199 #endif
200 
201 #ifdef F_iEnableDmac
202 int iEnableDmac(int dmac)
203 {
204  int res = _iEnableDmac(dmac);
205  EE_SYNC();
206 
207  return res;
208 }
209 #endif
210 
211 #ifdef F_iDisableDmac
212 int iDisableDmac(int dmac)
213 {
214  int res = _iDisableDmac(dmac);
215  EE_SYNC();
216 
217  return res;
218 }
219 #endif
220 
221 #ifdef F_iSetAlarm
222 int iSetAlarm(u16 time, void (*callback)(s32 alarm_id, u16 time, void *common), void *common)
223 {
224  int res = _iSetAlarm(time, callback, common);
225  EE_SYNC();
226 
227  return res;
228 }
229 #endif
230 
231 #ifdef F_iReleaseAlarm
232 int iReleaseAlarm(int alarm_id)
233 {
234  int res = _iReleaseAlarm(alarm_id);
235  EE_SYNC();
236 
237  return res;
238 }
239 #endif
240 
241 #ifdef F_SyncDCache
242 void SyncDCache(void *start, void *end)
243 {
244  int eie;
245 
246  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
247  eie &= 0x10000;
248 
249  if (eie)
250  DI();
251 
252  _SyncDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
253 
254  if (eie)
255  EI();
256 }
257 #endif
258 
259 #ifdef F_iSyncDCache
260 void iSyncDCache(void *start, void *end)
261 {
262  _SyncDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
263 }
264 #endif
265 
266 #ifdef F_InvalidDCache
267 void InvalidDCache(void *start, void *end)
268 {
269  int eie;
270 
271  asm volatile ("mfc0\t%0, $12" : "=r" (eie));
272  eie &= 0x10000;
273 
274  if (eie)
275  DI();
276 
277  _InvalidDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
278 
279  if (eie)
280  EI();
281 }
282 #endif
283 
284 #ifdef F_iInvalidDCache
285 void iInvalidDCache(void *start, void *end)
286 {
287  _InvalidDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
288 }
289 #endif
int DisableDmac(int dmac)
int EnableIntc(int intc)
void _InvalidDCache(void *start, void *end)
int DisableIntc(int intc)
s32 _DisableIntc(s32 cause)
#define EE_SYNC()
Definition: kernel.h:31
s32 _iEnableIntc(s32 cause)
int iDisableDmac(int dmac)
s32 iReleaseAlarm(s32 alarm_id)
void SyncDCache(void *start, void *end)
s32 _iReleaseAlarm(s32 alarm_id)
s32 _iDisableIntc(s32 cause)
s32 _EnableDmac(s32 channel)
int iDisableIntc(int intc)
void InvalidDCache(void *start, void *end)
s32 iSetAlarm(u16 time, void(*callback)(s32 alarm_id, u16 time, void *common), void *common)
s32 _iDisableDmac(s32 channel)
void _SyncDCache(void *start, void *end)
s32 _DisableDmac(s32 channel)
s32 _EnableIntc(s32 cause)
s32 _SetAlarm(u16 time, void(*callback)(s32 alarm_id, u16 time, void *common), void *common)
s32 _ReleaseAlarm(s32 alarm_id)
void iInvalidDCache(void *start, void *end)
s32 _iEnableDmac(s32 channel)
#define DI
Definition: kernel.h:24
s32 _iSetAlarm(u16 time, void(*callback)(s32 alarm_id, u16 time, void *common), void *common)
#define EI
Definition: kernel.h:25
int iEnableIntc(int intc)
void iSyncDCache(void *start, void *end)
int DIntr(void)
int EnableDmac(int dmac)
s32 SetAlarm(u16 time, void(*callback)(s32 alarm_id, u16 time, void *common), void *common)
s32 ReleaseAlarm(s32 alarm_id)
Definition: alarm.c:110
int iEnableDmac(int dmac)
int EIntr(void)
u32 time
Definition: libmouse.c:37
signed int s32
Definition: tamtypes.h:58
unsigned int u32
Definition: tamtypes.h:30
unsigned short u16
Definition: tamtypes.h:24