1 | /* $Id: irq.cpp,v 1.1.1.1 2003/07/02 13:56:56 eleph Exp $ */
|
---|
2 | /*
|
---|
3 | * IRQ handler functions
|
---|
4 | *
|
---|
5 | * (C) 2000-2002 InnoTek Systemberatung GmbH
|
---|
6 | *
|
---|
7 | * This program is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU General Public License as
|
---|
9 | * published by the Free Software Foundation; either version 2 of
|
---|
10 | * the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This program is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public
|
---|
18 | * License along with this program; if not, write to the Free
|
---|
19 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
20 | * USA.
|
---|
21 | *
|
---|
22 | */
|
---|
23 |
|
---|
24 | #define INCL_NOPMAPI
|
---|
25 | #define INCL_DOSINFOSEG // Need Global info seg in rm.cpp algorithms
|
---|
26 | #include <os2.h>
|
---|
27 |
|
---|
28 | #include <devtype.h>
|
---|
29 | #include <devinfo.h>
|
---|
30 | #include <devhelp.h>
|
---|
31 | #include <include.h> // Defn's for WatCom based drivers.
|
---|
32 | #include <irqos2.h>
|
---|
33 | #include <dbgos2.h>
|
---|
34 | #include "irq.h"
|
---|
35 |
|
---|
36 | // List of handlers here.
|
---|
37 | static FARPTR16 *pISR[NUM_IRQLEVELS] = {
|
---|
38 | NULL,
|
---|
39 | NULL,
|
---|
40 | NULL,
|
---|
41 | &ISR03,
|
---|
42 | &ISR04,
|
---|
43 | &ISR05,
|
---|
44 | NULL,
|
---|
45 | &ISR07,
|
---|
46 | NULL,
|
---|
47 | &ISR09,
|
---|
48 | &ISR10,
|
---|
49 | &ISR11,
|
---|
50 | &ISR12,
|
---|
51 | &ISR13,
|
---|
52 | &ISR14,
|
---|
53 | &ISR15
|
---|
54 | };
|
---|
55 |
|
---|
56 | static PFNIRQ pfnAlsaIRQHandler = NULL;
|
---|
57 |
|
---|
58 | //******************************************************************************
|
---|
59 | //******************************************************************************
|
---|
60 | BOOL RMSetIrq(ULONG ulIrq, BOOL fShared, PFNIRQ pfnIrqHandler)
|
---|
61 | {
|
---|
62 | USHORT rc = 1;
|
---|
63 |
|
---|
64 | if(pISR[ulIrq] == NULL) {
|
---|
65 | DebugInt3();
|
---|
66 | return FALSE;
|
---|
67 | }
|
---|
68 | if(fShared)
|
---|
69 | {
|
---|
70 | rc = DevIRQSet((WORD16) *pISR[ ulIrq ],
|
---|
71 | (WORD16)ulIrq,
|
---|
72 | 1 ); // first try shared shared
|
---|
73 | }
|
---|
74 | if (rc != 0) { // If error ...
|
---|
75 | rc = DevIRQSet((WORD16) *pISR[ ulIrq ],
|
---|
76 | (WORD16)ulIrq,
|
---|
77 | 0); // failed, so try exclusive instead
|
---|
78 | }
|
---|
79 | if (rc != 0) { // If error ...
|
---|
80 | dprintf(("ERROR: RMSetIrq %d %d %x FAILED!!", ulIrq, fShared, pfnIrqHandler));
|
---|
81 | DebugInt3();
|
---|
82 | return FALSE;
|
---|
83 | }
|
---|
84 | //Always called with the same handler
|
---|
85 | if(pfnAlsaIRQHandler && (pfnAlsaIRQHandler != pfnIrqHandler)) {
|
---|
86 | DebugInt3();
|
---|
87 | return FALSE;
|
---|
88 | }
|
---|
89 | pfnAlsaIRQHandler = pfnIrqHandler;
|
---|
90 | return TRUE;
|
---|
91 | }
|
---|
92 | //******************************************************************************
|
---|
93 | //******************************************************************************
|
---|
94 | BOOL RMFreeIrq(ULONG ulIrq)
|
---|
95 | {
|
---|
96 | return (DevIRQClear((WORD16)ulIrq) == 0);
|
---|
97 | }
|
---|
98 | //******************************************************************************
|
---|
99 | //******************************************************************************
|
---|
100 | ULONG ALSA_Interrupt(ULONG irqnr);
|
---|
101 | #pragma aux ALSA_Interrupt "ALSA_Interrupt" parm [ebx]
|
---|
102 | ULONG ALSA_Interrupt(ULONG irqnr)
|
---|
103 | {
|
---|
104 | if(pfnAlsaIRQHandler == NULL) {
|
---|
105 | DebugInt3();
|
---|
106 | return FALSE;
|
---|
107 | }
|
---|
108 | #ifdef DEBUG
|
---|
109 | dprintf2(("irq %d",irqnr));
|
---|
110 | #endif
|
---|
111 | if(pfnAlsaIRQHandler(irqnr)) {
|
---|
112 | cli();
|
---|
113 | // We've cleared all service requests. Send EOI and clear
|
---|
114 | // the carry flag (tells OS/2 kernel that Int was handled).
|
---|
115 | DevEOI( (WORD16)irqnr );
|
---|
116 | return TRUE;
|
---|
117 | }
|
---|
118 | // Indicate Interrupt not serviced by setting carry flag before
|
---|
119 | // returning to OS/2 kernel. OS/2 will then shut down the interrupt!
|
---|
120 | // NOTE: Make sure interrupts are not turned on again when this irq isn't ours!
|
---|
121 | return FALSE;
|
---|
122 | }
|
---|
123 | //******************************************************************************
|
---|
124 | //******************************************************************************
|
---|