| 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 | //****************************************************************************** | 
|---|
| 49 | //****************************************************************************** | 
|---|
| 50 | BOOL 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 | rc = DevIRQSet((WORD16) *pISR[ulSlotNo], | 
|---|
| 68 | (WORD16)ulIrq, | 
|---|
| 69 | 0);   // failed, so try exclusive instead | 
|---|
| 70 | } | 
|---|
| 71 |  | 
|---|
| 72 | if (rc != 0) {                    // If error ... | 
|---|
| 73 | dprintf(("ERROR: RMSetIrq %d %d %x FAILED!!", ulIrq, fShared, ulSlotNo)); | 
|---|
| 74 | DebugInt3(); | 
|---|
| 75 | return FALSE; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | return TRUE; | 
|---|
| 79 | } | 
|---|
| 80 | //****************************************************************************** | 
|---|
| 81 | //****************************************************************************** | 
|---|
| 82 | BOOL ALSA_FreeIrq(ULONG ulIrq) | 
|---|
| 83 | { | 
|---|
| 84 | return (DevIRQClear((WORD16)ulIrq) == 0); | 
|---|
| 85 | } | 
|---|
| 86 | //****************************************************************************** | 
|---|
| 87 | //****************************************************************************** | 
|---|
| 88 | ULONG ALSA_Interrupt(ULONG ulSlotNo); | 
|---|
| 89 | #pragma aux ALSA_Interrupt "ALSA_Interrupt" parm [ebx] | 
|---|
| 90 | ULONG ALSA_Interrupt(ULONG ulSlotNo) | 
|---|
| 91 | { | 
|---|
| 92 | ULONG       ulIrqNo; | 
|---|
| 93 |  | 
|---|
| 94 | if( process_interrupt(ulSlotNo, &ulIrqNo) ) { | 
|---|
| 95 | cli(); | 
|---|
| 96 | // We've cleared all service requests.  Send EOI and clear | 
|---|
| 97 | // the carry flag (tells OS/2 kernel that Int was handled). | 
|---|
| 98 | DevEOI( (WORD16)ulIrqNo ); | 
|---|
| 99 | return TRUE; | 
|---|
| 100 | } | 
|---|
| 101 | // Indicate Interrupt not serviced by setting carry flag before | 
|---|
| 102 | // returning to OS/2 kernel.  OS/2 will then shut down the interrupt! | 
|---|
| 103 | // NOTE: Make sure interrupts are not turned on again when this irq isn't ours! | 
|---|
| 104 | return FALSE; | 
|---|
| 105 | } | 
|---|
| 106 | //****************************************************************************** | 
|---|
| 107 | //****************************************************************************** | 
|---|