sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
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
15
16#include "kernel.h"
17#include <mipscopaccess.h>
18
19int DIntr()
20{
21 int eie, res;
22
23 eie = get_mips_cop_reg(0, COP0_REG_Status);
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 EE_SYNCP();
34 eie = get_mips_cop_reg(0, COP0_REG_Status);
35 eie &= 0x10000;
36 } while (eie);
37
38 return res;
39}
40
41int EIntr()
42{
43 int eie;
44
45 eie = get_mips_cop_reg(0, COP0_REG_Status);
46 eie &= 0x10000;
47 __asm__ __volatile__("ei");
48
49 return eie != 0;
50}
51
52int EnableIntc(int intc)
53{
54 int eie, res;
55
56 eie = get_mips_cop_reg(0, COP0_REG_Status);
57 eie &= 0x10000;
58
59 if (eie)
60 DI();
61
62 res = _EnableIntc(intc);
63 EE_SYNC();
64
65 if (eie)
66 EI();
67
68 return res;
69}
70
71int DisableIntc(int intc)
72{
73 int eie, res;
74
75 eie = get_mips_cop_reg(0, COP0_REG_Status);
76 eie &= 0x10000;
77
78 if (eie)
79 DI();
80
81 res = _DisableIntc(intc);
82 EE_SYNC();
83
84 if (eie)
85 EI();
86
87 return res;
88}
89
90int EnableDmac(int dmac)
91{
92 int eie, res;
93
94 eie = get_mips_cop_reg(0, COP0_REG_Status);
95 eie &= 0x10000;
96
97 if (eie)
98 DI();
99
100 res = _EnableDmac(dmac);
101 EE_SYNC();
102
103 if (eie)
104 EI();
105
106 return res;
107}
108
109int DisableDmac(int dmac)
110{
111 int eie, res;
112
113 eie = get_mips_cop_reg(0, COP0_REG_Status);
114 eie &= 0x10000;
115
116 if (eie)
117 DI();
118
119 res = _DisableDmac(dmac);
120 EE_SYNC();
121
122 if (eie)
123 EI();
124
125 return res;
126}
127
128int iEnableIntc(int intc)
129{
130 int res = _iEnableIntc(intc);
131 EE_SYNC();
132
133 return res;
134}
135
136int iDisableIntc(int intc)
137{
138 int res = _iDisableIntc(intc);
139 EE_SYNC();
140
141 return res;
142}
143
144int iEnableDmac(int dmac)
145{
146 int res = _iEnableDmac(dmac);
147 EE_SYNC();
148
149 return res;
150}
151
152int iDisableDmac(int dmac)
153{
154 int res = _iDisableDmac(dmac);
155 EE_SYNC();
156
157 return res;
158}
159
160void SyncDCache(void *start, void *end)
161{
162 int eie;
163
164 eie = get_mips_cop_reg(0, COP0_REG_Status);
165 eie &= 0x10000;
166
167 if (eie)
168 DI();
169
170 _SyncDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
171
172 if (eie)
173 EI();
174}
175
176void iSyncDCache(void *start, void *end)
177{
178 _SyncDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
179}
180
181void InvalidDCache(void *start, void *end)
182{
183 int eie;
184
185 eie = get_mips_cop_reg(0, COP0_REG_Status);
186 eie &= 0x10000;
187
188 if (eie)
189 DI();
190
191 _InvalidDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
192
193 if (eie)
194 EI();
195}
196
197void iInvalidDCache(void *start, void *end)
198{
199 _InvalidDCache((void *)((u32)start & 0xffffffc0), (void *)((u32)end & 0xffffffc0));
200}
#define COP0_REG_Status