2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: IRQ servers for standalone i386 AROS
10 #include <aros/asmcall.h>
11 #include <exec/types.h>
12 #include <exec/lists.h>
13 #include <exec/interrupts.h>
14 #include <exec/execbase.h>
15 #include <exec/memory.h>
17 #include <utility/utility.h>
18 #include <hardware/intbits.h>
20 #include <exec/ptrace.h>
23 #include <proto/exec.h>
24 #include <proto/oop.h>
27 #include <aros/core.h>
30 # include <aros/debug.h>
37 void global_server(int cpl
, void *isd
, struct pt_regs
*);
39 struct irqServer irq1_int
= { global_server
, "irq1: " , NULL
};
40 struct irqServer irq2_int
= { global_server
, "irq2: " , NULL
};
41 struct irqServer irq3_int
= { global_server
, "irq3: " , NULL
};
42 struct irqServer irq4_int
= { global_server
, "irq4: serial 1, rtc, keyboard, etc." , NULL
};
43 struct irqServer irq5_int
= { global_server
, "irq5: " , NULL
};
44 struct irqServer irq6_int
= { global_server
, "irq6: " , NULL
};
46 void timer_interrupt(HIDDT_IRQ_Handler
*irq
, HIDDT_IRQ_HwInfo
*hw
);
48 /*******************************************************************************
49 Two special irq handlers. As we don't need these two interrupts we define
51 *******************************************************************************/
53 void no_action(int cpl
, void *dev_id
, struct pt_regs
*regs
, struct irq_staticdata
*isd
) { }
56 #define SysBase (isd->sysbase)
58 void init_Servers(struct irq_staticdata
*isd
)
60 HIDDT_IRQ_Handler
*timer
;
62 irqSet(1, &irq1_int
, (void *)isd
, SysBase
);
63 irqSet(2, &irq2_int
, (void *)isd
, SysBase
);
64 irqSet(3, &irq3_int
, (void *)isd
, SysBase
);
65 irqSet(4, &irq4_int
, (void *)isd
, SysBase
);
66 irqSet(5, &irq5_int
, (void *)isd
, SysBase
);
67 irqSet(6, &irq6_int
, (void *)isd
, SysBase
);
69 /* Install timer interrupt */
70 timer
= AllocMem(sizeof(HIDDT_IRQ_Handler
), MEMF_CLEAR
|MEMF_PUBLIC
);
72 timer
->h_Node
.ln_Name
= "INT_VERTB emulator";
73 timer
->h_Node
.ln_Type
= NT_INTERRUPT
;
74 timer
->h_Node
.ln_Pri
= 0;
75 timer
->h_Data
= &SysBase
->IntVects
[INTB_VERTB
];
76 timer
->h_Code
= timer_interrupt
;
78 Enqueue((struct List
*)&isd
->irqlist
[vHidd_IRQ_Timer
], (struct Node
*)timer
);
84 /*******************************************************************************
85 This timer interrupt is used to keep compatibility with old Amiga software
86 *******************************************************************************/
88 void timer_interrupt(HIDDT_IRQ_Handler
*irq
, HIDDT_IRQ_HwInfo
*hw
)
90 struct IntVector
*iv
= irq
->h_Data
;
94 /* Call it. I call with all these parameters for a reason.
96 In my `Amiga ROM Kernel Reference Manual: Libraries and
97 Devices' (the 1.3 version), interrupt servers are called
98 with the following 5 parameters.
100 D1 - Mask of INTENAR and INTREQR
101 A0 - 0xDFF000 (base of custom chips)
103 A5 - Interrupt Code vector
106 It is quite possible that some code uses all of these, so
107 I must supply them here. Obviously I will dummy some of these
110 AROS_UFC5(void, iv
->iv_Code
,
111 AROS_UFCA(ULONG
, 0, D1
),
112 AROS_UFCA(ULONG
, 0, A0
),
113 AROS_UFCA(APTR
, iv
->iv_Data
, A1
),
114 AROS_UFCA(APTR
, iv
->iv_Code
, A5
),
115 AROS_UFCA(struct ExecBase
*, hw
->sysBase
, A6
));
118 if (--SysBase
->Elapsed
== 0) {
119 SysBase
->SysFlags
|= 0x2000;
120 SysBase
->AttnResched
|= 0x80;
126 /*******************************************************************************
127 Global Interrupt Handler
129 This piece of code translates real irq number to AROS specific irq id. This
130 allows us to map system-dependent irqs (audio, ethernet and so on) into well
132 *******************************************************************************/
135 #define SysBase (isd->sysbase)
137 HIDDT_IRQ_Id translation_table
[] = {
157 void global_server(int cpl
, void *_isd
, struct pt_regs
*regs
)
159 struct irq_staticdata
* isd
= (struct irq_staticdata
*)_isd
;
160 if (cpl
>= 0 && cpl
<= 15) {
162 HIDDT_IRQ_HwInfo hwinfo
;
163 HIDDT_IRQ_Handler
*handler
;
165 if (-1 == (id
= translation_table
[cpl
]))
168 hwinfo
.Error
= 0; /* No errorcode */
169 hwinfo
.sysBase
= isd
->sysbase
;
171 /* Execute all installed handlers */
172 ForeachNode(&isd
->irqlist
[id
], handler
) {
173 handler
->h_Code(handler
, &hwinfo
);
176 /* Leave the interrupt. */