;===========================================================================
; File:	PCPIC.INC
; Project: MUNGA
; Contents: PC Peripheral Interrupt Controller equates (TASM)
;---------------------------------------------------------------------------
;   Date    Who  Modification
; --------  ---  -----------------------------------------------------------
; 01/04/95  CPB  Initial coding
;---------------------------------------------------------------------------
; Copyright (C) 1994, Virtual World Entertainment, Inc.
; All Rights reserved worldwide
; This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL
;===========================================================================

PIC_MASTER_0	EQU	020h
PIC_MASTER_1	EQU	021h

PIC_SLAVE_0		EQU	0A0h
PIC_SLAVE_1		EQU	0A1h


PIC_TIMERTICK	EQU	00000001b	;PIC:system timer tick
PIC_KEYBOARD	EQU	00000010b	;PIC:keyboard
PIC_CASCADE		EQU	00000100b	;PIC:cascade to secondary PIC
PIC_COM2COM4	EQU	00001000b	;PIC:COM2, COM4 (shared)
PIC_COM1COM3	EQU	00010000b	;PIC:COM1, COM3 (shared)
PIC_LPT2			EQU	00100000b	;PIC:LPT2
PIC_DISKETTE	EQU	01000000b	;PIC:diskette controller
PIC_LPT1			EQU	10000000b	;PIC:LPT1

OCW2_NONSPEC_EOI EQU	00100000b	;OCW2: non-specific EOI
OCW2_SPEC_EOI	EQU	01100000b	;OCW2: specific EOI (set lowest 3 bits)

OCW3_READ_IRR	EQU	00001010b	;OCW3:read IRR
OCW3_READ_ISR	EQU	00001011b	;OCW3:read ISR

ASSERT_PIC MACRO theseBits
			in		al,PIC_MASTER_1
			and	al,NOT theseBits			;;clear bit(s) to enable
			out	PIC_MASTER_1,al
ENDM

ASSERT_PIC_REG MACRO reg
			not	reg
			in		al,PIC_MASTER_1
			and	al,reg						;;clear bit(s) to enable
			out	PIC_MASTER_1,al
			not	reg
ENDM

RETRACT_PIC MACRO theseBits
			in		al,PIC_MASTER_1
			or		al,theseBits				;;set bit(s) to disable
			out	PIC_MASTER_1,al
ENDM

PIC_RESET_MASTER MACRO
			mov	al,OCW2_NONSPEC_EOI
			out	PIC_MASTER_0,al			;;unspecified EOI to master PIC
ENDM

PIC_RESET_SLAVE MACRO
			mov	al,OCW2_NONSPEC_EOI
			out	PIC_SLAVE_0,al				;;unspecified EOI to slave PIC
			out	PIC_MASTER_0,al			;;unspecified EOI to master PIC
ENDM

PIC_ISR_TO_AL MACRO
			mov	al,OCW3_READ_ISR
			out	PIC_MASTER_0,al
			in		al,PIC_MASTER_0			;;reads IMR byte
ENDM

PIC_IRR_TO_AL MACRO
			mov	al,OCW3_READ_IRR
			out	PIC_MASTER_0,al
			in		al,PIC_MASTER_0			;;reads IMR byte
ENDM

PIC_IMR_TO_AL MACRO
			in		al,PIC_MASTER_1			;;reads IMR byte
ENDM
