14Srgrimes/*-
24Srgrimes * Copyright (c) 1990 The Regents of the University of California.
34Srgrimes * All rights reserved.
44Srgrimes *
54Srgrimes * This code is derived from software contributed to Berkeley by
64Srgrimes * William Jolitz.
74Srgrimes *
84Srgrimes * Redistribution and use in source and binary forms, with or without
94Srgrimes * modification, are permitted provided that the following conditions
104Srgrimes * are met:
114Srgrimes * 1. Redistributions of source code must retain the above copyright
124Srgrimes *    notice, this list of conditions and the following disclaimer.
134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
144Srgrimes *    notice, this list of conditions and the following disclaimer in the
154Srgrimes *    documentation and/or other materials provided with the distribution.
164Srgrimes * 4. Neither the name of the University nor the names of its contributors
174Srgrimes *    may be used to endorse or promote products derived from this software
184Srgrimes *    without specific prior written permission.
194Srgrimes *
204Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
214Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
224Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
234Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
244Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
254Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
264Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
274Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
284Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
294Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
304Srgrimes * SUCH DAMAGE.
314Srgrimes *
32619Srgrimes *	from: @(#)icu.h	5.6 (Berkeley) 5/9/91
3350477Speter * $FreeBSD: releng/10.2/sys/x86/isa/icu.h 233031 2012-03-16 12:13:44Z nyan $
344Srgrimes */
354Srgrimes
364Srgrimes/*
374Srgrimes * AT/386 Interrupt Control constants
384Srgrimes * W. Jolitz 8/89
394Srgrimes */
404Srgrimes
41204309Sattilio#ifndef _X86_ISA_ICU_H_
42204309Sattilio#define	_X86_ISA_ICU_H_
434Srgrimes
4493945Snyan#ifdef PC98
4593945Snyan#define	ICU_IMR_OFFSET	2
4693945Snyan#else
4793945Snyan#define	ICU_IMR_OFFSET	1
4893945Snyan#endif
49121985Sjhb
50233031Snyan/*
51233031Snyan * PC-98 machines wire the slave 8259A to pin 7 on the master PIC, and
52233031Snyan * PC-AT machines wire the slave PIC to pin 2 on the master PIC.
53233031Snyan */
54233031Snyan#ifdef PC98
55233031Snyan#define	ICU_SLAVEID	7
56233031Snyan#else
57233031Snyan#define	ICU_SLAVEID	2
58233031Snyan#endif
59233031Snyan
60233031Snyan/*
61233031Snyan * Determine the base master and slave modes not including auto EOI support.
62233031Snyan * All machines that FreeBSD supports use 8086 mode.
63233031Snyan */
64233031Snyan#ifdef PC98
65233031Snyan/*
66233031Snyan * PC-98 machines do not support auto EOI on the second PIC.  Also, it
67233031Snyan * seems that PC-98 machine PICs use buffered mode, and the master PIC
68233031Snyan * uses special fully nested mode.
69233031Snyan */
70233031Snyan#define	BASE_MASTER_MODE	(ICW4_SFNM | ICW4_BUF | ICW4_MS | ICW4_8086)
71233031Snyan#define	BASE_SLAVE_MODE		(ICW4_BUF | ICW4_8086)
72233031Snyan#else
73233031Snyan#define	BASE_MASTER_MODE	ICW4_8086
74233031Snyan#define	BASE_SLAVE_MODE		ICW4_8086
75233031Snyan#endif
76233031Snyan
77233031Snyan/* Enable automatic EOI if requested. */
78233031Snyan#ifdef AUTO_EOI_1
79233031Snyan#define	MASTER_MODE		(BASE_MASTER_MODE | ICW4_AEOI)
80233031Snyan#else
81233031Snyan#define	MASTER_MODE		BASE_MASTER_MODE
82233031Snyan#endif
83233031Snyan#ifdef AUTO_EOI_2
84233031Snyan#define	SLAVE_MODE		(BASE_SLAVE_MODE | ICW4_AEOI)
85233031Snyan#else
86233031Snyan#define	SLAVE_MODE		BASE_SLAVE_MODE
87233031Snyan#endif
88233031Snyan
89233031Snyan#define	IRQ_MASK(irq)		(1 << (irq))
90233031Snyan#define	IMEN_MASK(ai)		(IRQ_MASK((ai)->at_irq))
91233031Snyan
92165302Skmacyvoid	atpic_handle_intr(u_int vector, struct trapframe *frame);
93121985Sjhbvoid	atpic_startup(void);
9425164Speter
95204309Sattilio#endif /* !_X86_ISA_ICU_H_ */
96