xref: /freebsd/sys/dev/ic/i8259.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1b733b254SJohn Baldwin /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
4b733b254SJohn Baldwin  * Copyright (c) 2003 Peter Wemm
5b733b254SJohn Baldwin  * All rights reserved.
6b733b254SJohn Baldwin  *
7b733b254SJohn Baldwin  * Redistribution and use in source and binary forms, with or without
8b733b254SJohn Baldwin  * modification, are permitted provided that the following conditions
9b733b254SJohn Baldwin  * are met:
10b733b254SJohn Baldwin  * 1. Redistributions of source code must retain the above copyright
11b733b254SJohn Baldwin  *    notice, this list of conditions and the following disclaimer.
12b733b254SJohn Baldwin  * 2. Redistributions in binary form must reproduce the above copyright
13b733b254SJohn Baldwin  *    notice, this list of conditions and the following disclaimer in the
14b733b254SJohn Baldwin  *    documentation and/or other materials provided with the distribution.
15b733b254SJohn Baldwin  *
16b733b254SJohn Baldwin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17b733b254SJohn Baldwin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18b733b254SJohn Baldwin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19b733b254SJohn Baldwin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20b733b254SJohn Baldwin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21b733b254SJohn Baldwin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22b733b254SJohn Baldwin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23b733b254SJohn Baldwin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24b733b254SJohn Baldwin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25b733b254SJohn Baldwin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26b733b254SJohn Baldwin  * SUCH DAMAGE.
27b733b254SJohn Baldwin  */
28b733b254SJohn Baldwin 
29b733b254SJohn Baldwin /*
3021314694SGleb Smirnoff  * Register defintions for the i8259A programmable interrupt controller.
31b733b254SJohn Baldwin  */
32b733b254SJohn Baldwin 
33b733b254SJohn Baldwin #ifndef _DEV_IC_I8259_H_
34b733b254SJohn Baldwin #define	_DEV_IC_I8259_H_
35b733b254SJohn Baldwin 
36b733b254SJohn Baldwin /* Initialization control word 1. Written to even address. */
37b733b254SJohn Baldwin #define	ICW1_IC4	0x01		/* ICW4 present */
38b733b254SJohn Baldwin #define	ICW1_SNGL	0x02		/* 1 = single, 0 = cascaded */
39b733b254SJohn Baldwin #define	ICW1_ADI	0x04		/* 1 = 4, 0 = 8 byte vectors */
40b733b254SJohn Baldwin #define	ICW1_LTIM	0x08		/* 1 = level trigger, 0 = edge */
41b733b254SJohn Baldwin #define	ICW1_RESET	0x10		/* must be 1 */
42b733b254SJohn Baldwin /* 0x20 - 0x80 - in 8080/8085 mode only */
43b733b254SJohn Baldwin 
44b733b254SJohn Baldwin /* Initialization control word 2. Written to the odd address. */
45b733b254SJohn Baldwin /* No definitions, it is the base vector of the IDT for 8086 mode */
46b733b254SJohn Baldwin 
47b733b254SJohn Baldwin /* Initialization control word 3. Written to the odd address. */
48b733b254SJohn Baldwin /* For a master PIC, bitfield indicating a slave 8259 on given input */
49b733b254SJohn Baldwin /* For slave, lower 3 bits are the slave's ID binary id on master */
50b733b254SJohn Baldwin 
51b733b254SJohn Baldwin /* Initialization control word 4. Written to the odd address. */
52b733b254SJohn Baldwin #define	ICW4_8086	0x01		/* 1 = 8086, 0 = 8080 */
53b733b254SJohn Baldwin #define	ICW4_AEOI	0x02		/* 1 = Auto EOI */
54b733b254SJohn Baldwin #define	ICW4_MS		0x04		/* 1 = buffered master, 0 = slave */
55b733b254SJohn Baldwin #define	ICW4_BUF	0x08		/* 1 = enable buffer mode */
56b733b254SJohn Baldwin #define	ICW4_SFNM	0x10		/* 1 = special fully nested mode */
57b733b254SJohn Baldwin 
58b733b254SJohn Baldwin /* Operation control words.  Written after initialization. */
59b733b254SJohn Baldwin 
60b733b254SJohn Baldwin /* Operation control word type 1 */
61b733b254SJohn Baldwin /*
62b733b254SJohn Baldwin  * No definitions.  Written to the odd address.  Bitmask for interrupts.
63b733b254SJohn Baldwin  * 1 = disabled.
64b733b254SJohn Baldwin  */
65b733b254SJohn Baldwin 
66b733b254SJohn Baldwin /* Operation control word type 2.  Bit 3 (0x08) must be zero. Even address. */
67b733b254SJohn Baldwin #define	OCW2_L0		0x01		/* Level */
68b733b254SJohn Baldwin #define	OCW2_L1		0x02
69b733b254SJohn Baldwin #define	OCW2_L2		0x04
70b733b254SJohn Baldwin /* 0x08 must be 0 to select OCW2 vs OCW3 */
71b733b254SJohn Baldwin /* 0x10 must be 0 to select OCW2 vs ICW1 */
72b733b254SJohn Baldwin #define	OCW2_EOI	0x20		/* 1 = EOI */
73b733b254SJohn Baldwin #define	OCW2_SL		0x40		/* EOI mode */
74b733b254SJohn Baldwin #define	OCW2_R		0x80		/* EOI mode */
75b733b254SJohn Baldwin 
76b733b254SJohn Baldwin /* Operation control word type 3.  Bit 3 (0x08) must be set. Even address. */
77b733b254SJohn Baldwin #define	OCW3_RIS	0x01		/* 1 = read IS, 0 = read IR */
78b733b254SJohn Baldwin #define	OCW3_RR		0x02		/* register read */
79b733b254SJohn Baldwin #define	OCW3_P		0x04		/* poll mode command */
80b733b254SJohn Baldwin /* 0x08 must be 1 to select OCW3 vs OCW2 */
81b733b254SJohn Baldwin #define	OCW3_SEL	0x08		/* must be 1 */
82b733b254SJohn Baldwin /* 0x10 must be 0 to select OCW3 vs ICW1 */
83b733b254SJohn Baldwin #define	OCW3_SMM	0x20		/* special mode mask */
84b733b254SJohn Baldwin #define	OCW3_ESMM	0x40		/* enable SMM */
85b733b254SJohn Baldwin 
86b733b254SJohn Baldwin #endif /* !_DEV_IC_I8259_H_ */
87