| 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[MAX_IRQ_SLOTS] = { | 
|---|
| 38 | &ISR00, | 
|---|
| 39 | &ISR01, | 
|---|
| 40 | &ISR02, | 
|---|
| 41 | &ISR03, | 
|---|
| 42 | &ISR04, | 
|---|
| 43 | &ISR05, | 
|---|
| 44 | &ISR06, | 
|---|
| 45 | &ISR07 | 
|---|
| 46 | }; | 
|---|
| 47 |  | 
|---|
| 48 | extern DBGINT DbgInt; | 
|---|
| 49 |  | 
|---|
| 50 | //****************************************************************************** | 
|---|
| 51 | BOOL ALSA_SetIrq(ULONG ulIrq, ULONG ulSlotNo, BOOL fShared) | 
|---|
| 52 | { | 
|---|
| 53 | USHORT rc = 1; | 
|---|
| 54 |  | 
|---|
| 55 | if( ulSlotNo >= MAX_IRQ_SLOTS ) | 
|---|
| 56 | { | 
|---|
| 57 | DebugInt3(); | 
|---|
| 58 | return FALSE; | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | if(fShared) | 
|---|
| 62 | { | 
|---|
| 63 | rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 1 );   // first try shared shared | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | if (rc != 0) | 
|---|
| 67 | {                    // If error ... | 
|---|
| 68 | rprintf(("ERROR: RMSetIrq %d %d %x - failed to set shared - trying exclusive!!", ulIrq, fShared, ulSlotNo)); | 
|---|
| 69 | rc = DevIRQSet((WORD16) *pISR[ulSlotNo], (WORD16)ulIrq, 0);   // failed, so try exclusive instead | 
|---|
| 70 | } | 
|---|
| 71 |  | 
|---|
| 72 | if (rc != 0) | 
|---|
| 73 | {                    // If error ... | 
|---|
| 74 | rprintf(("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 | //****************************************************************************** | 
|---|
| 83 | BOOL ALSA_FreeIrq(ULONG ulIrq) | 
|---|
| 84 | { | 
|---|
| 85 | return (DevIRQClear((WORD16)ulIrq) == 0); | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | //****************************************************************************** | 
|---|
| 89 | #pragma aux ALSA_Interrupt "ALSA_Interrupt" parm [ebx] | 
|---|
| 90 | ULONG ALSA_Interrupt(ULONG ulSlotNo) | 
|---|
| 91 | { | 
|---|
| 92 | ULONG ulIrqNo; | 
|---|
| 93 |  | 
|---|
| 94 | // enable interrupts that have higher priority we should | 
|---|
| 95 | // allow higher priority interrupts | 
|---|
| 96 | sti(); | 
|---|
| 97 | if( process_interrupt(ulSlotNo, &ulIrqNo) ) | 
|---|
| 98 | { | 
|---|
| 99 | DbgInt.ulIntServiced[DbgInt.ulState]++; | 
|---|
| 100 | // We've cleared all service requests. | 
|---|
| 101 | // Clear (disable) Interrupts, Send EOI | 
|---|
| 102 | // and clear the carry flag (tells OS/2 kernel that Int was handled). | 
|---|
| 103 | // Note carry flag is handled in setup.asm | 
|---|
| 104 | cli(); | 
|---|
| 105 | DevEOI( (WORD16)ulIrqNo ); | 
|---|
| 106 | return TRUE; | 
|---|
| 107 | } | 
|---|
| 108 | DbgInt.ulIntUnserviced[DbgInt.ulState]++; | 
|---|
| 109 | // Indicate Interrupt not serviced by setting carry flag before | 
|---|
| 110 | // returning to OS/2 kernel.  OS/2 will then shut down the interrupt! | 
|---|
| 111 | // NOTE: Make sure interrupts are not turned on again when this irq isn't ours! | 
|---|
| 112 | return FALSE; | 
|---|
| 113 | } | 
|---|
| 114 |  | 
|---|