PS2SDK
PS2 Homebrew Libraries
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 #include <mipscopaccess.h>
18 
19 #ifdef F_DIntr
20 int DIntr()
21 {
22  int eie, res;
23 
24  eie = get_mips_cop_reg(0, COP0_REG_Status);
25  eie &= 0x10000;
26  res = eie != 0;
27 
28  if (!eie)
29  return 0;
30 
31  __asm__ (".p2align 3");
32  do {
33  __asm__ __volatile__("di");
34  EE_SYNCP();
35  eie = get_mips_cop_reg(0, COP0_REG_Status);
36  eie &= 0x10000;
37  } while (eie);
38 
39  return res;
40 }
41 #endif
42 
43 #ifdef F_EIntr
44 int EIntr()
45 {
46  int eie;
47 
48  eie = get_mips_cop_reg(0, COP0_REG_Status);
49  eie &= 0x10000;
50  __asm__ __volatile__("ei");
51 
52  return eie != 0;
53 }
54 #endif
55 
56 #ifdef F_EnableIntc
57 int EnableIntc(int intc)
58 {
59  int eie, res;
60 
61  eie = get_mips_cop_reg(0, COP0_REG_Status);
62  eie &= 0x10000;
63 
64  if (eie)
65  DI();
66 
67  res = _EnableIntc(intc);
68  EE_SYNC();
69 
70  if (eie)
71  EI();
72 
73  return res;
74 }
75 #endif
76 
77 #ifdef F_DisableIntc
78 int DisableIntc(int intc)
79 {
80  int eie, res;
81 
82  eie = get_mips_cop_reg(0, COP0_REG_Status);
83  eie &= 0x10000;
84 
85  if (eie)
86  DI();
87 
88  res = _DisableIntc(intc);
89  EE_SYNC();
90 
91  if (eie)
92  EI();
93 
94  return res;
95 }
96 #endif
97 
98 #ifdef F_EnableDmac
99 int EnableDmac(int dmac)
100 {
101  int eie, res;
102 
103  eie = get_mips_cop_reg(0, COP0_REG_Status);
104  eie &= 0x10000;
105 
106  if (eie)
107  DI();
108 
109  res = _EnableDmac(dmac);
110  EE_SYNC();
111 
112  if (eie)
113  EI();
114 
115  return res;
116 }
117 #endif
118 
119 #ifdef F_DisableDmac
120 int DisableDmac(int dmac)
121 {
122  int eie, res;
123 
124  eie = get_mips_cop_reg(0, COP0_REG_Status);
125  eie &= 0x10000;
126 
127  if (eie)
128  DI();
129 
130  res = _DisableDmac(dmac);
131  EE_SYNC();
132 
133  if (eie)
134  EI();
135 
136  return res;
137 }
138 #endif
139 
140 #ifdef F_SetAlarm
141 int SetAlarm(u16 time, void (*callback)(s32 alarm_id, u16 time, void *common), void *common)
142 {
143  int eie, res;
144 
145  eie = get_mips_cop_reg(0, COP0_REG_Status);
146  eie &= 0x10000;
147 
148  if (eie)
149  DI();
150 
151  res = _SetAlarm(time, callback, common);
152  EE_SYNC();
153 
154  if (eie)
155  EI();
156 
157  return res;
158 }
159 #endif
160 
161 #ifdef F_ReleaseAlarm
162 int ReleaseAlarm(int alarm_id)
163 {
164  int eie, res;
165 
166  eie = get_mips_cop_reg(0, COP0_REG_Status);
167  eie &= 0x10000;
168 
169  if (eie)
170  DI();
171 
172  res = _ReleaseAlarm(alarm_id);
173  EE_SYNC();
174 
175  if (eie)
176  EI();
177 
178  return res;
179 }
180 #endif
181 
182 #ifdef F_iEnableIntc
183 int iEnableIntc(int intc)
184 {
185  int res = _iEnableIntc(intc);
186  EE_SYNC();
187 
188  return res;
189 }
190 #endif
191 
192 #ifdef F_iDisableIntc
193 int iDisableIntc(int intc)
194 {
195  int res = _iDisableIntc(intc);
196  EE_SYNC();
197 
198  return res;
199 }
200 #endif
201 
202 #ifdef F_iEnableDmac
203 int iEnableDmac(int dmac)
204 {
205  int res = _iEnableDmac(dmac);
206  EE_SYNC();
207 
208  return res;
209 }
210 #endif
211 
212 #ifdef F_iDisableDmac
213 int iDisableDmac(int dmac)
214 {
215  int res = _iDisableDmac(dmac);
216  EE_SYNC();
217 
218  return res;
219 }
220 #endif
221 
222 #ifdef F_iSetAlarm
223 int iSetAlarm(u16 time, void (*callback)(s32 alarm_id, u16 time, void *common), void *common)
224 {
225  int res = _iSetAlarm(time, callback, common);
226  EE_SYNC();
227 
228  return res;
229 }
230 #endif
231 
232 #ifdef F_iReleaseAlarm
233 int iReleaseAlarm(int alarm_id)
234 {
235  int res = _iReleaseAlarm(alarm_id);
236  EE_SYNC();
237 
238  return res;
239 }
240 #endif
241 
242 #ifdef F_SyncDCache
243 void SyncDCache(void *start, void *end)
244 {
245  int eie;
246 
247  eie = get_mips_cop_reg(0, COP0_REG_Status);
248  eie &= 0x10000;
249 
250  if (eie)
251  DI();
252 
253  _SyncDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
254 
255  if (eie)
256  EI();
257 }
258 #endif
259 
260 #ifdef F_iSyncDCache
261 void iSyncDCache(void *start, void *end)
262 {
263  _SyncDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
264 }
265 #endif
266 
267 #ifdef F_InvalidDCache
268 void InvalidDCache(void *start, void *end)
269 {
270  int eie;
271 
272  eie = get_mips_cop_reg(0, COP0_REG_Status);
273  eie &= 0x10000;
274 
275  if (eie)
276  DI();
277 
278  _InvalidDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
279 
280  if (eie)
281  EI();
282 }
283 #endif
284 
285 #ifdef F_iInvalidDCache
286 void iInvalidDCache(void *start, void *end)
287 {
288  _InvalidDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
289 }
290 #endif
kernel.h
COP0_REG_Status
@ COP0_REG_Status
Definition: mipscopaccess.h:36
mipscopaccess.h