[587] | 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 <devhelp.h>
|
---|
| 29 | #include <include.h> // Defn's for WatCom based drivers.
|
---|
| 30 | #include <irqos2.h>
|
---|
| 31 | #include <dbgos2.h>
|
---|
| 32 | #include "irq.h"
|
---|
| 33 |
|
---|
| 34 | // List of handlers here.
|
---|
| 35 | static FARPTR16 *pISR[MAX_IRQ_SLOTS] = {
|
---|
| 36 | &ISR00,
|
---|
| 37 | &ISR01,
|
---|
| 38 | &ISR02,
|
---|
| 39 | &ISR03,
|
---|
| 40 | &ISR04,
|
---|
| 41 | &ISR05,
|
---|
| 42 | &ISR06,
|
---|
| 43 | &ISR07
|
---|
| 44 | };
|
---|
| 45 |
|
---|
| 46 | extern DBGINT DbgInt;
|
---|
| 47 |
|
---|
| 48 | //******************************************************************************
|
---|
| 49 | BOOL ALSA_SetIrq(ULONG ulIrq, ULONG ulSlotNo, BOOL fShared)
|
---|
| 50 | {
|
---|
[604] | 51 | USHORT rc = 1;
|
---|
[587] | 52 |
|
---|
[604] | 53 | if( ulSlotNo >= MAX_IRQ_SLOTS )
|
---|
| 54 | {
|
---|
| 55 | DebugInt3();
|
---|
| 56 | return FALSE;
|
---|
| 57 | }
|
---|
[587] | 58 |
|
---|
[604] | 59 | if(fShared)
|
---|
| 60 | {
|
---|
| 61 | rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 1 ); // first try shared shared
|
---|
| 62 | }
|
---|
[587] | 63 |
|
---|
[604] | 64 | if (rc != 0)
|
---|
[680] | 65 | {
|
---|
[604] | 66 | rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 0); // failed, so try exclusive instead
|
---|
| 67 | }
|
---|
[587] | 68 |
|
---|
[604] | 69 | if (rc != 0)
|
---|
[680] | 70 | {
|
---|
| 71 | // If error ...
|
---|
| 72 | rprintf(("ERROR: RMSetIrq %d %d %x FAILED to set interrupt.", ulIrq, fShared, ulSlotNo));
|
---|
[604] | 73 | DebugInt3();
|
---|
| 74 | return FALSE;
|
---|
| 75 | }
|
---|
[587] | 76 |
|
---|
[604] | 77 | return TRUE;
|
---|
[587] | 78 | }
|
---|
| 79 |
|
---|
| 80 | //******************************************************************************
|
---|
| 81 | BOOL ALSA_FreeIrq(ULONG ulIrq)
|
---|
| 82 | {
|
---|
[604] | 83 | return (DevIRQClear((WORD16)ulIrq) == 0);
|
---|
[587] | 84 | }
|
---|
| 85 |
|
---|
| 86 | //******************************************************************************
|
---|
| 87 | #pragma aux ALSA_Interrupt "ALSA_Interrupt" parm [ebx]
|
---|
| 88 | ULONG ALSA_Interrupt(ULONG ulSlotNo)
|
---|
| 89 | {
|
---|
[604] | 90 | ULONG ulIrqNo;
|
---|
[587] | 91 |
|
---|
[604] | 92 | // enable interrupts that have higher priority we should
|
---|
| 93 | // allow higher priority interrupts
|
---|
| 94 | sti();
|
---|
| 95 | if( process_interrupt(ulSlotNo, &ulIrqNo) )
|
---|
| 96 | {
|
---|
| 97 | DbgInt.ulIntServiced[DbgInt.ulState]++;
|
---|
| 98 | // We've cleared all service requests.
|
---|
| 99 | // Clear (disable) Interrupts, Send EOI
|
---|
| 100 | // and clear the carry flag (tells OS/2 kernel that Int was handled).
|
---|
| 101 | // Note carry flag is handled in setup.asm
|
---|
| 102 | cli();
|
---|
| 103 | DevEOI( (WORD16)ulIrqNo );
|
---|
| 104 | return TRUE;
|
---|
| 105 | }
|
---|
| 106 | DbgInt.ulIntUnserviced[DbgInt.ulState]++;
|
---|
| 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;
|
---|
[587] | 111 | }
|
---|
| 112 |
|
---|