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