r4548@vps: verhaegs | 2007-04-23 10:55:24 -0400
[AROS.git] / arch / .unmaintained / m68k-pp-native / Drivers / irq.hidd / servers.c
blobefca5d41a2687b0177560980ecafcbb10b29324a
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: IRQ servers for standalone i386 AROS
6 Lang: english
7 */
9 #include <oop/oop.h>
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>
16 #include <hidd/irq.h>
17 #include <utility/utility.h>
18 #include <hardware/intbits.h>
20 #include <exec/ptrace.h>
21 #include <asm/irq.h>
23 #include <proto/exec.h>
24 #include <proto/oop.h>
26 #include "irq.h"
27 #include <aros/core.h>
29 # define DEBUG 1
30 # include <aros/debug.h>
33 #ifdef SysBase
34 #undef SysBase
35 #endif /* SysBase */
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
50 here dummy handlers.
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);
71 if (timer) {
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);
82 #undef SysBase
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;
92 if (iv->iv_Code)
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)
102 A1 - Interrupt Data
103 A5 - Interrupt Code vector
104 A6 - SysBase
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
108 though.
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));
117 #if 0
118 if (--SysBase->Elapsed == 0) {
119 SysBase->SysFlags |= 0x2000;
120 SysBase->AttnResched |= 0x80;
122 #endif
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
131 defined ids.
132 *******************************************************************************/
134 #undef SysBase
135 #define SysBase (isd->sysbase)
137 HIDDT_IRQ_Id translation_table[] = {
138 vHidd_IRQ_Timer,
139 vHidd_IRQ_HDD1,
140 /* 2 */ -1,
141 -1,
142 vHidd_IRQ_Serial1,
143 /* 5 */ -1,
145 /* 7 */ -1,
146 vHidd_IRQ_RTC,
147 /* 9 */ -1,
150 vHidd_IRQ_Mouse,
151 /* 13 */-1,
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) {
161 HIDDT_IRQ_Id id;
162 HIDDT_IRQ_HwInfo hwinfo;
163 HIDDT_IRQ_Handler *handler;
165 if (-1 == (id = translation_table[cpl]))
166 return;
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. */