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

Last change on this file since 382 was 375, checked in by rjerant, 17 years ago

Change interrupt handler to run with interrupts enabled

File size: 3.8 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//******************************************************************************
50BOOL ALSA_SetIrq(ULONG ulIrq, ULONG ulSlotNo, BOOL fShared)
51{
52 USHORT rc = 1;
53
54 if( ulSlotNo >= MAX_IRQ_SLOTS ) {
55 DebugInt3();
56 return FALSE;
57 }
58
59 if(fShared)
60 {
61 rc = DevIRQSet((WORD16) *pISR[ulSlotNo],
62 (WORD16)ulIrq,
63 1 ); // first try shared shared
64 }
65
66 if (rc != 0) { // If error ...
67 dprintf(("ERROR: RMSetIrq %d %d %x - failed to set shared - trying exclusive!!", ulIrq, fShared, ulSlotNo));
68 rc = DevIRQSet((WORD16) *pISR[ulSlotNo],
69 (WORD16)ulIrq,
70 0); // failed, so try exclusive instead
71 }
72
73 if (rc != 0) { // If error ...
74 dprintf(("ERROR: RMSetIrq %d %d %x FAILED shared and exclusive mode!!", ulIrq, fShared, ulSlotNo));
75 DebugInt3();
76 return FALSE;
77 }
78
79 return TRUE;
80}
81//******************************************************************************
82//******************************************************************************
83BOOL ALSA_FreeIrq(ULONG ulIrq)
84{
85 return (DevIRQClear((WORD16)ulIrq) == 0);
86}
87//******************************************************************************
88//******************************************************************************
89ULONG ALSA_Interrupt(ULONG ulSlotNo);
90#pragma aux ALSA_Interrupt "ALSA_Interrupt" parm [ebx]
91ULONG ALSA_Interrupt(ULONG ulSlotNo)
92{
93 ULONG ulIrqNo;
94
95 // enable interrupts that have higher priority we should
96 // allow higher priority interrupts
97 sti();
98 if( process_interrupt(ulSlotNo, &ulIrqNo) ) {
99 // We've cleared all service requests.
100 // Clear (disable) Interrupts, Send EOI
101 // and clear the carry flag (tells OS/2 kernel that Int was handled).
102 // Note carry flag is handled in setup.asm
103 cli();
104 DevEOI( (WORD16)ulIrqNo );
105 return TRUE;
106 }
107 // Indicate Interrupt not serviced by setting carry flag before
108 // returning to OS/2 kernel. OS/2 will then shut down the interrupt!
109 // NOTE: Make sure interrupts are not turned on again when this irq isn't ours!
110 return FALSE;
111}
112//******************************************************************************
113//******************************************************************************
Note: See TracBrowser for help on using the repository browser.