r4548@vps: verhaegs | 2007-04-23 10:55:24 -0400
[AROS.git] / arch / .unmaintained / arm-all / Drivers / irq.hidd.sa1100 / servers.c
blobf8797684b69ca062c6ba416b93ad14059c73b3e2
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: IRQ servers for SA1110
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 irq_int = { global_server, "irq: (all) " , NULL};
41 void timer_interrupt(HIDDT_IRQ_Handler *irq, HIDDT_IRQ_HwInfo *hw);
43 /*******************************************************************************
44 Two special irq handlers. As we don't need these two interrupts we define
45 here dummy handlers.
46 *******************************************************************************/
48 void no_action(int cpl, void *dev_id, struct pt_regs *regs, struct irq_staticdata *isd) { }
51 #define SysBase (isd->sysbase)
53 void init_Servers(struct irq_staticdata *isd)
55 HIDDT_IRQ_Handler *timer;
57 irqSet(1, &irq_int , (void *)isd, SysBase);
59 /* Install timer interrupt */
60 timer = AllocMem(sizeof(HIDDT_IRQ_Handler), MEMF_CLEAR|MEMF_PUBLIC);
61 if (timer) {
62 timer->h_Node.ln_Name = "INT_VERTB emulator";
63 timer->h_Node.ln_Type = NT_INTERRUPT;
64 timer->h_Node.ln_Pri = 0;
65 timer->h_Data = &SysBase->IntVects[INTB_VERTB];
66 timer->h_Code = timer_interrupt;
68 Enqueue((struct List *)&isd->irqlist[vHidd_IRQ_Timer], (struct Node *)timer);
72 #undef SysBase
74 /*******************************************************************************
75 This timer interrupt is used to keep compatibility with old Amiga software
76 *******************************************************************************/
78 void timer_interrupt(HIDDT_IRQ_Handler *irq, HIDDT_IRQ_HwInfo *hw)
80 struct IntVector *iv = irq->h_Data;
82 if (iv->iv_Code)
84 /* Call it. I call with all these parameters for a reason.
86 In my `Amiga ROM Kernel Reference Manual: Libraries and
87 Devices' (the 1.3 version), interrupt servers are called
88 with the following 5 parameters.
90 D1 - Mask of INTENAR and INTREQR
91 A0 - 0xDFF000 (base of custom chips)
92 A1 - Interrupt Data
93 A5 - Interrupt Code vector
94 A6 - SysBase
96 It is quite possible that some code uses all of these, so
97 I must supply them here. Obviously I will dummy some of these
98 though.
100 AROS_UFC5(void, iv->iv_Code,
101 AROS_UFCA(ULONG, 0, D1),
102 AROS_UFCA(ULONG, 0, A0),
103 AROS_UFCA(APTR, iv->iv_Data, A1),
104 AROS_UFCA(APTR, iv->iv_Code, A5),
105 AROS_UFCA(struct ExecBase *, hw->sysBase, A6));
107 #if 0
108 if (--SysBase->Elapsed == 0) {
109 SysBase->SysFlags |= 0x2000;
110 SysBase->AttnResched |= 0x80;
112 #endif
116 /*******************************************************************************
117 Global Interrupt Handler
119 This piece of code translates real irq number to AROS specific irq id. This
120 allows us to map system-dependent irqs (audio, ethernet and so on) into well
121 defined ids.
122 *******************************************************************************/
124 #undef SysBase
125 #define SysBase (isd->sysbase)
127 HIDDT_IRQ_Id translation_table[] = {
128 vHidd_IRQ_Timer,
129 vHidd_IRQ_Keyboard,
130 /* 2 */ -1,
131 vHidd_IRQ_Serial2,
132 vHidd_IRQ_Serial1,
133 /* 5 */ -1,
134 -1, //vHidd_IRQ_Floppy,
135 /* 7 */ -1,
136 vHidd_IRQ_RTC,
137 /* 9 */ -1,
140 -1, //vHidd_IRQ_Mouse,
141 /* 13 */-1,
142 -1, //vHidd_IRQ_HDD1,
143 -1 //vHidd_IRQ_HDD2
147 void global_server(int cpl, void *_isd, struct pt_regs *regs)
149 struct irq_staticdata * isd = (struct irq_staticdata *)_isd;
150 if (cpl >= 0 && cpl <= 15) {
151 HIDDT_IRQ_Id id;
152 HIDDT_IRQ_HwInfo hwinfo;
153 HIDDT_IRQ_Handler *handler;
155 if (-1 == (id = translation_table[cpl]))
156 return;
158 hwinfo.Error = 0; /* No errorcode */
159 hwinfo.sysBase = isd->sysbase;
161 /* Execute all installed handlers */
162 ForeachNode(&isd->irqlist[id], handler) {
163 handler->h_Code(handler, &hwinfo);
166 /* Leave the interrupt. */