PS2SDK
PS2 Homebrew Libraries
intrman.h
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright (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 #ifndef __INTRMAN_H__
17 #define __INTRMAN_H__
18 
19 #include <types.h>
20 #include <irx.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
27  IOP_IRQ_VBLANK = 0,
28  IOP_IRQ_SBUS,
29  IOP_IRQ_CDVD,
32  IOP_IRQ_RTC0,
33  IOP_IRQ_RTC1,
34  IOP_IRQ_RTC2,
35  IOP_IRQ_SIO0,
36  IOP_IRQ_SIO1,
37  IOP_IRQ_SPU,
38  IOP_IRQ_PIO,
39  IOP_IRQ_EVBLANK,
42  IOP_IRQ_DEV9,
43  IOP_IRQ_RTC3,
44  IOP_IRQ_RTC4,
45  IOP_IRQ_RTC5,
46  IOP_IRQ_SIO2,
47  IOP_IRQ_HTR0,
48  IOP_IRQ_HTR1,
49  IOP_IRQ_HTR2,
50  IOP_IRQ_HTR3,
51  IOP_IRQ_USB,
54  IOP_IRQ_ILINK,
57 
58  IOP_IRQ_DMA_MDEC_IN = 0x20,
59  IOP_IRQ_DMA_MDEC_OUT,
60  IOP_IRQ_DMA_SIF2,
61  IOP_IRQ_DMA_CDVD,
62  IOP_IRQ_DMA_SPU,
63  IOP_IRQ_DMA_PIO,
64  IOP_IRQ_DMA_GPU_OTC,
67  IOP_IRQ_DMA_SPU2,
68  IOP_IRQ_DMA_DEV9,
69  IOP_IRQ_DMA_SIF0,
70  IOP_IRQ_DMA_SIF1,
71  IOP_IRQ_DMA_SIO2_IN,
72  IOP_IRQ_DMA_SIO2_OUT,
73 
75  IOP_IRQ_SW1 = 0x3E,
78 };
79 
81 {
82  int (*handler)(void *userdata);
83  void *userdata;
85 
86 typedef struct intrman_internals_
87 {
88  intrman_intr_handler_data_t *interrupt_handler_table;
89  int masked_icr_1;
90  int masked_icr_2;
91  int dmac2_interrupt_handler_mask;
93 
94 extern intrman_internals_t *GetIntrmanInternalData(void);
95 
107 extern int RegisterIntrHandler(int irq, int mode, int (*handler)(void *arg), void *arg);
108 
114 extern int ReleaseIntrHandler(int irq);
115 
121 extern int EnableIntr(int irq);
122 
129 extern int DisableIntr(int irq, int *res);
130 
137 extern int CpuDisableIntr();
144 extern int CpuEnableIntr();
145 
154 extern int CpuSuspendIntr(int *state);
155 
164 extern int CpuResumeIntr(int state);
165 
171 extern int CpuInvokeInKmode(void *function, ...);
172 
178 extern void DisableDispatchIntr(int irq);
184 extern void EnableDispatchIntr(int irq);
185 
190 extern int QueryIntrContext(void);
191 
197 extern int QueryIntrStack(void *sp);
198 
199 extern int iCatchMultiIntr(void);
200 
205 extern void SetNewCtxCb(void *cb);
206 extern void ResetNewCtxCb(void);
207 extern void SetShouldPreemptCb(void *cb);
208 extern void ResetShouldPreemptCb(void);
209 
210 #define intrman_IMPORTS_start DECLARE_IMPORT_TABLE(intrman, 1, 2)
211 #define intrman_IMPORTS_end END_IMPORT_TABLE
212 
213 #define I_GetIntrmanInternalData DECLARE_IMPORT(3, GetIntrmanInternalData)
214 #define I_RegisterIntrHandler DECLARE_IMPORT(4, RegisterIntrHandler)
215 #define I_ReleaseIntrHandler DECLARE_IMPORT(5, ReleaseIntrHandler)
216 #define I_EnableIntr DECLARE_IMPORT(6, EnableIntr)
217 #define I_DisableIntr DECLARE_IMPORT(7, DisableIntr)
218 #define I_CpuDisableIntr DECLARE_IMPORT(8, CpuDisableIntr)
219 #define I_CpuEnableIntr DECLARE_IMPORT(9, CpuEnableIntr)
220 #define I_CpuInvokeInKmode DECLARE_IMPORT(14, CpuInvokeInKmode);
221 #define I_DisableDispatchIntr DECLARE_IMPORT(15, DisableDispatchIntr);
222 #define I_EnableDispatchIntr DECLARE_IMPORT(16, EnableDispatchIntr);
223 #define I_CpuSuspendIntr DECLARE_IMPORT(17, CpuSuspendIntr)
224 #define I_CpuResumeIntr DECLARE_IMPORT(18, CpuResumeIntr)
225 #define I_QueryIntrContext DECLARE_IMPORT(23, QueryIntrContext)
226 #define I_QueryIntrStack DECLARE_IMPORT(24, QueryIntrStack)
227 #define I_iCatchMultiIntr DECLARE_IMPORT(25, iCatchMultiIntr)
228 #define I_SetNewCtxCb DECLARE_IMPORT(28, SetNewCtxCb)
229 #define I_SetShouldPreemptCb DECLARE_IMPORT(30, SetShouldPreemptCb)
230 
231 /* For compatibility purposes */
232 #define INUM_VBLANK IOP_IRQ_VBLANK
233 #define INUM_GM IOP_IRQ_SBUS
234 #define INUM_CDROM IOP_IRQ_CDVD
235 #define INUM_DMA IOP_IRQ_DMA
236 #define INUM_RTC0 IOP_IRQ_RTC0
237 #define INUM_RTC1 IOP_IRQ_RTC1
238 #define INUM_RTC2 IOP_IRQ_RTC2
239 #define INUM_SIO0 IOP_IRQ_SIO0
240 #define INUM_SIO1 IOP_IRQ_SIO1
241 #define INUM_SPU IOP_IRQ_SPU
242 #define INUM_PIO IOP_IRQ_PIO
243 #define INUM_EVBLANK IOP_IRQ_EVBLANK
244 #define INUM_DVD IOP_IRQ_DVD
245 #define INUM_PCMCIA IOP_IRQ_DEV9
246 #define INUM_RTC3 IOP_IRQ_RTC3
247 #define INUM_RTC4 IOP_IRQ_RTC4
248 #define INUM_RTC5 IOP_IRQ_RTC5
249 #define INUM_SIO2 IOP_IRQ_SIO2
250 #define INUM_HTR0 IOP_IRQ_HTR0
251 #define INUM_HTR1 IOP_IRQ_HTR1
252 #define INUM_HTR2 IOP_IRQ_HTR2
253 #define INUM_HTR3 IOP_IRQ_HTR3
254 #define INUM_USB IOP_IRQ_USB
255 #define INUM_EXTR IOP_IRQ_EXTR
256 #define INUM_FWRE IOP_IRQ_ILINK
257 #define INUM_FDMA IOP_IRQ_FDMA
258 #define INUM_DMA_0 IOP_IRQ_DMA_MDEC_IN
259 #define INUM_DMA_1 IOP_IRQ_DMA_MDEC_OUT
260 #define INUM_DMA_2 IOP_IRQ_DMA_SIF2
261 #define INUM_DMA_3 IOP_IRQ_DMA_CDVD
262 #define INUM_DMA_4 IOP_IRQ_DMA_SPU
263 #define INUM_DMA_5 IOP_IRQ_DMA_PIO
264 #define INUM_DMA_6 IOP_IRQ_DMA_GPU_OTC
265 #define INUM_DMA_BERR IOP_IRQ_DMA_BERR
266 #define INUM_DMA_7 IOP_IRQ_DMA_SPU2
267 #define INUM_DMA_8 IOP_IRQ_DMA_DEV9
268 #define INUM_DMA_9 IOP_IRQ_DMA_SIF0
269 #define INUM_DMA_10 IOP_IRQ_DMA_SIF1
270 #define INUM_DMA_11 IOP_IRQ_DMA_SIO2_IN
271 #define INUM_DMA_12 IOP_IRQ_DMA_SIO2_OUT
272 
273 #define SetCtxSwitchHandler(...) SetNewCtxCb(__VA_ARGS__)
274 #define ResetCtxSwitchHandler(...) ResetNewCtxCb(__VA_ARGS__)
275 #define SetCtxSwitchReqHandler(...) SetShouldPreemptCb(__VA_ARGS__)
276 #define ResetCtxSwitchReqHandler(...) ResetShouldPreemptCb(__VA_ARGS__)
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif /* __INTRMAN_H__ */
CpuDisableIntr
int CpuDisableIntr()
Definition: intrman.c:228
QueryIntrStack
int QueryIntrStack(void *sp)
RegisterIntrHandler
int RegisterIntrHandler(int irq, int mode, int(*handler)(void *arg), void *arg)
Definition: intrman.c:115
SetNewCtxCb
void SetNewCtxCb(void *cb)
Definition: intrman.c:703
ReleaseIntrHandler
int ReleaseIntrHandler(int irq)
Definition: intrman.c:157
CpuEnableIntr
int CpuEnableIntr()
Definition: intrman.c:240
EnableDispatchIntr
void EnableDispatchIntr(int irq)
Definition: intrman.c:458
DisableIntr
int DisableIntr(int irq, int *res)
Definition: intrman.c:385
IOP_IRQ_EXTR
@ IOP_IRQ_EXTR
Definition: intrman.h:53
QueryIntrContext
int QueryIntrContext(void)
intrman_intr_handler_data_
Definition: intrman.h:80
CpuSuspendIntr
int CpuSuspendIntr(int *state)
Definition: intrman.c:195
DisableDispatchIntr
void DisableDispatchIntr(int irq)
Definition: intrman.c:484
iop_irq_list
iop_irq_list
Definition: intrman.h:26
IOP_IRQ_DMA
@ IOP_IRQ_DMA
Definition: intrman.h:31
intrman_internals_
Definition: intrman.h:86
CpuInvokeInKmode
int CpuInvokeInKmode(void *function,...)
IOP_IRQ_DVD
@ IOP_IRQ_DVD
Definition: intrman.h:41
EnableIntr
int EnableIntr(int irq)
Definition: intrman.c:336
irx.h
IOP_IRQ_FDMA
@ IOP_IRQ_FDMA
Definition: intrman.h:56
IOP_IRQ_DMA_BERR
@ IOP_IRQ_DMA_BERR
Definition: intrman.h:66
CpuResumeIntr
int CpuResumeIntr(int state)
Definition: intrman.c:217
IOP_IRQ_SW2
@ IOP_IRQ_SW2
Definition: intrman.h:77
IOP_IRQ_SW1
@ IOP_IRQ_SW1
Definition: intrman.h:75