xref: /dflybsd-src/sys/platform/pc64/apic/apicreg.h (revision f89b4a45c33ccb84eab6ec70ca37a5b9e33e5a81)
1c8fe38aeSMatthew Dillon /*
2c8fe38aeSMatthew Dillon  * Copyright (c) 2003,2004,2008 The DragonFly Project.  All rights reserved.
3c8fe38aeSMatthew Dillon  *
4c8fe38aeSMatthew Dillon  * This code is derived from software contributed to The DragonFly Project
5c8fe38aeSMatthew Dillon  * by Matthew Dillon <dillon@backplane.com>
6c8fe38aeSMatthew Dillon  *
7c8fe38aeSMatthew Dillon  * Redistribution and use in source and binary forms, with or without
8c8fe38aeSMatthew Dillon  * modification, are permitted provided that the following conditions
9c8fe38aeSMatthew Dillon  * are met:
10c8fe38aeSMatthew Dillon  *
11c8fe38aeSMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
12c8fe38aeSMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
13c8fe38aeSMatthew Dillon  * 2. Redistributions in binary form must reproduce the above copyright
14c8fe38aeSMatthew Dillon  *    notice, this list of conditions and the following disclaimer in
15c8fe38aeSMatthew Dillon  *    the documentation and/or other materials provided with the
16c8fe38aeSMatthew Dillon  *    distribution.
17c8fe38aeSMatthew Dillon  * 3. Neither the name of The DragonFly Project nor the names of its
18c8fe38aeSMatthew Dillon  *    contributors may be used to endorse or promote products derived
19c8fe38aeSMatthew Dillon  *    from this software without specific, prior written permission.
20c8fe38aeSMatthew Dillon  *
21c8fe38aeSMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22c8fe38aeSMatthew Dillon  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23c8fe38aeSMatthew Dillon  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24c8fe38aeSMatthew Dillon  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25c8fe38aeSMatthew Dillon  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26c8fe38aeSMatthew Dillon  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27c8fe38aeSMatthew Dillon  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28c8fe38aeSMatthew Dillon  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29c8fe38aeSMatthew Dillon  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30c8fe38aeSMatthew Dillon  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31c8fe38aeSMatthew Dillon  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32c8fe38aeSMatthew Dillon  * SUCH DAMAGE.
33c8fe38aeSMatthew Dillon  *
34c8fe38aeSMatthew Dillon  * Copyright (c) 1996, by Peter Wemm and Steve Passe, All rights reserved.
35c8fe38aeSMatthew Dillon  *
36c8fe38aeSMatthew Dillon  * Redistribution and use in source and binary forms, with or without
37c8fe38aeSMatthew Dillon  * modification, are permitted provided that the following conditions
38c8fe38aeSMatthew Dillon  * are met:
39c8fe38aeSMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
40c8fe38aeSMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
41c8fe38aeSMatthew Dillon  * 2. The name of the developer may NOT be used to endorse or promote products
42c8fe38aeSMatthew Dillon  *    derived from this software without specific prior written permission.
43c8fe38aeSMatthew Dillon  *
44c8fe38aeSMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
45c8fe38aeSMatthew Dillon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46c8fe38aeSMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47c8fe38aeSMatthew Dillon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
48c8fe38aeSMatthew Dillon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49c8fe38aeSMatthew Dillon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50c8fe38aeSMatthew Dillon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51c8fe38aeSMatthew Dillon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52c8fe38aeSMatthew Dillon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53c8fe38aeSMatthew Dillon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54c8fe38aeSMatthew Dillon  * SUCH DAMAGE.
55c8fe38aeSMatthew Dillon  *
56c8fe38aeSMatthew Dillon  * $FreeBSD: src/sys/i386/include/apic.h,v 1.14.2.2 2003/03/21 21:46:15 jhb Exp $
57c8fe38aeSMatthew Dillon  * $DragonFly: src/sys/platform/pc64/apic/apicreg.h,v 1.1 2008/08/29 17:07:12 dillon Exp $
58c8fe38aeSMatthew Dillon  */
59c8fe38aeSMatthew Dillon 
60c8fe38aeSMatthew Dillon #ifndef _MACHINE_APICREG_H_
61c8fe38aeSMatthew Dillon #define _MACHINE_APICREG_H_
62c8fe38aeSMatthew Dillon 
63c8fe38aeSMatthew Dillon /*
64c8fe38aeSMatthew Dillon  * Local && I/O APIC definitions for Pentium P54C+ Built-in APIC.
65c8fe38aeSMatthew Dillon  *
66c8fe38aeSMatthew Dillon  * A per-cpu APIC resides in memory location 0xFEE00000.
67c8fe38aeSMatthew Dillon  *
68c8fe38aeSMatthew Dillon  *		  31 ... 24   23 ... 16   15 ... 8     7 ... 0
69c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
70c8fe38aeSMatthew Dillon  * 0000 	|           |           |           |           |
71c8fe38aeSMatthew Dillon  * 0010 	|           |           |           |           |
72c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
73c8fe38aeSMatthew Dillon  *
74c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
75c8fe38aeSMatthew Dillon  * 0020 ID	|     | ID  |           |           |           | RW
76c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
77c8fe38aeSMatthew Dillon  *
78c8fe38aeSMatthew Dillon  *		    The physical APIC ID is used with physical interrupt
79c8fe38aeSMatthew Dillon  *		    delivery modes.
80c8fe38aeSMatthew Dillon  *
81c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
82c8fe38aeSMatthew Dillon  * 0030 VER	|           |           |           |           |
83c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
84c8fe38aeSMatthew Dillon  * 0040 	|           |           |           |           |
85c8fe38aeSMatthew Dillon  * 0050 	|           |           |           |           |
86c8fe38aeSMatthew Dillon  * 0060 	|           |           |           |           |
87c8fe38aeSMatthew Dillon  * 0070 	|           |           |           |           |
88c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
89c8fe38aeSMatthew Dillon  * 0080 TPR	|           |           |           | PRIO SUBC |
90c8fe38aeSMatthew Dillon  * 0090 APR	|           |           |           |           |
91c8fe38aeSMatthew Dillon  * 00A0 PPR	|           |           |           |           |
92c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
93c8fe38aeSMatthew Dillon  *
94c8fe38aeSMatthew Dillon  *		    The Task Priority Register provides a priority threshold
95c8fe38aeSMatthew Dillon  *		    mechanism for interrupting the processor.  Only interrupts
96c8fe38aeSMatthew Dillon  *		    with a higher priority then that specified in the TPR will
97c8fe38aeSMatthew Dillon  *		    be served.   Other interrupts are recorded and serviced
98c8fe38aeSMatthew Dillon  *		    as soon as the TPR value decreases enough to allow that
99c8fe38aeSMatthew Dillon  *		    (unless EOId by another APIC).
100c8fe38aeSMatthew Dillon  *
101c8fe38aeSMatthew Dillon  *		    PRIO (7:4).  Main priority.  If 15 the APIC will not
102c8fe38aeSMatthew Dillon  *		    		 accept any interrupts.
103c8fe38aeSMatthew Dillon  *		    SUBC (3:0)	 Sub priority.  See APR/PPR.
104c8fe38aeSMatthew Dillon  *
105c8fe38aeSMatthew Dillon  *
106c8fe38aeSMatthew Dillon  *		    The Processor Priority Register determines whether a
107c8fe38aeSMatthew Dillon  *		    pending interrupt can be dispensed to the processor.  ISRV
108c8fe38aeSMatthew Dillon  *		    Is the vector of the highest priority ISR bit set or
109c8fe38aeSMatthew Dillon  *		    zero if no ISR bit is set.
110c8fe38aeSMatthew Dillon  *
111c8fe38aeSMatthew Dillon  *		    IF TPR[7:4] >= ISRV[7:4]
112c8fe38aeSMatthew Dillon  *			PPR[7:0] = TPR[7:0]
113c8fe38aeSMatthew Dillon  *		    ELSE
114c8fe38aeSMatthew Dillon  *			PPR[7:0] = ISRV[7:4].000
115c8fe38aeSMatthew Dillon  *
116c8fe38aeSMatthew Dillon  *		    The Arbitration Priority Register holds the current
117c8fe38aeSMatthew Dillon  *		    lowest priority of the procsesor, a value used during
118c8fe38aeSMatthew Dillon  *		    lowest-priority arbitration.
119c8fe38aeSMatthew Dillon  *
120c8fe38aeSMatthew Dillon  *		    IF (TPR[7:4] >= IRRV[7:4] AND TPR[7:4] > ISRV[7:4])
121c8fe38aeSMatthew Dillon  *			APR[7:0] = TPR[7:0]
122c8fe38aeSMatthew Dillon  *		    ELSE
123c8fe38aeSMatthew Dillon  *			APR[7:4] = max((TPR[7:4]&ISRV[7:4]),IRRV[7:4]).000
124c8fe38aeSMatthew Dillon  *
125c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
126c8fe38aeSMatthew Dillon  * 00B0 EOI	|           |           |           |           |
127c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
128c8fe38aeSMatthew Dillon  * 00C0 	|           |           |           |           |
129c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
130c8fe38aeSMatthew Dillon  * 00D0 LDR	|LOG APICID |           |           |           |
131c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
132c8fe38aeSMatthew Dillon  * 00E0 DFR	|MODEL|     |           |           |           |
133c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
134c8fe38aeSMatthew Dillon  *
135c8fe38aeSMatthew Dillon  *		    The logical APIC ID is used with logical interrupt
136c8fe38aeSMatthew Dillon  *		    delivery modes.  Interpretation of logical destination
137c8fe38aeSMatthew Dillon  *		    information depends on the MODEL bits in the Destination
138c8fe38aeSMatthew Dillon  *		    Format Regiuster.
139c8fe38aeSMatthew Dillon  *
140c8fe38aeSMatthew Dillon  *		    MODEL=1111 FLAT MODEL - The MDA is interpreted as
141c8fe38aeSMatthew Dillon  *					    a decoded address.  By setting
142c8fe38aeSMatthew Dillon  *					    one bit in the LDR for each
143c8fe38aeSMatthew Dillon  *					    local apic 8 APICs can coexist.
144c8fe38aeSMatthew Dillon  *
145c8fe38aeSMatthew Dillon  *		    MODEL=0000 CLUSTER MODEL -
146c8fe38aeSMatthew Dillon  *
147c8fe38aeSMatthew Dillon  *		  31 ... 24   23 ... 16   15 ... 8     7 ... 0
148c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
149c8fe38aeSMatthew Dillon  * 00F0 SVR	|           |           |       FE  |  vvvvvvvv |
150c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
151c8fe38aeSMatthew Dillon  *
152c8fe38aeSMatthew Dillon  *		    Spurious interrupt vector register.  The 4 low
153c8fe38aeSMatthew Dillon  *		    vector bits must be programmed to 1111, e.g.
154c8fe38aeSMatthew Dillon  *		    vvvv1111.
155c8fe38aeSMatthew Dillon  *
156bb467734SMatthew Dillon  *		    E - LAPIC enable (0 = disable, 1 = enable)
157c8fe38aeSMatthew Dillon  *
158c8fe38aeSMatthew Dillon  *		    F - Focus processor disable (1 = disable, 0 = enable)
159c8fe38aeSMatthew Dillon  *
160c8fe38aeSMatthew Dillon  *		    NOTE: The handler for the spurious interrupt vector
161c8fe38aeSMatthew Dillon  *		    should *NOT* issue an EOI because the spurious
162c8fe38aeSMatthew Dillon  *		    interrupt does not effect the ISR.
163c8fe38aeSMatthew Dillon  *
164c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
165c8fe38aeSMatthew Dillon  * 0100-0170 ISR|           |           |           |           |
166c8fe38aeSMatthew Dillon  * 0180-01F0 TMR|           |           |           |           |
167c8fe38aeSMatthew Dillon  * 0200-0270 IRR|           |           |           |           |
168c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
169c8fe38aeSMatthew Dillon  *
170c8fe38aeSMatthew Dillon  *		    These registers represent 256 bits, one bit for each
171c8fe38aeSMatthew Dillon  *		    possible interrupt.  Interrupts 0-15 are reserved so
172c8fe38aeSMatthew Dillon  *		    bits 0-15 are also reserved.
173c8fe38aeSMatthew Dillon  *
174c8fe38aeSMatthew Dillon  *		    TMR - Trigger mode register.  Upon acceptance of an int
175c8fe38aeSMatthew Dillon  *			  the corresponding bit is cleared for edge-trig and
176c8fe38aeSMatthew Dillon  *			  set for level-trig.  If the TMR bit is set (level),
177c8fe38aeSMatthew Dillon  *			  the local APIC sends an EOI to all I/O APICs as
178c8fe38aeSMatthew Dillon  *			  a result of software issuing an EOI command.
179c8fe38aeSMatthew Dillon  *
180c8fe38aeSMatthew Dillon  *		    IRR - Interrupt Request Register.  Contains active
181c8fe38aeSMatthew Dillon  *			  interrupt requests that have been accepted but not
182c8fe38aeSMatthew Dillon  *			  yet dispensed by the current local APIC.  The bit is
183c8fe38aeSMatthew Dillon  *			  cleared and the corresponding ISR bit is set when
184c8fe38aeSMatthew Dillon  *			  the INTA cycle is issued.
185c8fe38aeSMatthew Dillon  *
186c8fe38aeSMatthew Dillon  *		    ISR - Interrupt In-Service register.  Interrupt has been
187c8fe38aeSMatthew Dillon  *			  delivered but not yet fully serviced.  Cleared when
188c8fe38aeSMatthew Dillon  *			  an EOI is issued from the processor.  An EOI will
189c8fe38aeSMatthew Dillon  *			  also send an EOI to all I/O APICs if TMR was set.
190c8fe38aeSMatthew Dillon  *
191c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
192c8fe38aeSMatthew Dillon  * 0280 ESR	|           |           |           |           |
193c8fe38aeSMatthew Dillon  * 0290-02F0    |           |           |           |           |
194c8fe38aeSMatthew Dillon  *		+--FEDCBA98-+--76543210-+--FEDCBA98-+-----------+
195c8fe38aeSMatthew Dillon  * 0300	ICR_LO	|           |      XX   |  TL SDMMM | vector    |
196c8fe38aeSMatthew Dillon  * 0310	ICR_HI	| DEST FIELD|           |           |           |
197c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
198c8fe38aeSMatthew Dillon  *
199c8fe38aeSMatthew Dillon  *		    The interrupt command register.  Generally speaking
200c8fe38aeSMatthew Dillon  *		    writing to ICR_LO initiates a command.  All fields
201c8fe38aeSMatthew Dillon  *		    are R/W except the 'S' (delivery status) field, which
202c8fe38aeSMatthew Dillon  *		    is read-only.  When
203c8fe38aeSMatthew Dillon  *
204c8fe38aeSMatthew Dillon  *
205c8fe38aeSMatthew Dillon  *			XX:	Destination Shorthand field:
206c8fe38aeSMatthew Dillon  *
207c8fe38aeSMatthew Dillon  *				00	Use Destination field
208c8fe38aeSMatthew Dillon  *				01	Self only.  Dest field ignored.
209c8fe38aeSMatthew Dillon  *				10	All including self (uses a
210c8fe38aeSMatthew Dillon  *					destination field of 0x0F)
211c8fe38aeSMatthew Dillon  *				11	All excluding self (uses a
212c8fe38aeSMatthew Dillon  *					destination field of 0x0F)
213c8fe38aeSMatthew Dillon  *
214c8fe38aeSMatthew Dillon  *			T:	1 = Level 0 = Edge Trigger modde, used for
215c8fe38aeSMatthew Dillon  *				the INIT level de-assert delivery mode only
216c8fe38aeSMatthew Dillon  *				to de-assert a request.
217c8fe38aeSMatthew Dillon  *
218c8fe38aeSMatthew Dillon  *			L:	0 = De-Assert, 1 = Assert.  Always write as
219c8fe38aeSMatthew Dillon  *				1 when initiating a new command.  Can only
220c8fe38aeSMatthew Dillon  *				write as 0 for INIT mode de-assertion of
221c8fe38aeSMatthew Dillon  *				command.
222c8fe38aeSMatthew Dillon  *
223c8fe38aeSMatthew Dillon  *			S:	1 = Send Pending.  Interrupt has been injected
224c8fe38aeSMatthew Dillon  *				but APIC has not yet accepted it.
225c8fe38aeSMatthew Dillon  *
226c8fe38aeSMatthew Dillon  *			D:	0=physical 1=logical.  In physical mode
227c8fe38aeSMatthew Dillon  *				only 24-27 of DEST FIELD is used from ICR_HI.
228c8fe38aeSMatthew Dillon  *
229c8fe38aeSMatthew Dillon  *			MMM:	000 Fixed. Deliver to all processors according
230c8fe38aeSMatthew Dillon  *				    to the ICR.  Always treated as edge trig.
231c8fe38aeSMatthew Dillon  *
232c8fe38aeSMatthew Dillon  *				001 Lowest Priority.  Deliver to just the
233c8fe38aeSMatthew Dillon  *				    processor running at the lowest priority.
234c8fe38aeSMatthew Dillon  *
235c8fe38aeSMatthew Dillon  *				010 SMI.  The vector must be 00B.  Only edge
236c8fe38aeSMatthew Dillon  *				    triggered is allowed.  The vector field
237c8fe38aeSMatthew Dillon  *				    must be programmed to zero (huh?).
238c8fe38aeSMatthew Dillon  *
239c8fe38aeSMatthew Dillon  *				011 <reserved>
240c8fe38aeSMatthew Dillon  *
241c8fe38aeSMatthew Dillon  *				100 NMI.  Deliver as an NMI to all processors
242c8fe38aeSMatthew Dillon  *				    listed in the destination field.  The
243c8fe38aeSMatthew Dillon  *				    vector is ignored.  Alawys treated as
244c8fe38aeSMatthew Dillon  *				    edge triggered.
245c8fe38aeSMatthew Dillon  *
246c8fe38aeSMatthew Dillon  *				101 INIT.  Deliver as an INIT signal to all
247c8fe38aeSMatthew Dillon  *				    processors (like FIXED).  Vector is ignored
248c8fe38aeSMatthew Dillon  *				    and it is always edge-triggered.
249c8fe38aeSMatthew Dillon  *
250c8fe38aeSMatthew Dillon  *				110 Start Up.  Sends a special message between
251c8fe38aeSMatthew Dillon  *				    cpus.  the vector contains a start-up
252c8fe38aeSMatthew Dillon  *				    address for MP boot protocol.
253c8fe38aeSMatthew Dillon  *				    Always edge triggered.  Note: a startup
254c8fe38aeSMatthew Dillon  *				    int is not automatically tried in case of
255c8fe38aeSMatthew Dillon  *				    failure.
256c8fe38aeSMatthew Dillon  *
257c8fe38aeSMatthew Dillon  *				111 <reserved>
258c8fe38aeSMatthew Dillon  *
259c8fe38aeSMatthew Dillon  *		+-----------+--------10-+--FEDCBA98-+-----------+
260c8fe38aeSMatthew Dillon  * 0320	LTIMER  |           |        TM |  ---S---- | vector    |
261c8fe38aeSMatthew Dillon  * 0330		|           |           |           |           |
262c8fe38aeSMatthew Dillon  *		+-----------+--------10-+--FEDCBA98-+-----------+
263c8fe38aeSMatthew Dillon  * 0340	LVPCINT	|           |        -M |  ---S-MMM | vector    |
264c8fe38aeSMatthew Dillon  * 0350	LVINT0	|           |        -M |  LRPS-MMM | vector    |
265c8fe38aeSMatthew Dillon  * 0360 LVINT1	|           |        -M |  LRPS-MMM | vector    |
266c8fe38aeSMatthew Dillon  * 0370	LVERROR	|           |        -M |  -------- | vector    |
267c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
268c8fe38aeSMatthew Dillon  *
269c8fe38aeSMatthew Dillon  *			T:	1 = periodic, 0 = one-shot
270c8fe38aeSMatthew Dillon  *
271c8fe38aeSMatthew Dillon  *			M:	1 = masked
272c8fe38aeSMatthew Dillon  *
273c8fe38aeSMatthew Dillon  *			L:	1 = level, 0 = edge
274c8fe38aeSMatthew Dillon  *
275c8fe38aeSMatthew Dillon  *			R:	For level triggered only, set to 1 when a
276c8fe38aeSMatthew Dillon  *				level int is accepted, cleared by EOI.
277c8fe38aeSMatthew Dillon  *
278c8fe38aeSMatthew Dillon  *			P:	Pin Polarity 0 = Active High, 1 = Active Low
279c8fe38aeSMatthew Dillon  *
280c8fe38aeSMatthew Dillon  *			S:	1 = Send Pending.  Interrupt has been injected
281c8fe38aeSMatthew Dillon  *				but APIC has not yet accepted it.
282c8fe38aeSMatthew Dillon  *
283c8fe38aeSMatthew Dillon  *			MMM 	000 = Fixed	deliver to cpu according to LVT
284c8fe38aeSMatthew Dillon  *
285c8fe38aeSMatthew Dillon  *			MMM 	100 = NMI	deliver as an NMI.  Always edge
286c8fe38aeSMatthew Dillon  *
287c8fe38aeSMatthew Dillon  *			MMM 	111 = ExtInt	deliver from 8259, routes INTA
288c8fe38aeSMatthew Dillon  *						bus cycle to external
289c8fe38aeSMatthew Dillon  *						controller.  Controller is
290c8fe38aeSMatthew Dillon  *						expected to supply vector.
291c8fe38aeSMatthew Dillon  *						Always level.
292c8fe38aeSMatthew Dillon  *
293c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
294c8fe38aeSMatthew Dillon  * 0380	TMR_ICR	|           |           |           |           |
295c8fe38aeSMatthew Dillon  * 0390	TMR_CCR	|           |           |           |           |
296c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
297c8fe38aeSMatthew Dillon  *
298c8fe38aeSMatthew Dillon  *		The timer initial count register and current count
299c8fe38aeSMatthew Dillon  *		register (32 bits)
300c8fe38aeSMatthew Dillon  *
301c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
302c8fe38aeSMatthew Dillon  * 03A0		|           |           |           |           |
303c8fe38aeSMatthew Dillon  * 03B0		|           |           |           |           |
304c8fe38aeSMatthew Dillon  * 03C0		|           |           |           |           |
305c8fe38aeSMatthew Dillon  * 03D0		|           |           |           |           |
306c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
307c8fe38aeSMatthew Dillon  * 03E0 TMR_DCR	|           |           |           |      d-dd |
308c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
309c8fe38aeSMatthew Dillon  *
310c8fe38aeSMatthew Dillon  *		The timer divide configuration register.  d-dd is:
311c8fe38aeSMatthew Dillon  *
312c8fe38aeSMatthew Dillon  *		0000 - divide by 2
313c8fe38aeSMatthew Dillon  *		0001 - divide by 4
314c8fe38aeSMatthew Dillon  *		0010 - divide by 8
315c8fe38aeSMatthew Dillon  *		0011 - divide by 16
316c8fe38aeSMatthew Dillon  *		1000 - divide by 32
317c8fe38aeSMatthew Dillon  *		1001 - divide by 64
318c8fe38aeSMatthew Dillon  *		1010 - divide by 128
319c8fe38aeSMatthew Dillon  *		1011 - divide by 1
320c8fe38aeSMatthew Dillon  *
321c8fe38aeSMatthew Dillon  *	NOTE ON EOI: Upon receiving an EOI the APIC clears the highest priority
322c8fe38aeSMatthew Dillon  *	interrupt in the ISR and selects the next highest priority interrupt
323c8fe38aeSMatthew Dillon  *	for posting to the CPU.  If the interrupt being EOId was level
324c8fe38aeSMatthew Dillon  *	triggered the APIC will send an EOI to all I/O APICs.  For the moment
325c8fe38aeSMatthew Dillon  *	you can write garbage to the EOI register but for future compatibility
326c8fe38aeSMatthew Dillon  *	0 should be written.
32767534613SMatthew Dillon  *
32867534613SMatthew Dillon  * 03F0 SELF_IPI
32967534613SMatthew Dillon  * 0400 EXT_FEAT
33067534613SMatthew Dillon  * 0410 EXT_CTRL
33167534613SMatthew Dillon  * 0420 EXT_SEOI
33267534613SMatthew Dillon  * 0430
33367534613SMatthew Dillon  * 0440
33467534613SMatthew Dillon  * 0450
33567534613SMatthew Dillon  * 0460
33667534613SMatthew Dillon  * 0470
33767534613SMatthew Dillon  * 0480 EXT_IER0
33867534613SMatthew Dillon  * 0490 EXT_IER1
33967534613SMatthew Dillon  * 04A0 EXT_IER2
34067534613SMatthew Dillon  * 04B0 EXT_IER3
34167534613SMatthew Dillon  * 04C0 EXT_IER4
34267534613SMatthew Dillon  * 04D0 EXT_IER5
34367534613SMatthew Dillon  * 04E0 EXT_IER6
34467534613SMatthew Dillon  * 04F0 EXT_IER7
34567534613SMatthew Dillon  * 0500 EXT_LVT0
34667534613SMatthew Dillon  * 0510 EXT_LVT1
34767534613SMatthew Dillon  * 0520 EXT_LVT2
34867534613SMatthew Dillon  * 0530 EXT_LVT3
349c8fe38aeSMatthew Dillon  */
350c8fe38aeSMatthew Dillon 
351c8fe38aeSMatthew Dillon #ifndef LOCORE
352c8fe38aeSMatthew Dillon #include <sys/types.h>
353c8fe38aeSMatthew Dillon 
354c8fe38aeSMatthew Dillon #define PAD3	int : 32; int : 32; int : 32
355c8fe38aeSMatthew Dillon #define PAD4	int : 32; int : 32; int : 32; int : 32
356c8fe38aeSMatthew Dillon 
357c8fe38aeSMatthew Dillon struct LAPIC {
358c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
359c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
360c8fe38aeSMatthew Dillon 	u_int32_t id;		PAD3;	/* 0020	R/W */
361c8fe38aeSMatthew Dillon 	u_int32_t version;	PAD3;	/* 0030	RO */
362c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
363c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
364c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
365c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
366c8fe38aeSMatthew Dillon 	u_int32_t tpr;		PAD3;
367c8fe38aeSMatthew Dillon 	u_int32_t apr;		PAD3;
368c8fe38aeSMatthew Dillon 	u_int32_t ppr;		PAD3;
369c8fe38aeSMatthew Dillon 	u_int32_t eoi;		PAD3;
370c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
371c8fe38aeSMatthew Dillon 	u_int32_t ldr;		PAD3;
372c8fe38aeSMatthew Dillon 	u_int32_t dfr;		PAD3;
373c8fe38aeSMatthew Dillon 	u_int32_t svr;		PAD3;
374c8fe38aeSMatthew Dillon 	u_int32_t isr0;		PAD3;
375c8fe38aeSMatthew Dillon 	u_int32_t isr1;		PAD3;
376c8fe38aeSMatthew Dillon 	u_int32_t isr2;		PAD3;
377c8fe38aeSMatthew Dillon 	u_int32_t isr3;		PAD3;
378c8fe38aeSMatthew Dillon 	u_int32_t isr4;		PAD3;
379c8fe38aeSMatthew Dillon 	u_int32_t isr5;		PAD3;
380c8fe38aeSMatthew Dillon 	u_int32_t isr6;		PAD3;
381c8fe38aeSMatthew Dillon 	u_int32_t isr7;		PAD3;
382c8fe38aeSMatthew Dillon 	u_int32_t tmr0;		PAD3;
383c8fe38aeSMatthew Dillon 	u_int32_t tmr1;		PAD3;
384c8fe38aeSMatthew Dillon 	u_int32_t tmr2;		PAD3;
385c8fe38aeSMatthew Dillon 	u_int32_t tmr3;		PAD3;
386c8fe38aeSMatthew Dillon 	u_int32_t tmr4;		PAD3;
387c8fe38aeSMatthew Dillon 	u_int32_t tmr5;		PAD3;
388c8fe38aeSMatthew Dillon 	u_int32_t tmr6;		PAD3;
389c8fe38aeSMatthew Dillon 	u_int32_t tmr7;		PAD3;
390c8fe38aeSMatthew Dillon 	u_int32_t irr0;		PAD3;
391c8fe38aeSMatthew Dillon 	u_int32_t irr1;		PAD3;
392c8fe38aeSMatthew Dillon 	u_int32_t irr2;		PAD3;
393c8fe38aeSMatthew Dillon 	u_int32_t irr3;		PAD3;
394c8fe38aeSMatthew Dillon 	u_int32_t irr4;		PAD3;
395c8fe38aeSMatthew Dillon 	u_int32_t irr5;		PAD3;
396c8fe38aeSMatthew Dillon 	u_int32_t irr6;		PAD3;
397c8fe38aeSMatthew Dillon 	u_int32_t irr7;		PAD3;
398c8fe38aeSMatthew Dillon 	u_int32_t esr;		PAD3;
399c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
400c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
401c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
402c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
403c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
404c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
405c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
406c8fe38aeSMatthew Dillon 	u_int32_t icr_lo;	PAD3;
407c8fe38aeSMatthew Dillon 	u_int32_t icr_hi;	PAD3;
408c8fe38aeSMatthew Dillon 	u_int32_t lvt_timer;	PAD3;
409c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
410c8fe38aeSMatthew Dillon 	u_int32_t lvt_pcint;	PAD3;
411c8fe38aeSMatthew Dillon 	u_int32_t lvt_lint0;	PAD3;
412c8fe38aeSMatthew Dillon 	u_int32_t lvt_lint1;	PAD3;
413c8fe38aeSMatthew Dillon 	u_int32_t lvt_error;	PAD3;
414c8fe38aeSMatthew Dillon 	u_int32_t icr_timer;	PAD3;
41567534613SMatthew Dillon 	u_int32_t ccr_timer;	PAD3;	/* e9 */
416c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
417c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
418c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
419c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
42067534613SMatthew Dillon 	u_int32_t dcr_timer;	PAD3;	/* 3e */
42167534613SMatthew Dillon 	u_int32_t self_ipi;	PAD3;	/* 3f - Only in x2APIC */
42267534613SMatthew Dillon 	u_int32_t ext_feat;	PAD3;
42367534613SMatthew Dillon 	u_int32_t ext_ctrl;	PAD3;
42467534613SMatthew Dillon 	u_int32_t ext_seoi;	PAD3;
425c8fe38aeSMatthew Dillon 	/* reserved */		PAD4;
42667534613SMatthew Dillon 	/* reserved */		PAD4;
42767534613SMatthew Dillon 	/* reserved */		PAD4;
42867534613SMatthew Dillon 	/* reserved */		PAD4;
42967534613SMatthew Dillon 	/* reserved */		PAD4;
43067534613SMatthew Dillon 	u_int32_t ext_ier0;	PAD3;
43167534613SMatthew Dillon 	u_int32_t ext_ier1;	PAD3;
43267534613SMatthew Dillon 	u_int32_t ext_ier2;	PAD3;
43367534613SMatthew Dillon 	u_int32_t ext_ier3;	PAD3;
43467534613SMatthew Dillon 	u_int32_t ext_ier4;	PAD3;
43567534613SMatthew Dillon 	u_int32_t ext_ier5;	PAD3;
43667534613SMatthew Dillon 	u_int32_t ext_ier6;	PAD3;
43767534613SMatthew Dillon 	u_int32_t ext_ier7;	PAD3;
43867534613SMatthew Dillon 	struct {			/* 50 */
43967534613SMatthew Dillon 		u_int32_t lvt;	PAD3;
44067534613SMatthew Dillon 	} ext_lvt[16];
44167534613SMatthew Dillon } __packed;
442c8fe38aeSMatthew Dillon 
443c8fe38aeSMatthew Dillon typedef struct LAPIC lapic_t;
444c8fe38aeSMatthew Dillon 
445c8fe38aeSMatthew Dillon /******************************************************************************
446c8fe38aeSMatthew Dillon  * I/O APIC structure
447c8fe38aeSMatthew Dillon  */
448c8fe38aeSMatthew Dillon 
449c8fe38aeSMatthew Dillon struct IOAPIC {
450c8fe38aeSMatthew Dillon 	u_int32_t ioregsel;	PAD3;
451c8fe38aeSMatthew Dillon 	u_int32_t iowin;	PAD3;
452c8fe38aeSMatthew Dillon };
453c8fe38aeSMatthew Dillon 
454c8fe38aeSMatthew Dillon typedef struct IOAPIC ioapic_t;
455c8fe38aeSMatthew Dillon 
456c8fe38aeSMatthew Dillon #undef PAD4
457c8fe38aeSMatthew Dillon #undef PAD3
458c8fe38aeSMatthew Dillon 
459*f89b4a45SSepherosa Ziehau /* X2APIC */
460*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_BASE		0x00000800
461*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_ID		0x00000802
462*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_EOI		0x0000080b
463*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_DFR_RSVD	0x0000080e
464*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_ICR		0x00000830
465*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_ICR_RSVD	0x00000831
466*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_ICR_TIMER	0x00000838
467*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_CCR_TIMER	0x00000839
468*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_SELFIPI	0x0000083f
469*f89b4a45SSepherosa Ziehau 
470*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_MIN		MSR_X2APIC_ID
471*f89b4a45SSepherosa Ziehau #define MSR_X2APIC_MAX		MSR_X2APIC_SELFIPI
472*f89b4a45SSepherosa Ziehau 
473*f89b4a45SSepherosa Ziehau #define LAPIC2MSR(field) __extension__ ({		\
474*f89b4a45SSepherosa Ziehau 	uint32_t __msr;					\
475*f89b4a45SSepherosa Ziehau 							\
476*f89b4a45SSepherosa Ziehau 	__msr = MSR_X2APIC_BASE +			\
477*f89b4a45SSepherosa Ziehau 		(__offsetof(struct LAPIC, field) >> 4);	\
478*f89b4a45SSepherosa Ziehau 	KASSERT(__msr >= MSR_X2APIC_MIN &&		\
479*f89b4a45SSepherosa Ziehau 		__msr <= MSR_X2APIC_MAX &&		\
480*f89b4a45SSepherosa Ziehau 	        __msr != MSR_X2APIC_DFR_RSVD &&		\
481*f89b4a45SSepherosa Ziehau 		__msr != MSR_X2APIC_ICR &&		\
482*f89b4a45SSepherosa Ziehau 		__msr != MSR_X2APIC_ICR_RSVD,		\
483*f89b4a45SSepherosa Ziehau 		("invalid MSR 0x%08x", __msr));		\
484*f89b4a45SSepherosa Ziehau 	__msr;						\
485*f89b4a45SSepherosa Ziehau })
486*f89b4a45SSepherosa Ziehau 
487c8fe38aeSMatthew Dillon #endif  /* !LOCORE */
488c8fe38aeSMatthew Dillon 
489c8fe38aeSMatthew Dillon 
490c8fe38aeSMatthew Dillon /******************************************************************************
491c8fe38aeSMatthew Dillon  * various code 'logical' values
492c8fe38aeSMatthew Dillon  */
493c8fe38aeSMatthew Dillon 
494c8fe38aeSMatthew Dillon /*
495c8fe38aeSMatthew Dillon  * TPR loads to prioritize which cpu grabs an interrupt
496c8fe38aeSMatthew Dillon  *
497c8fe38aeSMatthew Dillon  * (note: some fields of the TPR are reserved)
498c8fe38aeSMatthew Dillon  */
499c8fe38aeSMatthew Dillon #define LOPRIO_LEVEL		0x00000010	/* TPR of CPU accepting INTs */
500c8fe38aeSMatthew Dillon #define ALLHWI_LEVEL		0x00000000	/* TPR of CPU grabbing INTs */
501c8fe38aeSMatthew Dillon 
502c8fe38aeSMatthew Dillon /******************************************************************************
503c8fe38aeSMatthew Dillon  * LOCAL APIC defines
504c8fe38aeSMatthew Dillon  */
505c8fe38aeSMatthew Dillon 
506c8fe38aeSMatthew Dillon /*
507c8fe38aeSMatthew Dillon  * default physical location for the LOCAL (CPU) APIC
508c8fe38aeSMatthew Dillon  */
509c8fe38aeSMatthew Dillon #define DEFAULT_APIC_BASE	0xfee00000
510c8fe38aeSMatthew Dillon 
511c8fe38aeSMatthew Dillon /*
512c8fe38aeSMatthew Dillon  * lapic.id (rw)
513c8fe38aeSMatthew Dillon  */
514c8fe38aeSMatthew Dillon #define APIC_ID_MASK		0xff000000
515c8fe38aeSMatthew Dillon #define APIC_ID_SHIFT		24
516c8fe38aeSMatthew Dillon #define APIC_ID_CLUSTER		0xf0
517c8fe38aeSMatthew Dillon #define APIC_ID_CLUSTER_ID	0x0f
518c8fe38aeSMatthew Dillon #define APIC_MAX_CLUSTER	0xe
519c8fe38aeSMatthew Dillon #define APIC_MAX_INTRACLUSTER_ID 3
520c8fe38aeSMatthew Dillon #define APIC_ID_CLUSTER_SHIFT   4
521c8fe38aeSMatthew Dillon 
522b38251dcSMichael Neumann #define APIC_ID(id)		(((id) & APIC_ID_MASK) >> APIC_ID_SHIFT)
523b38251dcSMichael Neumann 
524c8fe38aeSMatthew Dillon /*
525c8fe38aeSMatthew Dillon  * lapic.ver (ro)
526c8fe38aeSMatthew Dillon  */
527c8fe38aeSMatthew Dillon #define APIC_VER_VERSION	0x000000ff
528c8fe38aeSMatthew Dillon #define APIC_VER_MAXLVT		0x00ff0000
529c8fe38aeSMatthew Dillon #define MAXLVTSHIFT		16
53067534613SMatthew Dillon #define APIC_VER_EOI_SUPP	0x01000000
53167534613SMatthew Dillon #define APIC_VER_AMD_EXT_SPACE	0x80000000
532c8fe38aeSMatthew Dillon 
533c8fe38aeSMatthew Dillon /*
534c8fe38aeSMatthew Dillon  * lapic.ldr (rw)
535c8fe38aeSMatthew Dillon  */
536c8fe38aeSMatthew Dillon #define APIC_LDR_RESERVED       0x00ffffff
537c8fe38aeSMatthew Dillon 
538c8fe38aeSMatthew Dillon /*
539c8fe38aeSMatthew Dillon  * lapic.dfr (rw)
540c8fe38aeSMatthew Dillon  *
541c8fe38aeSMatthew Dillon  * The logical APIC ID is used with logical interrupt
542c8fe38aeSMatthew Dillon  * delivery modes.  Interpretation of logical destination
543c8fe38aeSMatthew Dillon  * information depends on the MODEL bits in the Destination
544c8fe38aeSMatthew Dillon  * Format Regiuster.
545c8fe38aeSMatthew Dillon  *
546c8fe38aeSMatthew Dillon  * MODEL=1111 FLAT MODEL - The MDA is interpreted as
547c8fe38aeSMatthew Dillon  * 			   a decoded address.  By setting
548c8fe38aeSMatthew Dillon  * 			   one bit in the LDR for each
549c8fe38aeSMatthew Dillon  *			   local apic 8 APICs can coexist.
550c8fe38aeSMatthew Dillon  *
551c8fe38aeSMatthew Dillon  * MODEL=0000 CLUSTER MODEL -
552c8fe38aeSMatthew Dillon  */
553c8fe38aeSMatthew Dillon #define APIC_DFR_RESERVED	0x0fffffff
554c8fe38aeSMatthew Dillon #define APIC_DFR_MODEL_MASK	0xf0000000
555c8fe38aeSMatthew Dillon #define APIC_DFR_MODEL_FLAT	0xf0000000
556c8fe38aeSMatthew Dillon #define APIC_DFR_MODEL_CLUSTER	0x00000000
557c8fe38aeSMatthew Dillon 
558c8fe38aeSMatthew Dillon /*
559c8fe38aeSMatthew Dillon  * lapic.svr
560c8fe38aeSMatthew Dillon  *
561c8fe38aeSMatthew Dillon  * Contains the spurious interrupt vector and bits to enable/disable
562c8fe38aeSMatthew Dillon  * the local apic and focus processor.
563c8fe38aeSMatthew Dillon  */
564c8fe38aeSMatthew Dillon #define APIC_SVR_VECTOR		0x000000ff
565c8fe38aeSMatthew Dillon #define APIC_SVR_ENABLE		0x00000100
566c8fe38aeSMatthew Dillon #define APIC_SVR_FOCUS_DISABLE	0x00000200
56767534613SMatthew Dillon #define APIC_SVR_EOI_SUPP	0x00001000
568c8fe38aeSMatthew Dillon 
569c8fe38aeSMatthew Dillon /*
570c8fe38aeSMatthew Dillon  * lapic.tpr
571c8fe38aeSMatthew Dillon  *
572c8fe38aeSMatthew Dillon  *    PRIO (7:4).  Main priority.  If 15 the APIC will not
573c8fe38aeSMatthew Dillon  *    		 accept any interrupts.
574c8fe38aeSMatthew Dillon  *    SUBC (3:0)	 Sub priority.  See APR/PPR.
575c8fe38aeSMatthew Dillon  */
576c8fe38aeSMatthew Dillon #define APIC_TPR_PRIO		0x000000ff
577c8fe38aeSMatthew Dillon #define APIC_TPR_INT		0x000000f0
578c8fe38aeSMatthew Dillon #define APIC_TPR_SUB		0x0000000f
579c8fe38aeSMatthew Dillon 
580c8fe38aeSMatthew Dillon /*
581c8fe38aeSMatthew Dillon  * lapic.icr_lo	  -------- ----XXRR TL-SDMMM vvvvvvvv
582c8fe38aeSMatthew Dillon  *
583c8fe38aeSMatthew Dillon  *	The interrupt command register.  Generally speaking
584c8fe38aeSMatthew Dillon  * 	writing to ICR_LO initiates a command.  All fields
585c8fe38aeSMatthew Dillon  * 	are R/W except the 'S' (delivery status) field, which
586c8fe38aeSMatthew Dillon  * 	is read-only.  When
587c8fe38aeSMatthew Dillon  *
588c8fe38aeSMatthew Dillon  *      XX:     Destination Shorthand field:
589c8fe38aeSMatthew Dillon  *
590c8fe38aeSMatthew Dillon  *		00 -	Use Destination field
591c8fe38aeSMatthew Dillon  *		01 -	Self only.  Dest field ignored.
592c8fe38aeSMatthew Dillon  *		10 -	All including self (uses a
593c8fe38aeSMatthew Dillon  *			destination field of 0x0F)
594c8fe38aeSMatthew Dillon  *		11 -	All excluding self (uses a
595c8fe38aeSMatthew Dillon  *			destination field of 0x0F)
596c8fe38aeSMatthew Dillon  *
597c8fe38aeSMatthew Dillon  *	RR:	RR mode (? needs documentation)
598c8fe38aeSMatthew Dillon  *
599c8fe38aeSMatthew Dillon  *      T:      1 = Level 0 = Edge Trigger modde, used for
600c8fe38aeSMatthew Dillon  *      	the INIT level de-assert delivery mode only
601c8fe38aeSMatthew Dillon  *      	to de-assert a request.
602c8fe38aeSMatthew Dillon  *
603c8fe38aeSMatthew Dillon  *	L:      0 = De-Assert, 1 = Assert.  Always write as
604c8fe38aeSMatthew Dillon  *      	1 when initiating a new command.  Can only
605c8fe38aeSMatthew Dillon  *		write as 0 for INIT mode de-assertion of
606c8fe38aeSMatthew Dillon  *		command.
607c8fe38aeSMatthew Dillon  *
608c8fe38aeSMatthew Dillon  *	S:	1 = Send Pending.  Interrupt has been injected but the APIC
609c8fe38aeSMatthew Dillon  *		has not yet accepted it.
610c8fe38aeSMatthew Dillon  *
611c8fe38aeSMatthew Dillon  *	D:	0 = physical 1 = logical.  In physical mode only bits 24-27
612c8fe38aeSMatthew Dillon  *		of the DEST field is used from ICR_HI.
613c8fe38aeSMatthew Dillon  *
614c8fe38aeSMatthew Dillon  *	MMM:	Delivery mode
615c8fe38aeSMatthew Dillon  *
616c8fe38aeSMatthew Dillon  *		000 - Fixed.  Deliver to all processors according to the
617c8fe38aeSMatthew Dillon  *		      ICR.  Always treated as edge triggered.
618c8fe38aeSMatthew Dillon  *
619c8fe38aeSMatthew Dillon  *		001 - Lowest Priority.  Deliver to just the processor
620c8fe38aeSMatthew Dillon  *		      running at the lowest priority.
621c8fe38aeSMatthew Dillon  *
622c8fe38aeSMatthew Dillon  *		010 - SMI.  The vector must be 00B.  Only edge triggered
623c8fe38aeSMatthew Dillon  *		      is allowed.  The vector field must be programmed to
624c8fe38aeSMatthew Dillon  *		      0 (huh?)
625c8fe38aeSMatthew Dillon  *
626c8fe38aeSMatthew Dillon  *		011 - RR Delivery mode (?? needs documentation).
627c8fe38aeSMatthew Dillon  *
628c8fe38aeSMatthew Dillon  *		100 - NMI.  Deliver as an NMI to all processors listed in
629c8fe38aeSMatthew Dillon  *		      the destination field.  The vector is ignored.  Always
630c8fe38aeSMatthew Dillon  *		      treated as edge triggered.
631c8fe38aeSMatthew Dillon  *
632c8fe38aeSMatthew Dillon  *		101 - INIT.  Deliver as an INIT signal to all processors
633c8fe38aeSMatthew Dillon  *		      (like FIXED) according to the ICR.  The vector is
634c8fe38aeSMatthew Dillon  *		      ignored and delivery is always edge-triggered.
635c8fe38aeSMatthew Dillon  *
636c8fe38aeSMatthew Dillon  *		110 - Startup.  Send a special message between cpus.  The
637c8fe38aeSMatthew Dillon  *		      vector contains a startup address for the MP boot
638c8fe38aeSMatthew Dillon  *		      protocol.  Always edge triggered.  Note: a startup
639c8fe38aeSMatthew Dillon  *		      interrupt is not automatically tried in case of failure.
640c8fe38aeSMatthew Dillon  *
641c8fe38aeSMatthew Dillon  *		111 - <reserved>
642c8fe38aeSMatthew Dillon  */
643c8fe38aeSMatthew Dillon #define APIC_VECTOR_MASK	0x000000ff
644c8fe38aeSMatthew Dillon 
645c8fe38aeSMatthew Dillon #define APIC_DELMODE_MASK	0x00000700
646c8fe38aeSMatthew Dillon #define APIC_DELMODE_FIXED	0x00000000
647c8fe38aeSMatthew Dillon #define APIC_DELMODE_LOWPRIO	0x00000100
648c8fe38aeSMatthew Dillon #define APIC_DELMODE_SMI	0x00000200
649c8fe38aeSMatthew Dillon #define APIC_DELMODE_RR		0x00000300
650c8fe38aeSMatthew Dillon #define APIC_DELMODE_NMI	0x00000400
651c8fe38aeSMatthew Dillon #define APIC_DELMODE_INIT	0x00000500
652c8fe38aeSMatthew Dillon #define APIC_DELMODE_STARTUP	0x00000600
653c8fe38aeSMatthew Dillon #define APIC_DELMODE_RESV7	0x00000700
654c8fe38aeSMatthew Dillon 
655c8fe38aeSMatthew Dillon #define APIC_DESTMODE_MASK	0x00000800
656c8fe38aeSMatthew Dillon #define APIC_DESTMODE_PHY	0x00000000
657c8fe38aeSMatthew Dillon #define APIC_DESTMODE_LOG	0x00000800
658c8fe38aeSMatthew Dillon 
659c8fe38aeSMatthew Dillon #define APIC_DELSTAT_MASK	0x00001000
660c8fe38aeSMatthew Dillon #define APIC_DELSTAT_IDLE	0x00000000
661c8fe38aeSMatthew Dillon #define APIC_DELSTAT_PEND	0x00001000
662c8fe38aeSMatthew Dillon 
663c8fe38aeSMatthew Dillon #define APIC_LEVEL_MASK		0x00004000
664c8fe38aeSMatthew Dillon #define APIC_LEVEL_DEASSERT	0x00000000
665c8fe38aeSMatthew Dillon #define APIC_LEVEL_ASSERT	0x00004000
666c8fe38aeSMatthew Dillon 
667c8fe38aeSMatthew Dillon #define APIC_TRIGMOD_MASK	0x00008000
668c8fe38aeSMatthew Dillon #define APIC_TRIGMOD_EDGE	0x00000000
669c8fe38aeSMatthew Dillon #define APIC_TRIGMOD_LEVEL	0x00008000
670c8fe38aeSMatthew Dillon 
671c8fe38aeSMatthew Dillon #define APIC_RRSTAT_MASK	0x00030000
672c8fe38aeSMatthew Dillon #define APIC_RRSTAT_INVALID	0x00000000
673c8fe38aeSMatthew Dillon #define APIC_RRSTAT_INPROG	0x00010000
674c8fe38aeSMatthew Dillon #define APIC_RRSTAT_VALID	0x00020000
675c8fe38aeSMatthew Dillon #define APIC_RRSTAT_RESV	0x00030000
676c8fe38aeSMatthew Dillon 
677c8fe38aeSMatthew Dillon #define APIC_DEST_MASK		0x000c0000
678c8fe38aeSMatthew Dillon #define APIC_DEST_DESTFLD	0x00000000
679c8fe38aeSMatthew Dillon #define APIC_DEST_SELF		0x00040000
680c8fe38aeSMatthew Dillon #define APIC_DEST_ALLISELF	0x00080000
681c8fe38aeSMatthew Dillon #define APIC_DEST_ALLESELF	0x000c0000
682c8fe38aeSMatthew Dillon 
683c8fe38aeSMatthew Dillon #define APIC_ICRLO_RESV_MASK	0xfff02000
684c8fe38aeSMatthew Dillon 
685c8fe38aeSMatthew Dillon /*
686c8fe38aeSMatthew Dillon  * lapic.icr_hi
687c8fe38aeSMatthew Dillon  */
688c8fe38aeSMatthew Dillon #define APIC_ICRH_ID_MASK	APIC_ID_MASK
689c8fe38aeSMatthew Dillon 
690c8fe38aeSMatthew Dillon /*
691c8fe38aeSMatthew Dillon  * lapic.lvt_timer
692c8fe38aeSMatthew Dillon  * lapic.lvt_pcint
693c8fe38aeSMatthew Dillon  * lapic.lvt_lint0
694c8fe38aeSMatthew Dillon  * lapic.lvt_lint1
695c8fe38aeSMatthew Dillon  * lapic.lvt_error
696c8fe38aeSMatthew Dillon  *
697c8fe38aeSMatthew Dillon  *		+-----------+--------10-+--FEDCBA98-+-----------+
698c8fe38aeSMatthew Dillon  * 0320	LTIMER  |           |        TM |  ---S---- | vector    |
699c8fe38aeSMatthew Dillon  * 0330		|           |           |           |           |
700c8fe38aeSMatthew Dillon  *		+-----------+--------10-+--FEDCBA98-+-----------+
701c8fe38aeSMatthew Dillon  * 0340	LVPCINT	|           |        -M |  ---S-MMM | vector    |
702c8fe38aeSMatthew Dillon  * 0350	LVINT0	|           |        -M |  LRPS-MMM | vector    |
703c8fe38aeSMatthew Dillon  * 0360 LVINT1	|           |        -M |  LRPS-MMM | vector    |
704c8fe38aeSMatthew Dillon  * 0370	LVERROR	|           |        -M |  -------- | vector    |
705c8fe38aeSMatthew Dillon  *		+-----------+-----------+-----------+-----------+
706c8fe38aeSMatthew Dillon  *
707c8fe38aeSMatthew Dillon  *			T:	1 = periodic, 0 = one-shot
708c8fe38aeSMatthew Dillon  *				(LTIMER only)
709c8fe38aeSMatthew Dillon  *
710c8fe38aeSMatthew Dillon  *			M:	1 = masked
711c8fe38aeSMatthew Dillon  *
712c8fe38aeSMatthew Dillon  *			L:	1 = level, 0 = edge
713c8fe38aeSMatthew Dillon  *				(LVINT0/1 only)
714c8fe38aeSMatthew Dillon  *
715c8fe38aeSMatthew Dillon  *			R:	For level triggered only, set to 1 when a
716c8fe38aeSMatthew Dillon  *				level int is accepted, cleared by EOI.
717c8fe38aeSMatthew Dillon  *				(LVINT0/1 only)
718c8fe38aeSMatthew Dillon  *
719c8fe38aeSMatthew Dillon  *			P:	Pin Polarity 0 = Active High, 1 = Active Low
720c8fe38aeSMatthew Dillon  *				(LVINT0/1 only)
721c8fe38aeSMatthew Dillon  *
722c8fe38aeSMatthew Dillon  *			S:	1 = Send Pending.  Interrupt has been injected
723c8fe38aeSMatthew Dillon  *				but APIC has not yet accepted it.
724c8fe38aeSMatthew Dillon  *
725c8fe38aeSMatthew Dillon  *			MMM 	000 = Fixed	deliver to cpu according to LVT
726c8fe38aeSMatthew Dillon  *
727c8fe38aeSMatthew Dillon  *			MMM 	100 = NMI	deliver as an NMI.  Always edge
728c8fe38aeSMatthew Dillon  *
729c8fe38aeSMatthew Dillon  *			MMM 	111 = ExtInt	deliver from 8259, routes INTA
730c8fe38aeSMatthew Dillon  *						bus cycle to external
731c8fe38aeSMatthew Dillon  *						controller.  Controller is
732c8fe38aeSMatthew Dillon  *						expected to supply vector.
733c8fe38aeSMatthew Dillon  *						Always level.
734c8fe38aeSMatthew Dillon  */
735c8fe38aeSMatthew Dillon #define APIC_LVT_VECTOR		0x000000ff
736c8fe38aeSMatthew Dillon 
737c8fe38aeSMatthew Dillon #define APIC_LVT_DM_MASK	0x00000700
738c8fe38aeSMatthew Dillon #define APIC_LVT_DM_FIXED	0x00000000
739c8fe38aeSMatthew Dillon #define APIC_LVT_DM_NMI		0x00000400
740c8fe38aeSMatthew Dillon #define APIC_LVT_DM_EXTINT	0x00000700
741c8fe38aeSMatthew Dillon 
742c8fe38aeSMatthew Dillon #define APIC_LVT_DS		0x00001000	/* (S) Send Pending */
743c8fe38aeSMatthew Dillon #define APIC_LVT_POLARITY_MASK	0x00002000
744c8fe38aeSMatthew Dillon #define APIC_LVT_POLARITY_LO	0x00002000	/* (P) Pin Polarity */
745c8fe38aeSMatthew Dillon #define APIC_LVT_POLARITY_HI	0x00000000
746c8fe38aeSMatthew Dillon #define APIC_LVT_LEVELSTATUS	0x00004000	/* (R) level trig status */
747c8fe38aeSMatthew Dillon #define APIC_LVT_TRIG_MASK	0x00008000
748c8fe38aeSMatthew Dillon #define APIC_LVT_LEVELTRIG	0x00008000	/* (L) 1 = level, 0 = edge */
749c8fe38aeSMatthew Dillon #define APIC_LVT_MASKED		0x00010000	/* (M) 1 = masked */
750c8fe38aeSMatthew Dillon 
751c8fe38aeSMatthew Dillon /*
752c8fe38aeSMatthew Dillon  * lapic.lvt_timer
753c8fe38aeSMatthew Dillon  */
754c8fe38aeSMatthew Dillon #define APIC_LVTT_VECTOR	APIC_LVT_VECTOR
755c8fe38aeSMatthew Dillon #define APIC_LVTT_DS		APIC_LVT_DS
756c8fe38aeSMatthew Dillon #define APIC_LVTT_MASKED	APIC_LVT_MASKED
757c8fe38aeSMatthew Dillon #define APIC_LVTT_PERIODIC	0x00020000
758185b27faSImre Vadász #define APIC_LVTT_TSCDLT	0x00040000
759c8fe38aeSMatthew Dillon 
760c8fe38aeSMatthew Dillon #define APIC_TIMER_MAX_COUNT    0xffffffff
761c8fe38aeSMatthew Dillon 
762c8fe38aeSMatthew Dillon /*
763c8fe38aeSMatthew Dillon  * lapic.icr_timer - initial count register (32 bits)
764c8fe38aeSMatthew Dillon  * lapic.ccr_timer - current count register (32 bits)
765c8fe38aeSMatthew Dillon  */
766c8fe38aeSMatthew Dillon 
767c8fe38aeSMatthew Dillon /*
768c8fe38aeSMatthew Dillon  * lapic.dcr_timer - timer divider register
769c8fe38aeSMatthew Dillon  *
770c8fe38aeSMatthew Dillon  * d0dd
771c8fe38aeSMatthew Dillon  *
772c8fe38aeSMatthew Dillon  *	0000 - divide by 2
773c8fe38aeSMatthew Dillon  *	0001 - divide by 4
774c8fe38aeSMatthew Dillon  *	0010 - divide by 8
775c8fe38aeSMatthew Dillon  *	0011 - divide by 16
776c8fe38aeSMatthew Dillon  *	1000 - divide by 32
777c8fe38aeSMatthew Dillon  *	1001 - divide by 64
778c8fe38aeSMatthew Dillon  *	1010 - divide by 128
779c8fe38aeSMatthew Dillon  *	1011 - divide by 1
780c8fe38aeSMatthew Dillon  */
781c8fe38aeSMatthew Dillon #define APIC_TDCR_2		0x00
782c8fe38aeSMatthew Dillon #define APIC_TDCR_4		0x01
783c8fe38aeSMatthew Dillon #define APIC_TDCR_8		0x02
784c8fe38aeSMatthew Dillon #define APIC_TDCR_16		0x03
785c8fe38aeSMatthew Dillon #define APIC_TDCR_32		0x08
786c8fe38aeSMatthew Dillon #define APIC_TDCR_64		0x09
787c8fe38aeSMatthew Dillon #define APIC_TDCR_128		0x0a
788c8fe38aeSMatthew Dillon #define APIC_TDCR_1		0x0b
789c8fe38aeSMatthew Dillon 
79067534613SMatthew Dillon /*
79167534613SMatthew Dillon  * lapic.self_ipi (x2APIC only)
79267534613SMatthew Dillon  */
79367534613SMatthew Dillon /*
79467534613SMatthew Dillon  * lapic.ext_feat (AMD only)
79567534613SMatthew Dillon  */
79667534613SMatthew Dillon #define APIC_EXTFEAT_MASK	0x00ff0000
79767534613SMatthew Dillon #define APIC_EXTFEAT_SHIFT    	16
79867534613SMatthew Dillon #define APIC_EXTFEAT_EXTID_CAP	0x00000004
79967534613SMatthew Dillon #define APIC_EXTFEAT_SEIO_CAP	0x00000002
80067534613SMatthew Dillon #define APIC_EXTFEAT_IER_CAP	0x00000001
80167534613SMatthew Dillon 
80267534613SMatthew Dillon /*
80367534613SMatthew Dillon  * lapic.ext_ctrl
80467534613SMatthew Dillon  * lapic.ext_seoi
80567534613SMatthew Dillon  * lapic.ext_ier{0-7}
80667534613SMatthew Dillon  */
80767534613SMatthew Dillon /*
80867534613SMatthew Dillon  * lapic.ext_lvt[N].lvt
80967534613SMatthew Dillon  */
81067534613SMatthew Dillon #define APIC_EXTLVT_IBS		0	/* Instruction based sampling */
81167534613SMatthew Dillon #define APIC_EXTLVT_MCA		1	/* MCE thresholding */
81267534613SMatthew Dillon #define APIC_EXTLVT_DEI		2	/* Deferred error interrupt */
81367534613SMatthew Dillon #define APIC_EXTLVT_SBI		3	/* Sideband interface */
81467534613SMatthew Dillon 
815c8fe38aeSMatthew Dillon /******************************************************************************
816c8fe38aeSMatthew Dillon  * I/O APIC defines
817c8fe38aeSMatthew Dillon  */
818c8fe38aeSMatthew Dillon 
819c8fe38aeSMatthew Dillon /* default physical locations of an IO APIC */
820c8fe38aeSMatthew Dillon #define DEFAULT_IO_APIC_BASE	0xfec00000
821c8fe38aeSMatthew Dillon 
822c8fe38aeSMatthew Dillon /* window register offset */
823c8fe38aeSMatthew Dillon #define IOAPIC_WINDOW		0x10
824c8fe38aeSMatthew Dillon 
825c8fe38aeSMatthew Dillon /*
826c8fe38aeSMatthew Dillon  * indexes into IO APIC (index into array of 32 bit entities)
827c8fe38aeSMatthew Dillon  */
828c8fe38aeSMatthew Dillon #define IOAPIC_ID		0x00
829c8fe38aeSMatthew Dillon #define IOAPIC_VER		0x01
830c8fe38aeSMatthew Dillon #define IOAPIC_ARB		0x02
831c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL		0x10
832c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL0		IOAPIC_REDTBL
833c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL1		(IOAPIC_REDTBL+0x02)
834c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL2		(IOAPIC_REDTBL+0x04)
835c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL3		(IOAPIC_REDTBL+0x06)
836c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL4		(IOAPIC_REDTBL+0x08)
837c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL5		(IOAPIC_REDTBL+0x0a)
838c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL6		(IOAPIC_REDTBL+0x0c)
839c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL7		(IOAPIC_REDTBL+0x0e)
840c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL8		(IOAPIC_REDTBL+0x10)
841c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL9		(IOAPIC_REDTBL+0x12)
842c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL10		(IOAPIC_REDTBL+0x14)
843c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL11		(IOAPIC_REDTBL+0x16)
844c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL12		(IOAPIC_REDTBL+0x18)
845c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL13		(IOAPIC_REDTBL+0x1a)
846c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL14		(IOAPIC_REDTBL+0x1c)
847c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL15		(IOAPIC_REDTBL+0x1e)
848c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL16		(IOAPIC_REDTBL+0x20)
849c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL17		(IOAPIC_REDTBL+0x22)
850c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL18		(IOAPIC_REDTBL+0x24)
851c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL19		(IOAPIC_REDTBL+0x26)
852c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL20		(IOAPIC_REDTBL+0x28)
853c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL21		(IOAPIC_REDTBL+0x2a)
854c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL22		(IOAPIC_REDTBL+0x2c)
855c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL23		(IOAPIC_REDTBL+0x2e)
856c8fe38aeSMatthew Dillon 
857c8fe38aeSMatthew Dillon /* fields in VER */
858c8fe38aeSMatthew Dillon #define IOART_VER_VERSION	0x000000ff
859c8fe38aeSMatthew Dillon #define IOART_VER_MAXREDIR	0x00ff0000
860c8fe38aeSMatthew Dillon #define MAXREDIRSHIFT		16
861c8fe38aeSMatthew Dillon 
862c8fe38aeSMatthew Dillon /*
863c8fe38aeSMatthew Dillon  * fields in the IO APIC's redirection table entries
864c8fe38aeSMatthew Dillon  */
865c8fe38aeSMatthew Dillon 
866c8fe38aeSMatthew Dillon /*
867c8fe38aeSMatthew Dillon  * High 32 bit word.  The high 8 bits contain the destination field.
868c8fe38aeSMatthew Dillon  *
869c8fe38aeSMatthew Dillon  * If this entry is set up for Physical Mode, bits 59:56 (the low 4 bits
870c8fe38aeSMatthew Dillon  * of the 8 bit destination field) contain an APIC ID.
871c8fe38aeSMatthew Dillon  *
872c8fe38aeSMatthew Dillon  * If this entry is set up for Logical Mode, the destination field potentially
873c8fe38aeSMatthew Dillon  * defines a set of processors.  Bits 63:56 (all 8 bits) specify the logical
874c8fe38aeSMatthew Dillon  * destination address.
875c8fe38aeSMatthew Dillon  *
876c8fe38aeSMatthew Dillon  * Current we use IOART_HI_DEST_BROADCAST to broadcast to all LAPICs
877c8fe38aeSMatthew Dillon  */
878c8fe38aeSMatthew Dillon #define IOART_HI_DEST_MASK	APIC_ID_MASK
879c8fe38aeSMatthew Dillon #define IOART_HI_DEST_RESV	~APIC_ID_MASK
880c8fe38aeSMatthew Dillon #define IOART_HI_DEST_BROADCAST	IOART_HI_DEST_MASK
88146d4e165SJordan Gordeev #define IOART_HI_DEST_SHIFT	24
882c8fe38aeSMatthew Dillon 
883c8fe38aeSMatthew Dillon /*
884c8fe38aeSMatthew Dillon  * Low 32 bit word
885c8fe38aeSMatthew Dillon  */
886c8fe38aeSMatthew Dillon #define IOART_RESV	0x00fe0000	/* reserved */
887c8fe38aeSMatthew Dillon 
888c8fe38aeSMatthew Dillon /*
889c8fe38aeSMatthew Dillon  * Interrupt mask bit.  If 1 the interrupt is masked.  An edge sensitive
890c8fe38aeSMatthew Dillon  * interrupt which is masked will be lost.
891c8fe38aeSMatthew Dillon  */
892c8fe38aeSMatthew Dillon #define IOART_INTMASK	0x00010000	/* R/W: INTerrupt mask */
893c8fe38aeSMatthew Dillon #define IOART_INTMCLR	0x00000000	/*       clear, allow INTs */
894c8fe38aeSMatthew Dillon #define IOART_INTMSET	0x00010000	/*       set, inhibit INTs */
895c8fe38aeSMatthew Dillon 
896c8fe38aeSMatthew Dillon /*
897c8fe38aeSMatthew Dillon  * Select trigger mode.
898c8fe38aeSMatthew Dillon  */
899c8fe38aeSMatthew Dillon #define IOART_TRGRMOD	0x00008000	/* R/W: trigger mode */
900c8fe38aeSMatthew Dillon #define IOART_TRGREDG	0x00000000	/*       edge */
901c8fe38aeSMatthew Dillon #define IOART_TRGRLVL	0x00008000	/*       level */
902c8fe38aeSMatthew Dillon 
903c8fe38aeSMatthew Dillon /*
904c8fe38aeSMatthew Dillon  * Remote IRR.  Only applies to level triggered interrupts, this bit
905c8fe38aeSMatthew Dillon  * is set to 1 when the IOAPIC has delivered a level triggered interrupt
906c8fe38aeSMatthew Dillon  * to a local APIC.  It is cleared when the LAPIC EOI's the interrupt.
907c8fe38aeSMatthew Dillon  * This field is read-only.
908c8fe38aeSMatthew Dillon  */
909c8fe38aeSMatthew Dillon #define IOART_REM_IRR	0x00004000	/* RO: remote IRR */
910c8fe38aeSMatthew Dillon 
911c8fe38aeSMatthew Dillon /*
912c8fe38aeSMatthew Dillon  * Select interrupt pin polarity
913c8fe38aeSMatthew Dillon  */
914c8fe38aeSMatthew Dillon #define IOART_INTPOL	0x00002000	/* R/W: INT input pin polarity */
915c8fe38aeSMatthew Dillon #define IOART_INTAHI	0x00000000	/*      active high */
916c8fe38aeSMatthew Dillon #define IOART_INTALO	0x00002000	/*      active low */
917c8fe38aeSMatthew Dillon 
918c8fe38aeSMatthew Dillon /*
919c8fe38aeSMatthew Dillon  * Delivery Status (read only).  0 = no interrupt pending, 1 = interrupt
920c8fe38aeSMatthew Dillon  * pending for tranmission to an LAPIC.  Note that this bit does not
921c8fe38aeSMatthew Dillon  * indicate whether the interrupt has been processed or is undergoing
922c8fe38aeSMatthew Dillon  * processing by a cpu.
923c8fe38aeSMatthew Dillon  */
924c8fe38aeSMatthew Dillon #define IOART_DELIVS	0x00001000	/* RO: delivery status */
925c8fe38aeSMatthew Dillon 
926c8fe38aeSMatthew Dillon /*
927c8fe38aeSMatthew Dillon  * Destination mode.
928c8fe38aeSMatthew Dillon  *
929c8fe38aeSMatthew Dillon  * In physical mode the destination APIC is identified by its ID.
930b9f7ba13SMatthew Dillon  * Bits 56-63 specify the 8 bit APIC ID.
931c8fe38aeSMatthew Dillon  *
932c8fe38aeSMatthew Dillon  * In logical mode destinations are identified by matching on the logical
933c8fe38aeSMatthew Dillon  * destination under the control of the destination format register and
934c8fe38aeSMatthew Dillon  * logical destination register in each local APIC.
935c8fe38aeSMatthew Dillon  *
936c8fe38aeSMatthew Dillon  */
937c8fe38aeSMatthew Dillon #define IOART_DESTMOD	0x00000800	/* R/W: destination mode */
938c8fe38aeSMatthew Dillon #define IOART_DESTPHY	0x00000000	/*      physical */
939c8fe38aeSMatthew Dillon #define IOART_DESTLOG	0x00000800	/*      logical */
940c8fe38aeSMatthew Dillon 
941c8fe38aeSMatthew Dillon /*
942c8fe38aeSMatthew Dillon  * Delivery mode.
943c8fe38aeSMatthew Dillon  *
944c8fe38aeSMatthew Dillon  *	000	Fixed		Deliver the signal on the INTR signal for
945c8fe38aeSMatthew Dillon  *				all processor core's LAPICs listed in the
946c8fe38aeSMatthew Dillon  *				destination.  The trigger mode may be
947c8fe38aeSMatthew Dillon  *				edge or level.
948c8fe38aeSMatthew Dillon  *
949c8fe38aeSMatthew Dillon  *	001	Lowest Pri	Deliver to the processor core whos LAPIC
950c8fe38aeSMatthew Dillon  *				is operating at the lowest priority (TPR).
951c8fe38aeSMatthew Dillon  *				The trigger mode may be edge or level.
952c8fe38aeSMatthew Dillon  *
953c8fe38aeSMatthew Dillon  *	010	SMI		System management interrupt.  the vector
954c8fe38aeSMatthew Dillon  *				information is ignored but must be programmed
955c8fe38aeSMatthew Dillon  *				to all zero's for future compatibility.
956c8fe38aeSMatthew Dillon  *				Must be edge triggered.
957c8fe38aeSMatthew Dillon  *
958c8fe38aeSMatthew Dillon  *	011	Reserved
959c8fe38aeSMatthew Dillon  *
960c8fe38aeSMatthew Dillon  *	100	NMI		Deliver on the NMI signal for all cpu cores
961c8fe38aeSMatthew Dillon  *				listed in the destination.  Vector information
962c8fe38aeSMatthew Dillon  *				is ignored.  NMIs are treated as edge triggered
963c8fe38aeSMatthew Dillon  *				interrupts even if programmed as level
964c8fe38aeSMatthew Dillon  *				triggered.  For proper operation the pin must
965c8fe38aeSMatthew Dillon  *				be programmed as an edge trigger.
966c8fe38aeSMatthew Dillon  *
967c8fe38aeSMatthew Dillon  *	101	INIT		Deliver to all processor cores listed in
968c8fe38aeSMatthew Dillon  *				the destination by asserting their INIT signal.
969c8fe38aeSMatthew Dillon  *				All addressed LAPICs will assume their INIT
970c8fe38aeSMatthew Dillon  *				state.  Always treated as edge-triggered even
971c8fe38aeSMatthew Dillon  *				if programmed as level.  For proper operation
972c8fe38aeSMatthew Dillon  *				the pin must be programed as an edge trigger.
973c8fe38aeSMatthew Dillon  *
974c8fe38aeSMatthew Dillon  *	110	Reserved
975c8fe38aeSMatthew Dillon  *
976c8fe38aeSMatthew Dillon  *	111	ExINT		Deliver as an INTR signal to all processor
977c8fe38aeSMatthew Dillon  *				cores listed in the destination as an
978c8fe38aeSMatthew Dillon  *				interrupt originating in an externally
979c8fe38aeSMatthew Dillon  *				connected interrupt controller.
980c8fe38aeSMatthew Dillon  *				The INTA cycle corresponding to this ExINT
981c8fe38aeSMatthew Dillon  *				will be routed to the external controller
982c8fe38aeSMatthew Dillon  *				that is expected to supply the vector.
983c8fe38aeSMatthew Dillon  *				Must be edge triggered.
984c8fe38aeSMatthew Dillon  *
985c8fe38aeSMatthew Dillon  */
986c8fe38aeSMatthew Dillon #define IOART_DELMOD	0x00000700	/* R/W: delivery mode */
987c8fe38aeSMatthew Dillon #define IOART_DELFIXED	0x00000000	/*       fixed */
988c8fe38aeSMatthew Dillon #define IOART_DELLOPRI	0x00000100	/*       lowest priority */
989c8fe38aeSMatthew Dillon #define IOART_DELSMI	0x00000200	/*       System Management INT */
990c8fe38aeSMatthew Dillon #define IOART_DELRSV1	0x00000300	/*       reserved */
991c8fe38aeSMatthew Dillon #define IOART_DELNMI	0x00000400	/*       NMI signal */
992c8fe38aeSMatthew Dillon #define IOART_DELINIT	0x00000500	/*       INIT signal */
993c8fe38aeSMatthew Dillon #define IOART_DELRSV2	0x00000600	/*       reserved */
994c8fe38aeSMatthew Dillon #define IOART_DELEXINT	0x00000700	/*       External INTerrupt */
995c8fe38aeSMatthew Dillon 
996c8fe38aeSMatthew Dillon /*
997c8fe38aeSMatthew Dillon  * The interrupt vector.  Valid values range from 0x10 to 0xFE.
998c8fe38aeSMatthew Dillon  */
999c8fe38aeSMatthew Dillon #define IOART_INTVEC	0x000000ff	/* R/W: INTerrupt vector field */
1000c8fe38aeSMatthew Dillon 
1001c8fe38aeSMatthew Dillon #endif /* _MACHINE_APIC_H_ */
1002