/*******************************************************************/ /* Advanced Communication Board Developer Toolkit 1993 */ /* For use with Advanced Communication Boards */ /* INT.C */ /* This file defines routines that setup interrupt handling. */ /* */ /* Source file is INT.C */ /* .OBJ File Linked to Program for interrupt use */ /*******************************************************************/ #include #include #include #include #include #include #include "int.h" /******************************************************************* Stuff to make us "compiler friendly" *******************************************************************/ #ifdef _BORLAND #define FAR far #define INTERRUPT far interrupt #define IN inportb #define OUT outportb #define GETVECT getvect #define SETVECT setvect #else #define FAR _far #define INTERRUPT __far __interrupt #define IN _inp #define OUT _outp #define GETVECT _dos_getvect #define SETVECT _dos_setvect #endif /******************************************************************* Stuff for IRQ Setup Routines *******************************************************************/ unsigned char XT_PIC_MASK; unsigned char AT_PIC_MASK; VOIDINTPROC OldIRQVector; /******************************************************************* IRQSetup : This routine will replace the specified Interrupt Vector and setup the XT and AT PIC. *******************************************************************/ void IRQSetup(unsigned char bIRQ, VOIDINTPROC fpISR) { unsigned char bNumber; if(bIRQ < 8) /* Setup the IRQ Vector*/ bNumber = 0x08 + bIRQ; /* i.e IRQ2 = 0x0a*/ else bNumber = 0x68 + bIRQ; /* i.e IRQ9 = 0x71*/ OldIRQVector = GETVECT(bNumber); SETVECT(bNumber, (VOIDINTPROC) fpISR); if(bIRQ < 8) {bNumber = 0x01 << bIRQ; OUT(0x21, (~bNumber & IN(0x21))); } else {OUT(0x21,( 0xfb & IN(0x21))); /*mask IRQ2*/ bNumber = 0x01 << (bIRQ - 8); OUT(0xA1, (~bNumber & IN(0xA1))); } } /******************************************************************* IRQUnsetup : This routine will restore the specified Interrupt Vector and restore the XT and AT PIC. *******************************************************************/ void IRQUnsetup(unsigned char bIRQ) { unsigned char bNumber; /* Setup the IRQ Vector*/ if(bIRQ < 8) bNumber = 0x08 + bIRQ; /* i.e IRQ2 = 0x0a*/ else bNumber = 0x68 + bIRQ; /* i.e IRQ9 = 0x71*/ SETVECT(bNumber, OldIRQVector); return; } /******************************************************************* SaveIRQMask : This routine will save the contents of the PIC mask register *******************************************************************/ void SaveIRQMask (void) { XT_PIC_MASK = (unsigned char) IN( 0x21); /*Save the PIC Mask*/ AT_PIC_MASK = (unsigned char) IN( 0xA1); } /* SaveIRQMask */ /******************************************************************* ReturnIRQMask : This routine will restore the contents of the PIC mask register *******************************************************************/ void ReturnIRQMask (void) { /*Restore the PIC Mask*/ OUT(0x21, XT_PIC_MASK); OUT(0xA1, AT_PIC_MASK); } /* ReturnIRQMask */