;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; Advanced Communication Board Developer Toolkit ;; ;; (c)Copyright 1993-1995, Sealevel Systems Incorporated ;; ;; ;; ;; For use with Advanced Communication Boards ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; This file defines constants and prototypes for routines that ;; ;; interface to the 8259 Programmable Interrupt Controller (PIC) ;; ;; Source File is INT.ASM ;; ;; .OBJ File linked with main module for interrupt driven program ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TITLE INT ifdef LMOD .MODEL LARGE elseifdef MMOD .MODEL MEDIUM elseifdef TMOD .MODEL TINY else .MODEL SMALL endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MACROS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pause MACRO ; I/O recovery time jmp short $+2 ;This purges the CPU prefetch cue, which allows jmp short $+2 ; for enough delay for most bus speeds speeds. jmp short $+2 ; jmp short $+2 ENDM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INCLUDE INT.INC XTPIC_CONTROL equ 020h XTPIC_MASK equ 021h ATPIC_CONTROL equ 0A0h ATPIC_MASK equ 0A1h .DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; VALID IRQs=2,3,4,5,6,7,8,9,10,11,12,13,14,15 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MASK_XT DB 00 MASK_AT DB 00 OLD_OFF DW 00,00,00,00,00,00,00 DW 00,00,00,00,00,00,00 OLD_SEG DW 00,00,00,00,00,00,00 DW 00,00,00,00,00,00,00 IRQ_NO DB 0AH,0BH,0CH,0DH,0EH,0FH ;XT DB 70h,71H,72H,73H,74H,75H,76H,77H ;AT IRQ_TABLE DB 0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .CODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; IRQSetup : ;; ;; This Routine will initialize the interrupt controller and set ;; ;; the vector for any interrupt 2-15 ;; ;; Parameters: IRQ - Selected Interrupt Request (2-15) ;; ;; SEG1 - Segment of ISR ;; ;; OFF1 - Offset of ISR ;; ;; Return: Nothing ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IRQSetup PROC C PUBLIC USES AX BX CX DX DS ES,IRQ:BYTE,SEG1:WORD,OFF1:WORD mov bl, IRQ call CONVERT_IRQ_BYTE push bx mov al, [IRQ_NO+bx] ;DOS Get Vector mov ah, 35h int 21h ;Returns es:bx mov cx, bx pop bx mov ax, 2 mul bx mov bx, ax mov [OLD_SEG+bx], es mov [OLD_OFF+bx], cx ;Save Old Int vector push ds mov bl, IRQ ;DOS Set Vector call CONVERT_IRQ_BYTE mov al, [IRQ_NO+bx] mov ah, 25h mov dx, OFF1 ; ds:dx mov bx, SEG1 mov ds, bx int 21h pop ds call GET_8259 mov cl, IRQ cmp cl, 07h jle @f sub cl, 8h mov al, 0feh rol al, cl and al, bh out ATPIC_MASK, al pause mov al, 0fbh ;MASK CHAN 2 and al, bl out XTPIC_MASK, al pause ret @@: mov al, 0feh rol al, cl and al, bl ; out XTPIC_MASK, al ;OCW1 MASK ret IRQSetup ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; IRQSetupEx : ;; ;; This Routine will initialize the interrupt controller and set ;; ;; the vector for any interrupt 2-15 ;; ;; Parameters: IRQ - Selected Interrupt Request (2-15) ;; ;; fpISR - Far Ptr to ISR ;; ;; Return: Nothing ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IRQSetupEx PROC C PUBLIC USES BX ES,IRQ:BYTE,fpISR:DWORD les bx, fpISR INVOKE IRQSetup, IRQ, ES, BX ret IRQSetupEx ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; IRQUnsetup : ;; ;; This Routine will restore the bit to the interrupt controller ;; ;; and set the vector to the previous handler ;; ;; Parameters: IRQ - Selected Interrupt Request (2-15) ;; ;; Return: Nothing ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IRQUnsetup PROC C PUBLIC USES AX BX CX DX DS IRQ:BYTE call GET_8259 mov cl, IRQ cmp cl, 07H jle @f sub cl, 8h mov al, 01h rol al, cl or al, bh out ATPIC_MASK, al pause mov al, 0fbh ;MASK CHAN 2 and al, bl ;LEAVE ON FOR AT INTS out XTPIC_MASK, al pause jmp rout @@: mov al, 01h rol al, cl or al, bl ; out XTPIC_MASK, al ;OCW1 MASK rout: mov bl, IRQ call CONVERT_IRQ_BYTE mov cl, [IRQ_NO+bx] mov ch, 25h mov ax, 2 mul bx mov bx, ax mov dx, [OLD_OFF+bx] ;OLD VECTOR mov ds, [OLD_SEG+bx] mov ax, cx int 21h ret IRQUnsetup ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GET_8259 : NEAR : INTERNAL ;; ;; This Routine will return the contents of the PIC mask register ;; ;; Parameters: None ;; ;; Return: bh = AT PIC Mask ; bl = XT PIC Mask ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GET_8259 PROC NEAR in al, XTPIC_MASK ;BL=XT BH=AT mov bl, al ;TEMP XT in al, ATPIC_MASK mov bh, al ;TEMP AT ret GET_8259 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SaveIRQMask : ;; ;; This Routine will save the contents of the PIC mask register ;; ;; Parameters: None ;; ;; Return: Nothing ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SaveIRQMask PROC C PUBLIC USES AX in al, XTPIC_MASK ;GET STATUS pause mov MASK_XT, al in al, ATPIC_MASK pause mov MASK_AT, al ret SaveIRQMask ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ReturnIRQMask : ;; ;; This Routine will restore the contents of the PIC mask register;; ;; Parameters: None ;; ;; Return: Nothing ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ReturnIRQMask PROC C PUBLIC USES AX mov al, MASK_XT out XTPIC_MASK, al pause mov al, MASK_AT out ATPIC_MASK, al pause ret ReturnIRQMask ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CONVERT_IRQ_BYTE : NEAR : INTERNAL ;; ;; This Routine will restore the contents of the PIC mask register;; ;; Parameters: IRQ in AL ;; ;; Return: byte ptr in BL ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CONVERT_IRQ_BYTE PROC NEAR push ax mov bh, 0 mov al, [IRQ_TABLE+bx] ;Convert to Pointer mov bl, al pop ax ret CONVERT_IRQ_BYTE ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END