1 | /* $Id: irq.c,v 1.1.1.1 2003/07/02 13:57:02 eleph Exp $ */
|
---|
2 | /*
|
---|
3 | * OS/2 implementation of Linux irq kernel services
|
---|
4 | *
|
---|
5 | * (C) 2000-2002 InnoTek Systemberatung GmbH
|
---|
6 | * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | * This program is free software; you can redistribute it and/or
|
---|
9 | * modify it under the terms of the GNU General Public License as
|
---|
10 | * published by the Free Software Foundation; either version 2 of
|
---|
11 | * the License, or (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This program is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | * GNU General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU General Public
|
---|
19 | * License along with this program; if not, write to the Free
|
---|
20 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
21 | * USA.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #include "linux.h"
|
---|
26 | #include <linux/init.h>
|
---|
27 | #include <linux/poll.h>
|
---|
28 | #include <asm/uaccess.h>
|
---|
29 | #include <asm/hardirq.h>
|
---|
30 |
|
---|
31 | #define LINUX
|
---|
32 | #include <ossidc.h>
|
---|
33 | #include <ossidc32.h>
|
---|
34 | #include <osspci.h>
|
---|
35 | #include <dbgos2.h>
|
---|
36 | #include "irqos2.h"
|
---|
37 |
|
---|
38 |
|
---|
39 | static IRQHANDLER_INFO irqHandlers[MAX_IRQS][MAX_SHAREDIRQS] = {0};
|
---|
40 | static ULONG nrIrqHandlers[MAX_IRQS] = {0};
|
---|
41 | static ULONG eoiIrq[MAX_IRQS] = {0};
|
---|
42 |
|
---|
43 | BOOL fInInterrupt = FALSE;
|
---|
44 | extern BOOL fSuspended; //pci.c
|
---|
45 |
|
---|
46 | //******************************************************************************
|
---|
47 | //******************************************************************************
|
---|
48 | int request_irq(unsigned int irq,
|
---|
49 | void (*handler)(int, void *, struct pt_regs *),
|
---|
50 | unsigned long x0, const char *x1, void *x2)
|
---|
51 | {
|
---|
52 | int i;
|
---|
53 |
|
---|
54 | if(RMRequestIRQ(hResMgr, irq, (x0 & SA_SHIRQ) ? TRUE : FALSE) == FALSE) {
|
---|
55 | dprintf(("RMRequestIRQ failed for irq %d", irq));
|
---|
56 | return NULL;
|
---|
57 | }
|
---|
58 |
|
---|
59 | if(irq > 0xF) {
|
---|
60 | DebugInt3();
|
---|
61 | return 0;
|
---|
62 | }
|
---|
63 |
|
---|
64 | for(i=0;i<MAX_SHAREDIRQS;i++)
|
---|
65 | {
|
---|
66 | if(irqHandlers[irq][i].handler == 0)
|
---|
67 | {
|
---|
68 | irqHandlers[irq][i].handler = handler;
|
---|
69 | irqHandlers[irq][i].x0 = x0;
|
---|
70 | irqHandlers[irq][i].x1 = (char *)x1;
|
---|
71 | irqHandlers[irq][i].x2 = x2;
|
---|
72 | nrIrqHandlers[irq]++;
|
---|
73 |
|
---|
74 | if(nrIrqHandlers[irq] == 1)
|
---|
75 | {
|
---|
76 | if(RMSetIrq(irq, (x0 & SA_SHIRQ) ? TRUE : FALSE, &oss_process_interrupt) == FALSE)
|
---|
77 | {
|
---|
78 | break;
|
---|
79 | }
|
---|
80 | }
|
---|
81 | return 0;
|
---|
82 | }
|
---|
83 | }
|
---|
84 | dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq));
|
---|
85 | return 1;
|
---|
86 | }
|
---|
87 | //******************************************************************************
|
---|
88 | //******************************************************************************
|
---|
89 | void free_irq(unsigned int irq, void *userdata)
|
---|
90 | {
|
---|
91 | int i;
|
---|
92 |
|
---|
93 | for(i=0;i<MAX_SHAREDIRQS;i++)
|
---|
94 | {
|
---|
95 | if(irqHandlers[irq][i].x2 == userdata) {
|
---|
96 | irqHandlers[irq][i].handler = 0;
|
---|
97 | irqHandlers[irq][i].x0 = 0;
|
---|
98 | irqHandlers[irq][i].x1 = 0;
|
---|
99 | irqHandlers[irq][i].x2 = 0;
|
---|
100 | if(--nrIrqHandlers[irq] == 0) {
|
---|
101 | RMFreeIrq(irq);
|
---|
102 | }
|
---|
103 | break;
|
---|
104 | }
|
---|
105 | }
|
---|
106 | }
|
---|
107 | //******************************************************************************
|
---|
108 | //******************************************************************************
|
---|
109 | void eoi_irq(unsigned int irq)
|
---|
110 | {
|
---|
111 | if(irq > 0xf) {
|
---|
112 | DebugInt3();
|
---|
113 | return;
|
---|
114 | }
|
---|
115 | eoiIrq[irq]++;
|
---|
116 | }
|
---|
117 | //******************************************************************************
|
---|
118 | //******************************************************************************
|
---|
119 | BOOL oss_process_interrupt(int irq)
|
---|
120 | {
|
---|
121 | BOOL rc;
|
---|
122 | int i;
|
---|
123 |
|
---|
124 | #ifdef DEBUG
|
---|
125 | // dprintf(("int proc"));
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | if(fSuspended)
|
---|
129 | {//If our device is suspended, then we can't receive interrupts, so it must
|
---|
130 | //be for some other device
|
---|
131 | //Don't pass it to the linux handler as the device doesn't respond as expected
|
---|
132 | //when suspended
|
---|
133 | #ifdef DEBUG
|
---|
134 | dprintf(("IRQ %d suspended",irq));
|
---|
135 | #endif
|
---|
136 | return FALSE;
|
---|
137 | }
|
---|
138 |
|
---|
139 | for(i=0;i<MAX_SHAREDIRQS;i++)
|
---|
140 | {
|
---|
141 | if(irqHandlers[irq][i].handler != 0)
|
---|
142 | {
|
---|
143 | fInInterrupt = TRUE;
|
---|
144 | irqHandlers[irq][i].handler(irq, irqHandlers[irq][i].x2, 0);
|
---|
145 | rc = (eoiIrq[irq] > 0);
|
---|
146 | fInInterrupt = FALSE;
|
---|
147 | if(rc) {
|
---|
148 | //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver
|
---|
149 | OSS32_ProcessIRQ();
|
---|
150 | eoiIrq[irq] = 0;
|
---|
151 | return TRUE;
|
---|
152 | }
|
---|
153 | }
|
---|
154 | }
|
---|
155 | return FALSE;
|
---|
156 | }
|
---|
157 | //******************************************************************************
|
---|
158 | //******************************************************************************
|
---|
159 | int in_interrupt()
|
---|
160 | {
|
---|
161 | return fInInterrupt;
|
---|
162 | }
|
---|
163 | //******************************************************************************
|
---|
164 | //******************************************************************************
|
---|
165 | void disable_irq(int irq)
|
---|
166 | {
|
---|
167 | dprintf(("disable_irq %d NOT implemented", irq));
|
---|
168 | }
|
---|
169 | //******************************************************************************
|
---|
170 | //******************************************************************************
|
---|