| 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 | { | 
|---|
| 51 | USHORT rc = 1; | 
|---|
| 52 |  | 
|---|
| 53 | if( ulSlotNo >= MAX_IRQ_SLOTS ) | 
|---|
| 54 | { | 
|---|
| 55 | DebugInt3(); | 
|---|
| 56 | return FALSE; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | if(fShared) | 
|---|
| 60 | { | 
|---|
| 61 | rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 1 );   // first try shared shared | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|
| 64 | if (rc != 0) | 
|---|
| 65 | { | 
|---|
| 66 | rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 0);   // failed, so try exclusive instead | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | if (rc != 0) | 
|---|
| 70 | { | 
|---|
| 71 | // If error ... | 
|---|
| 72 | rprintf(("ERROR: RMSetIrq %d %d %x FAILED to set interrupt.", ulIrq, fShared, ulSlotNo)); | 
|---|
| 73 | DebugInt3(); | 
|---|
| 74 | return FALSE; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | return TRUE; | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|
| 80 | //****************************************************************************** | 
|---|
| 81 | BOOL ALSA_FreeIrq(ULONG ulIrq) | 
|---|
| 82 | { | 
|---|
| 83 | return (DevIRQClear((WORD16)ulIrq) == 0); | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 | //****************************************************************************** | 
|---|
| 87 | #pragma aux ALSA_Interrupt "ALSA_Interrupt" parm [ebx] | 
|---|
| 88 | ULONG ALSA_Interrupt(ULONG ulSlotNo) | 
|---|
| 89 | { | 
|---|
| 90 | ULONG ulIrqNo; | 
|---|
| 91 |  | 
|---|
| 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; | 
|---|
| 111 | } | 
|---|
| 112 |  | 
|---|