1 | /* $Id: irq.c 142 2000-04-23 14:55:46Z ktk $ */
|
---|
2 |
|
---|
3 | //******************************************************************************
|
---|
4 | // OS/2 implementation of Linux irq kernel services
|
---|
5 | //
|
---|
6 | // Copyright 2000 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 | #define INCL_NOPMAPI
|
---|
25 | #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION
|
---|
26 | #include <os2.h>
|
---|
27 | #include <ossidc.h>
|
---|
28 | #include "irqos2.h"
|
---|
29 |
|
---|
30 | unsigned long volatile jiffies = 0;
|
---|
31 |
|
---|
32 | static IRQHANDLER_INFO irqHandlers[MAX_IRQS][MAX_SHAREDIRQS] = {0};
|
---|
33 | static ULONG nrIrqHandlers[MAX_IRQS] = {0};
|
---|
34 | static ULONG eoiIrq[MAX_IRQS] = {0};
|
---|
35 |
|
---|
36 | //******************************************************************************
|
---|
37 | //******************************************************************************
|
---|
38 | int request_irq(unsigned int irq,
|
---|
39 | void (*handler)(int, void *, void *),
|
---|
40 | unsigned long x0, const char *x1, void *x2)
|
---|
41 | {
|
---|
42 | int i;
|
---|
43 | if(irq > 0xF)
|
---|
44 | return 0;
|
---|
45 |
|
---|
46 | for(i=0;i<MAX_SHAREDIRQS;i++) {
|
---|
47 | if(irqHandlers[irq][i].handler == 0) {
|
---|
48 | irqHandlers[irq][i].handler = handler;
|
---|
49 | irqHandlers[irq][i].x0 = x0;
|
---|
50 | irqHandlers[irq][i].x1 = (char *)x1;
|
---|
51 | irqHandlers[irq][i].x2 = x2;
|
---|
52 | nrIrqHandlers[irq]++;
|
---|
53 | if(OSS32_SetIrq(irq, (ULONG)&oss_process_interrupt) == FALSE) {
|
---|
54 | break;
|
---|
55 | }
|
---|
56 | return 0;
|
---|
57 | }
|
---|
58 | }
|
---|
59 | dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq));
|
---|
60 | return 1;
|
---|
61 | }
|
---|
62 | //******************************************************************************
|
---|
63 | //******************************************************************************
|
---|
64 | void free_irq(unsigned int irq, void *userdata)
|
---|
65 | {
|
---|
66 | int i;
|
---|
67 | for(i=0;i<MAX_SHAREDIRQS;i++) {
|
---|
68 | if(irqHandlers[irq][i].x2 == userdata) {
|
---|
69 | irqHandlers[irq][i].handler = 0;
|
---|
70 | irqHandlers[irq][i].x0 = 0;
|
---|
71 | irqHandlers[irq][i].x1 = 0;
|
---|
72 | irqHandlers[irq][i].x2 = 0;
|
---|
73 | if(--nrIrqHandlers[irq] == 0) {
|
---|
74 | OSS32_FreeIrq(irq);
|
---|
75 | }
|
---|
76 | break;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | }
|
---|
80 | //******************************************************************************
|
---|
81 | //******************************************************************************
|
---|
82 | void eoi_irq(unsigned int irq)
|
---|
83 | {
|
---|
84 | if(irq > 0xf) {
|
---|
85 | DebugInt3();
|
---|
86 | return;
|
---|
87 | }
|
---|
88 | eoiIrq[irq]++;
|
---|
89 | }
|
---|
90 | //******************************************************************************
|
---|
91 | //******************************************************************************
|
---|
92 | BOOL _cdecl oss_process_interrupt(int irq)
|
---|
93 | {
|
---|
94 | BOOL rc;
|
---|
95 | int i;
|
---|
96 | for(i=0;i<MAX_SHAREDIRQS;i++) {
|
---|
97 | if(irqHandlers[irq][i].handler != 0) {
|
---|
98 | irqHandlers[irq][i].handler(irq, irqHandlers[irq][i].x2, 0);
|
---|
99 | rc = (eoiIrq[irq] > 0);
|
---|
100 | if(rc) {
|
---|
101 | eoiIrq[irq] = 0;
|
---|
102 | return rc;
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|
106 | return FALSE;
|
---|
107 | }
|
---|
108 | //******************************************************************************
|
---|
109 | //******************************************************************************
|
---|