xref: /illumos-gate/usr/src/uts/intel/io/pic.c (revision 5b6ecd7fe9733cbbf05a3badf91c9d6db3f8a544)
1*5b6ecd7fSRichard Lowe /*
2*5b6ecd7fSRichard Lowe  * CDDL HEADER START
3*5b6ecd7fSRichard Lowe  *
4*5b6ecd7fSRichard Lowe  * The contents of this file are subject to the terms of the
5*5b6ecd7fSRichard Lowe  * Common Development and Distribution License, Version 1.0 only
6*5b6ecd7fSRichard Lowe  * (the "License").  You may not use this file except in compliance
7*5b6ecd7fSRichard Lowe  * with the License.
8*5b6ecd7fSRichard Lowe  *
9*5b6ecd7fSRichard Lowe  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*5b6ecd7fSRichard Lowe  * or http://www.opensolaris.org/os/licensing.
11*5b6ecd7fSRichard Lowe  * See the License for the specific language governing permissions
12*5b6ecd7fSRichard Lowe  * and limitations under the License.
13*5b6ecd7fSRichard Lowe  *
14*5b6ecd7fSRichard Lowe  * When distributing Covered Code, include this CDDL HEADER in each
15*5b6ecd7fSRichard Lowe  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*5b6ecd7fSRichard Lowe  * If applicable, add the following below this CDDL HEADER, with the
17*5b6ecd7fSRichard Lowe  * fields enclosed by brackets "[]" replaced with your own identifying
18*5b6ecd7fSRichard Lowe  * information: Portions Copyright [yyyy] [name of copyright owner]
19*5b6ecd7fSRichard Lowe  *
20*5b6ecd7fSRichard Lowe  * CDDL HEADER END
21*5b6ecd7fSRichard Lowe  */
22*5b6ecd7fSRichard Lowe /*
23*5b6ecd7fSRichard Lowe  * Copyright 1999 Sun Microsystems, Inc.  All rights reserved.
24*5b6ecd7fSRichard Lowe  * Use is subject to license terms.
25*5b6ecd7fSRichard Lowe  */
26*5b6ecd7fSRichard Lowe 
27*5b6ecd7fSRichard Lowe /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
28*5b6ecd7fSRichard Lowe /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
29*5b6ecd7fSRichard Lowe /*	  All Rights Reserved  	*/
30*5b6ecd7fSRichard Lowe 
31*5b6ecd7fSRichard Lowe #include <sys/types.h>
32*5b6ecd7fSRichard Lowe #include <sys/pic.h>
33*5b6ecd7fSRichard Lowe #include <sys/sunddi.h>
34*5b6ecd7fSRichard Lowe 
35*5b6ecd7fSRichard Lowe void
picsetup()36*5b6ecd7fSRichard Lowe picsetup()
37*5b6ecd7fSRichard Lowe {
38*5b6ecd7fSRichard Lowe 	/* initialize master first 				*/
39*5b6ecd7fSRichard Lowe 	/* ICW1: Edge-triggered, Cascaded, need ICW4 	*/
40*5b6ecd7fSRichard Lowe 	(void) outb(MCMD_PORT, PIC_ICW1BASE|PIC_NEEDICW4);
41*5b6ecd7fSRichard Lowe 
42*5b6ecd7fSRichard Lowe 	/* ICW2: start master vectors at PIC_VECTBASE 		*/
43*5b6ecd7fSRichard Lowe 	(void) outb(MIMR_PORT, PIC_VECTBASE);
44*5b6ecd7fSRichard Lowe 
45*5b6ecd7fSRichard Lowe 	/* ICW3: define which lines are connected to slaves 	*/
46*5b6ecd7fSRichard Lowe 	(void) outb(MIMR_PORT, 1 << MASTERLINE);
47*5b6ecd7fSRichard Lowe 
48*5b6ecd7fSRichard Lowe 	/* ICW4: buffered master (?), norm eoi, mcs 86 		*/
49*5b6ecd7fSRichard Lowe 	(void) outb(MIMR_PORT, PIC_86MODE);
50*5b6ecd7fSRichard Lowe 
51*5b6ecd7fSRichard Lowe 	/* OCW1: Start the master with all interrupts off 	*/
52*5b6ecd7fSRichard Lowe 	(void) outb(MIMR_PORT, 0xFF);
53*5b6ecd7fSRichard Lowe 
54*5b6ecd7fSRichard Lowe 	/* OCW3: set master into "read isr mode" 		*/
55*5b6ecd7fSRichard Lowe 	(void) outb(MCMD_PORT, PIC_READISR);
56*5b6ecd7fSRichard Lowe 
57*5b6ecd7fSRichard Lowe 	/* initialize the slave 				*/
58*5b6ecd7fSRichard Lowe 	/* ICW1: Edge-triggered, Cascaded, need ICW4 	*/
59*5b6ecd7fSRichard Lowe 	(void) outb(SCMD_PORT, PIC_ICW1BASE|PIC_NEEDICW4);
60*5b6ecd7fSRichard Lowe 
61*5b6ecd7fSRichard Lowe 	/* ICW2: set base of vectors 				*/
62*5b6ecd7fSRichard Lowe 	outb(SIMR_PORT, PIC_VECTBASE +  8);
63*5b6ecd7fSRichard Lowe 
64*5b6ecd7fSRichard Lowe 	/* ICW3: specify ID for this slave 			*/
65*5b6ecd7fSRichard Lowe 	outb(SIMR_PORT, MASTERLINE);
66*5b6ecd7fSRichard Lowe 
67*5b6ecd7fSRichard Lowe 	/* ICW4: buffered slave (?), norm eoi, mcs 86 		*/
68*5b6ecd7fSRichard Lowe 	outb(SIMR_PORT, PIC_86MODE);
69*5b6ecd7fSRichard Lowe 
70*5b6ecd7fSRichard Lowe 	/* OCW1: set interrupt mask 				*/
71*5b6ecd7fSRichard Lowe 	outb(SIMR_PORT, 0xff);
72*5b6ecd7fSRichard Lowe 
73*5b6ecd7fSRichard Lowe 	/* OCW3: set pic into "read isr mode" 			*/
74*5b6ecd7fSRichard Lowe 	outb(SCMD_PORT, PIC_READISR);
75*5b6ecd7fSRichard Lowe }
76