i82489reg.h revision 1.19 1 1.19 msaitoh /* $NetBSD: i82489reg.h,v 1.19 2019/06/14 05:59:39 msaitoh Exp $ */
2 1.1 fvdl
3 1.1 fvdl /*-
4 1.6 ad * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
5 1.1 fvdl * All rights reserved.
6 1.1 fvdl *
7 1.1 fvdl * This code is derived from software contributed to The NetBSD Foundation
8 1.1 fvdl * by Frank van der Linden.
9 1.1 fvdl *
10 1.1 fvdl * Redistribution and use in source and binary forms, with or without
11 1.1 fvdl * modification, are permitted provided that the following conditions
12 1.1 fvdl * are met:
13 1.1 fvdl * 1. Redistributions of source code must retain the above copyright
14 1.1 fvdl * notice, this list of conditions and the following disclaimer.
15 1.1 fvdl * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 fvdl * notice, this list of conditions and the following disclaimer in the
17 1.1 fvdl * documentation and/or other materials provided with the distribution.
18 1.1 fvdl *
19 1.1 fvdl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 fvdl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 fvdl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 fvdl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 fvdl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 fvdl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 fvdl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 fvdl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 fvdl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 fvdl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 fvdl * POSSIBILITY OF SUCH DAMAGE.
30 1.1 fvdl */
31 1.1 fvdl
32 1.1 fvdl
33 1.1 fvdl /*
34 1.1 fvdl * Registers and constants for the 82489DX and Pentium (and up) integrated
35 1.1 fvdl * "local" APIC.
36 1.1 fvdl */
37 1.1 fvdl
38 1.18 msaitoh #define LAPIC_ID 0x020 /* ID. (xAPIC: RW, x2APIC: RO) */
39 1.6 ad # define LAPIC_ID_MASK 0xff000000
40 1.1 fvdl # define LAPIC_ID_SHIFT 24
41 1.1 fvdl
42 1.18 msaitoh #define LAPIC_VERS 0x030 /* Version. RO */
43 1.1 fvdl # define LAPIC_VERSION_MASK 0x000000ff
44 1.1 fvdl # define LAPIC_VERSION_LVT_MASK 0x00ff0000
45 1.1 fvdl # define LAPIC_VERSION_LVT_SHIFT 16
46 1.14 nonaka # define LAPIC_VERSION_DIRECTED_EOI 0x01000000
47 1.16 nonaka # define LAPIC_VERSION_EXTAPIC_SPACE 0x80000000
48 1.1 fvdl
49 1.18 msaitoh #define LAPIC_TPRI 0x080 /* Task Prio. RW */
50 1.1 fvdl # define LAPIC_TPRI_MASK 0x000000ff
51 1.1 fvdl # define LAPIC_TPRI_INT_MASK 0x000000f0
52 1.1 fvdl # define LAPIC_TPRI_SUB_MASK 0x0000000f
53 1.1 fvdl
54 1.18 msaitoh #define LAPIC_APRI 0x090 /* Arbitration prio (xAPIC: RO, x2APIC: NA) */
55 1.1 fvdl # define LAPIC_APRI_MASK 0x000000ff
56 1.1 fvdl
57 1.18 msaitoh #define LAPIC_PPRI 0x0a0 /* Processor prio. RO */
58 1.18 msaitoh #define LAPIC_EOI 0x0b0 /* End Int. W */
59 1.18 msaitoh #define LAPIC_RRR 0x0c0 /* Remote read (xAPIC: RO, x2APIC: NA) */
60 1.18 msaitoh #define LAPIC_LDR 0x0d0 /* Logical dest. (xAPIC: RW, x2APIC: RO) */
61 1.3 joerg
62 1.18 msaitoh #define LAPIC_DFR 0x0e0 /* Dest. format (xAPIC: RW, x2APIC: NA) */
63 1.3 joerg # define LAPIC_DFR_MASK 0xf0000000
64 1.3 joerg # define LAPIC_DFR_FLAT 0xf0000000
65 1.3 joerg # define LAPIC_DFR_CLUSTER 0x00000000
66 1.1 fvdl
67 1.18 msaitoh #define LAPIC_SVR 0x0f0 /* Spurious intvec RW */
68 1.1 fvdl # define LAPIC_SVR_VECTOR_MASK 0x000000ff
69 1.1 fvdl # define LAPIC_SVR_VEC_FIX 0x0000000f
70 1.1 fvdl # define LAPIC_SVR_VEC_PROG 0x000000f0
71 1.1 fvdl # define LAPIC_SVR_ENABLE 0x00000100
72 1.1 fvdl # define LAPIC_SVR_SWEN 0x00000100
73 1.1 fvdl # define LAPIC_SVR_FOCUS 0x00000200
74 1.1 fvdl # define LAPIC_SVR_FDIS 0x00000200
75 1.14 nonaka # define LAPIC_SVR_EOI_BC_DIS 0x00001000
76 1.1 fvdl
77 1.18 msaitoh #define LAPIC_ISR 0x100 /* In-Service Status RO */
78 1.18 msaitoh #define LAPIC_TMR 0x180 /* Trigger Mode RO */
79 1.18 msaitoh #define LAPIC_IRR 0x200 /* Interrupt Req RO */
80 1.18 msaitoh #define LAPIC_ESR 0x280 /* Err status. RW */
81 1.1 fvdl
82 1.19 msaitoh /* Common definitions for ICR, LVT and MSIDATA */
83 1.19 msaitoh #define LAPIC_VECTOR_MASK __BITS(7, 0)
84 1.19 msaitoh #define LAPIC_DLMODE_MASK __BITS(10, 8) /* Delivery Mode */
85 1.19 msaitoh #define LAPIC_DLMODE_FIXED __SHIFTIN(0, LAPIC_DLMODE_MASK)
86 1.19 msaitoh #define LAPIC_DLMODE_LOW __SHIFTIN(1, LAPIC_DLMODE_MASK) /* NA in x2APIC */
87 1.19 msaitoh #define LAPIC_DLMODE_SMI __SHIFTIN(2, LAPIC_DLMODE_MASK)
88 1.19 msaitoh #define LAPIC_DLMODE_NMI __SHIFTIN(4, LAPIC_DLMODE_MASK)
89 1.19 msaitoh #define LAPIC_DLMODE_INIT __SHIFTIN(5, LAPIC_DLMODE_MASK)
90 1.19 msaitoh #define LAPIC_DLMODE_STARTUP __SHIFTIN(6, LAPIC_DLMODE_MASK) /* NA in LVT,MSI*/
91 1.19 msaitoh #define LAPIC_DLMODE_EXTINT __SHIFTIN(7, LAPIC_DLMODE_MASK) /* NA in x2APIC */
92 1.19 msaitoh
93 1.19 msaitoh #define LAPIC_DLSTAT_BUSY __BIT(12) /* NA in x2APIC nor MSI */
94 1.19 msaitoh #define LAPIC_DLSTAT_IDLE 0x00000000
95 1.19 msaitoh
96 1.19 msaitoh #define LAPIC_LEVEL_MASK __BIT(14) /* LAPIC_LVT_LINT_RIRR in LVT LINT */
97 1.19 msaitoh #define LAPIC_LEVEL_ASSERT LAPIC_LEVEL_MASK
98 1.19 msaitoh #define LAPIC_LEVEL_DEASSERT 0x00000000
99 1.19 msaitoh
100 1.19 msaitoh #define LAPIC_TRIGMODE_MASK __BIT(15)
101 1.19 msaitoh #define LAPIC_TRIGMODE_EDGE 0x00000000
102 1.19 msaitoh #define LAPIC_TRIGMODE_LEVEL LAPIC_TRIGMODE_MASK
103 1.19 msaitoh
104 1.19 msaitoh /* Common definitions for LVT */
105 1.19 msaitoh #define LAPIC_LVT_MASKED __BIT(16)
106 1.19 msaitoh
107 1.18 msaitoh #define LAPIC_LVT_CMCI 0x2f0 /* Loc.vec (CMCI) RW */
108 1.19 msaitoh #define LAPIC_ICRLO 0x300 /* Int. cmd. (xAPIC: RW, x2APIC: RW64) */
109 1.14 nonaka
110 1.19 msaitoh # define LAPIC_DSTMODE_MASK __BIT(11)
111 1.19 msaitoh # define LAPIC_DSTMODE_PHYS __SHIFTIN(0, LAPIC_DSTMODE_MASK)
112 1.19 msaitoh # define LAPIC_DSTMODE_LOG __SHIFTIN(1, LAPIC_DSTMODE_MASK)
113 1.19 msaitoh
114 1.19 msaitoh # define LAPIC_DEST_MASK __BITS(19, 18)
115 1.19 msaitoh # define LAPIC_DEST_DEFAULT __SHIFTIN(0, LAPIC_DEST_MASK)
116 1.19 msaitoh # define LAPIC_DEST_SELF __SHIFTIN(1, LAPIC_DEST_MASK)
117 1.19 msaitoh # define LAPIC_DEST_ALLINCL __SHIFTIN(2, LAPIC_DEST_MASK)
118 1.19 msaitoh # define LAPIC_DEST_ALLEXCL __SHIFTIN(3, LAPIC_DEST_MASK)
119 1.1 fvdl
120 1.18 msaitoh #define LAPIC_ICRHI 0x310 /* Int. cmd. (xAPIC: RW, x2APIC: NA) */
121 1.1 fvdl
122 1.19 msaitoh #define LAPIC_LVT_TIMER 0x320 /* Loc.vec.(timer) RW */
123 1.19 msaitoh # define LAPIC_LVT_TMM __BITS(18, 17)
124 1.19 msaitoh # define LAPIC_LVT_TMM_ONESHOT __SHIFTIN(0, LAPIC_LVT_TMM)
125 1.19 msaitoh # define LAPIC_LVT_TMM_PERIODIC __SHIFTIN(1, LAPIC_LVT_TMM)
126 1.19 msaitoh # define LAPIC_LVT_TMM_TSCDLT __SHIFTIN(2, LAPIC_LVT_TMM)
127 1.19 msaitoh
128 1.19 msaitoh #define LAPIC_LVT_THERM 0x330 /* Loc.vec (Thermal) RW */
129 1.19 msaitoh #define LAPIC_LVT_PCINT 0x340 /* Loc.vec (Perf Mon) RW */
130 1.19 msaitoh #define LAPIC_LVT_LINT0 0x350 /* Loc.vec (LINT0) RW */
131 1.19 msaitoh # define LAPIC_LVT_LINT_INP_POL __BIT(13)
132 1.19 msaitoh # define LAPIC_LVT_LINT_RIRR __BIT(14)
133 1.1 fvdl
134 1.19 msaitoh #define LAPIC_LVT_LINT1 0x360 /* Loc.vec (LINT1) RW */
135 1.19 msaitoh #define LAPIC_LVT_ERR 0x370 /* Loc.vec (ERROR) RW */
136 1.18 msaitoh #define LAPIC_ICR_TIMER 0x380 /* Initial count RW */
137 1.18 msaitoh #define LAPIC_CCR_TIMER 0x390 /* Current count RO */
138 1.1 fvdl
139 1.18 msaitoh #define LAPIC_DCR_TIMER 0x3e0 /* Divisor config RW */
140 1.1 fvdl # define LAPIC_DCRT_DIV1 0x0b
141 1.1 fvdl # define LAPIC_DCRT_DIV2 0x00
142 1.1 fvdl # define LAPIC_DCRT_DIV4 0x01
143 1.1 fvdl # define LAPIC_DCRT_DIV8 0x02
144 1.1 fvdl # define LAPIC_DCRT_DIV16 0x03
145 1.1 fvdl # define LAPIC_DCRT_DIV32 0x08
146 1.1 fvdl # define LAPIC_DCRT_DIV64 0x09
147 1.1 fvdl # define LAPIC_DCRT_DIV128 0x0a
148 1.1 fvdl
149 1.18 msaitoh #define LAPIC_SELF_IPI 0x3f0 /* SELF IPI (xAPIC: NA, x2APIC: W) */
150 1.14 nonaka # define LAPIC_SELF_IPI_VEC_MASK 0x000000ff
151 1.14 nonaka
152 1.18 msaitoh #define LAPIC_MSIADDR_BASE 0xfee00000
153 1.12 dyoung #define LAPIC_MSIADDR_DSTID_MASK __BITS(19, 12)
154 1.12 dyoung #define LAPIC_MSIADDR_RSVD0_MASK __BITS(11, 4)
155 1.12 dyoung #define LAPIC_MSIADDR_RH __BIT(3)
156 1.12 dyoung #define LAPIC_MSIADDR_DM __BIT(2)
157 1.12 dyoung #define LAPIC_MSIADDR_RSVD1_MASK __BITS(1, 0)
158 1.12 dyoung
159 1.1 fvdl #define LAPIC_BASE 0xfee00000
160 1.1 fvdl
161 1.1 fvdl #define LAPIC_IRQ_MASK(i) (1 << ((i) + 1))
162 1.8 ad
163 1.10 cegger /* Extended APIC registers, valid when CPUID features4 EAPIC is present */
164 1.13 msaitoh #define LEAPIC_FR 0x400 /* Feature register */
165 1.13 msaitoh # define LEAPIC_FR_ELC __BITS(23,16) /* Ext. Lvt Count RO */
166 1.13 msaitoh # define LEAPIC_FR_EIDCAP __BIT(2) /* Ext. Apic ID Cap. RO */
167 1.13 msaitoh # define LEAPIC_FR_SEIOCAP __BIT(1) /* Specific EOI Cap. RO */
168 1.13 msaitoh # define LEAPIC_FR_IERCAP __BIT(0) /* Intr. Enable Reg. RO */
169 1.10 cegger
170 1.10 cegger #define LEAPIC_CR 0x410 /* Control Register */
171 1.13 msaitoh # define LEAPIC_CR_EID_ENABLE __BIT(2) /* Ext. Apic ID enable */
172 1.13 msaitoh # define LEAPIC_CR_SEOI_ENABLE __BIT(1) /* Specific EOI enable */
173 1.13 msaitoh # define LEAPIC_CR_IER_ENABLE __BIT(0) /* Enable writes to IER */
174 1.10 cegger
175 1.10 cegger #define LEAPIC_SEOIR 0x420 /* Specific EOI Register */
176 1.10 cegger # define LEAPIC_SEOI_VEC __BITS(7,0)
177 1.10 cegger
178 1.10 cegger #define LEAPIC_IER_480 0x480 /* Interrupts 0-31 */
179 1.10 cegger #define LEAPIC_IER_490 0x490 /* Interrupts 32-63 */
180 1.10 cegger #define LEAPIC_IER_4B0 0x4B0 /* Interrupts 64-95 */
181 1.10 cegger #define LEAPIC_IER_4C0 0x4C0 /* Interrupts 96-127 */
182 1.10 cegger #define LEAPIC_IER_4D0 0x4D0 /* Interrupts 128-159 */
183 1.10 cegger #define LEAPIC_IER_4E0 0x4E0 /* Interrupts 160-191 */
184 1.10 cegger #define LEAPIC_IER_4F0 0x4F0 /* Interrupts 192-255 */
185 1.10 cegger
186 1.10 cegger /* Extended Local Vector Table Entries */
187 1.10 cegger #define LEAPIC_LVTR_500 0x500
188 1.10 cegger #define LEAPIC_LVTR_504 0x504
189 1.10 cegger #define LEAPIC_LVTR_508 0x508
190 1.10 cegger #define LEAPIC_LVTR_50C 0x50C
191 1.10 cegger #define LEAPIC_LVTR_510 0x510
192 1.10 cegger #define LEAPIC_LVTR_514 0x514
193 1.10 cegger #define LEAPIC_LVTR_518 0x518
194 1.10 cegger #define LEAPIC_LVTR_51C 0x51C
195 1.10 cegger #define LEAPIC_LVTR_520 0x520
196 1.10 cegger #define LEAPIC_LVTR_524 0x524
197 1.10 cegger #define LEAPIC_LVTR_528 0x528
198 1.10 cegger #define LEAPIC_LVTR_52C 0x52C
199 1.10 cegger #define LEAPIC_LVTR_530 0x530
200 1.13 msaitoh # define LEAPIC_LVTR_MASK __BIT(16) /* interrupt masked RW */
201 1.10 cegger # define LEAPIC_LVTR_DSTAT __BIT(12) /* delivery state RO */
202 1.10 cegger # define LEAPIC_LVTR_MSGTYPE __BITS(10,8) /* Message type */
203 1.10 cegger # define LEAPIC_LVTR_VEC __BITS(7,0) /* the intr. vector */
204