source: GPL/branches/uniaud32-2.0/drv32/irq.cpp@ 421

Last change on this file since 421 was 421, checked in by Paul Smedley, 16 years ago

Updates from Pasha to improve IRQ handling and resolve long delays at startup in APIC mode when using ACPI

File size: 5.0 KB
Line 
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.
37static FARPTR16 *pISR[MAX_IRQ_SLOTS] = {
38 &ISR00,
39 &ISR01,
40 &ISR02,
41 &ISR03,
42 &ISR04,
43 &ISR05,
44 &ISR06,
45 &ISR07
46};
47
48//******************************************************************************
49#ifdef ACPI
50//PS+++ fix description
51// Problem is in open high IRQ (acpi.psd /SMP /APIC) at boot time.
52// In my case - this IRQ use SATA and we have flood IRQ. This flood do
53// MASK this IRQ from kernel. Next danis506.add has very slow read from
54// disk.
55// How to fix.
56// At boot time (from DevInit to DevInitComplete) we use low IRQ. In
57// DevInitComplete we close low IRQ and open high IRQ. All values for
58// IRQ we are getting from ACPI call.
59
60//PS+++ Array with saving IRQ number
61#ifdef __cplusplus
62extern "C" {
63#endif
64struct SaveIRQForSlot
65{
66 ULONG ulSlotNo;
67 BYTE LowIRQ;
68 BYTE HighIRQ;
69 BYTE Pin;
70} sISRHigh[8]; //FIX me to MAX_DEVICES or same
71
72int SaveIRQCounter = 0; //PS+++ current position in array
73extern ULONG InitCompleteWas; //PS+++ Indication of InitComplete call
74#ifdef __cplusplus
75}
76#endif
77
78#endif //ACPI
79//******************************************************************************
80BOOL ALSA_SetIrq(ULONG ulIrq, ULONG ulSlotNo, BOOL fShared)
81{
82 USHORT rc = 1;
83
84 if( ulSlotNo >= MAX_IRQ_SLOTS ) {
85 DebugInt3();
86 return FALSE;
87 }
88
89 if(fShared)
90 {
91 rc = DevIRQSet((WORD16) *pISR[ulSlotNo],
92 (WORD16)ulIrq,
93 1 ); // first try shared shared
94 }
95
96 if (rc != 0) { // If error ...
97 dprintf(("ERROR: RMSetIrq %d %d %x - failed to set shared - trying exclusive!!", ulIrq, fShared, ulSlotNo));
98 rc = DevIRQSet((WORD16) *pISR[ulSlotNo],
99 (WORD16)ulIrq,
100 0); // failed, so try exclusive instead
101 }
102
103 if (rc != 0) { // If error ...
104 dprintf(("ERROR: RMSetIrq %d %d %x FAILED shared and exclusive mode!!", ulIrq, fShared, ulSlotNo));
105 DebugInt3();
106 return FALSE;
107 }
108//PS+++ Begin
109#ifdef ACPI
110 if (InitCompleteWas == 0)
111 {
112 dprintf(("RMSetIrq saved %d %d %x was %d", (ULONG)ulIrq, ulSlotNo,(ULONG)sISRHigh[SaveIRQCounter].LowIRQ));
113 sISRHigh[SaveIRQCounter].ulSlotNo = ulSlotNo;
114 SaveIRQCounter++;
115 return TRUE;
116 }
117#endif
118//PS End
119
120 return TRUE;
121}
122//******************************************************************************
123//******************************************************************************
124BOOL ALSA_FreeIrq(ULONG ulIrq)
125{
126 return (DevIRQClear((WORD16)ulIrq) == 0);
127}
128//******************************************************************************
129//******************************************************************************
130ULONG ALSA_Interrupt(ULONG ulSlotNo);
131#pragma aux ALSA_Interrupt "ALSA_Interrupt" parm [ebx]
132ULONG ALSA_Interrupt(ULONG ulSlotNo)
133{
134 ULONG ulIrqNo;
135
136 // enable interrupts that have higher priority we should
137 // allow higher priority interrupts
138 sti();
139 if( process_interrupt(ulSlotNo, &ulIrqNo) ) {
140 // We've cleared all service requests.
141 // Clear (disable) Interrupts, Send EOI
142 // and clear the carry flag (tells OS/2 kernel that Int was handled).
143 // Note carry flag is handled in setup.asm
144 cli();
145 DevEOI( (WORD16)ulIrqNo );
146 return TRUE;
147 }
148 // Indicate Interrupt not serviced by setting carry flag before
149 // returning to OS/2 kernel. OS/2 will then shut down the interrupt!
150 // NOTE: Make sure interrupts are not turned on again when this irq isn't ours!
151 return FALSE;
152}
153//******************************************************************************
154//******************************************************************************
Note: See TracBrowser for help on using the repository browser.