2 * Copyright (c) 2003,2004,2008 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * Copyright (c) 1996, by Peter Wemm and Steve Passe, All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. The name of the developer may NOT be used to endorse or promote products
42 * derived from this software without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * $FreeBSD: src/sys/i386/include/apic.h,v 1.14.2.2 2003/03/21 21:46:15 jhb Exp $
57 * $DragonFly: src/sys/platform/pc64/apic/apicreg.h,v 1.1 2008/08/29 17:07:12 dillon Exp $
60 #ifndef _MACHINE_APICREG_H_
61 #define _MACHINE_APICREG_H_
64 * Local && I/O APIC definitions for Pentium P54C+ Built-in APIC.
66 * A per-cpu APIC resides in memory location 0xFEE00000.
68 * 31 ... 24 23 ... 16 15 ... 8 7 ... 0
69 * +-----------+-----------+-----------+-----------+
72 * +-----------+-----------+-----------+-----------+
74 * +-----------+-----------+-----------+-----------+
75 * 0020 ID | | ID | | | | RW
76 * +-----------+-----------+-----------+-----------+
78 * The physical APIC ID is used with physical interrupt
81 * +-----------+-----------+-----------+-----------+
83 * +-----------+-----------+-----------+-----------+
88 * +-----------+-----------+-----------+-----------+
89 * 0080 TPR | | | | PRIO SUBC |
92 * +-----------+-----------+-----------+-----------+
94 * The Task Priority Register provides a priority threshold
95 * mechanism for interrupting the processor. Only interrupts
96 * with a higher priority then that specified in the TPR will
97 * be served. Other interrupts are recorded and serviced
98 * as soon as the TPR value decreases enough to allow that
99 * (unless EOId by another APIC).
101 * PRIO (7:4). Main priority. If 15 the APIC will not
102 * accept any interrupts.
103 * SUBC (3:0) Sub priority. See APR/PPR.
106 * The Processor Priority Register determines whether a
107 * pending interrupt can be dispensed to the processor. ISRV
108 * Is the vector of the highest priority ISR bit set or
109 * zero if no ISR bit is set.
111 * IF TPR[7:4] >= ISRV[7:4]
112 * PPR[7:0] = TPR[7:0]
114 * PPR[7:0] = ISRV[7:4].000
116 * The Arbitration Priority Register holds the current
117 * lowest priority of the procsesor, a value used during
118 * lowest-priority arbitration.
120 * IF (TPR[7:4] >= IRRV[7:4] AND TPR[7:4] > ISRV[7:4])
121 * APR[7:0] = TPR[7:0]
123 * APR[7:4] = max((TPR[7:4]&ISRV[7:4]),IRRV[7:4]).000
125 * +-----------+-----------+-----------+-----------+
127 * +-----------+-----------+-----------+-----------+
129 * +-----------+-----------+-----------+-----------+
130 * 00D0 LDR |LOG APICID | | | |
131 * +-----------+-----------+-----------+-----------+
132 * 00E0 DFR |MODEL| | | | |
133 * +-----------+-----------+-----------+-----------+
135 * The logical APIC ID is used with logical interrupt
136 * delivery modes. Interpretation of logical destination
137 * information depends on the MODEL bits in the Destination
140 * MODEL=1111 FLAT MODEL - The MDA is interpreted as
141 * a decoded address. By setting
142 * one bit in the LDR for each
143 * local apic 8 APICs can coexist.
145 * MODEL=0000 CLUSTER MODEL -
147 * 31 ... 24 23 ... 16 15 ... 8 7 ... 0
148 * +-----------+-----------+-----------+-----------+
149 * 00F0 SVR | | | FE | vvvvvvvv |
150 * +-----------+-----------+-----------+-----------+
152 * Spurious interrupt vector register. The 4 low
153 * vector bits must be programmed to 1111, e.g.
156 * E - LAPIC enable (0 = disable, 1 = enable)
158 * F - Focus processor disable (1 = disable, 0 = enable)
160 * NOTE: The handler for the spurious interrupt vector
161 * should *NOT* issue an EOI because the spurious
162 * interrupt does not effect the ISR.
164 * +-----------+-----------+-----------+-----------+
165 * 0100-0170 ISR| | | | |
166 * 0180-01F0 TMR| | | | |
167 * 0200-0270 IRR| | | | |
168 * +-----------+-----------+-----------+-----------+
170 * These registers represent 256 bits, one bit for each
171 * possible interrupt. Interrupts 0-15 are reserved so
172 * bits 0-15 are also reserved.
174 * TMR - Trigger mode register. Upon acceptance of an int
175 * the corresponding bit is cleared for edge-trig and
176 * set for level-trig. If the TMR bit is set (level),
177 * the local APIC sends an EOI to all I/O APICs as
178 * a result of software issuing an EOI command.
180 * IRR - Interrupt Request Register. Contains active
181 * interrupt requests that have been accepted but not
182 * yet dispensed by the current local APIC. The bit is
183 * cleared and the corresponding ISR bit is set when
184 * the INTA cycle is issued.
186 * ISR - Interrupt In-Service register. Interrupt has been
187 * delivered but not yet fully serviced. Cleared when
188 * an EOI is issued from the processor. An EOI will
189 * also send an EOI to all I/O APICs if TMR was set.
191 * +-----------+-----------+-----------+-----------+
193 * 0290-02F0 | | | | |
194 * +--FEDCBA98-+--76543210-+--FEDCBA98-+-----------+
195 * 0300 ICR_LO | | XX | TL SDMMM | vector |
196 * 0310 ICR_HI | DEST FIELD| | | |
197 * +-----------+-----------+-----------+-----------+
199 * The interrupt command register. Generally speaking
200 * writing to ICR_LO initiates a command. All fields
201 * are R/W except the 'S' (delivery status) field, which
205 * XX: Destination Shorthand field:
207 * 00 Use Destination field
208 * 01 Self only. Dest field ignored.
209 * 10 All including self (uses a
210 * destination field of 0x0F)
211 * 11 All excluding self (uses a
212 * destination field of 0x0F)
214 * T: 1 = Level 0 = Edge Trigger modde, used for
215 * the INIT level de-assert delivery mode only
216 * to de-assert a request.
218 * L: 0 = De-Assert, 1 = Assert. Always write as
219 * 1 when initiating a new command. Can only
220 * write as 0 for INIT mode de-assertion of
223 * S: 1 = Send Pending. Interrupt has been injected
224 * but APIC has not yet accepted it.
226 * D: 0=physical 1=logical. In physical mode
227 * only 24-27 of DEST FIELD is used from ICR_HI.
229 * MMM: 000 Fixed. Deliver to all processors according
230 * to the ICR. Always treated as edge trig.
232 * 001 Lowest Priority. Deliver to just the
233 * processor running at the lowest priority.
235 * 010 SMI. The vector must be 00B. Only edge
236 * triggered is allowed. The vector field
237 * must be programmed to zero (huh?).
241 * 100 NMI. Deliver as an NMI to all processors
242 * listed in the destination field. The
243 * vector is ignored. Alawys treated as
246 * 101 INIT. Deliver as an INIT signal to all
247 * processors (like FIXED). Vector is ignored
248 * and it is always edge-triggered.
250 * 110 Start Up. Sends a special message between
251 * cpus. the vector contains a start-up
252 * address for MP boot protocol.
253 * Always edge triggered. Note: a startup
254 * int is not automatically tried in case of
259 * +-----------+--------10-+--FEDCBA98-+-----------+
260 * 0320 LTIMER | | TM | ---S---- | vector |
262 * +-----------+--------10-+--FEDCBA98-+-----------+
263 * 0340 LVPCINT | | -M | ---S-MMM | vector |
264 * 0350 LVINT0 | | -M | LRPS-MMM | vector |
265 * 0360 LVINT1 | | -M | LRPS-MMM | vector |
266 * 0370 LVERROR | | -M | -------- | vector |
267 * +-----------+-----------+-----------+-----------+
269 * T: 1 = periodic, 0 = one-shot
273 * L: 1 = level, 0 = edge
275 * R: For level triggered only, set to 1 when a
276 * level int is accepted, cleared by EOI.
278 * P: Pin Polarity 0 = Active High, 1 = Active Low
280 * S: 1 = Send Pending. Interrupt has been injected
281 * but APIC has not yet accepted it.
283 * MMM 000 = Fixed deliver to cpu according to LVT
285 * MMM 100 = NMI deliver as an NMI. Always edge
287 * MMM 111 = ExtInt deliver from 8259, routes INTA
288 * bus cycle to external
289 * controller. Controller is
290 * expected to supply vector.
293 * +-----------+-----------+-----------+-----------+
294 * 0380 TMR_ICR | | | | |
295 * 0390 TMR_CCR | | | | |
296 * +-----------+-----------+-----------+-----------+
298 * The timer initial count register and current count
301 * +-----------+-----------+-----------+-----------+
306 * +-----------+-----------+-----------+-----------+
307 * 03E0 TMR_DCR | | | | d-dd |
308 * +-----------+-----------+-----------+-----------+
310 * The timer divide configuration register. d-dd is:
315 * 0011 - divide by 16
316 * 1000 - divide by 32
317 * 1001 - divide by 64
318 * 1010 - divide by 128
321 * NOTE ON EOI: Upon receiving an EOI the APIC clears the highest priority
322 * interrupt in the ISR and selects the next highest priority interrupt
323 * for posting to the CPU. If the interrupt being EOId was level
324 * triggered the APIC will send an EOI to all I/O APICs. For the moment
325 * you can write garbage to the EOI register but for future compatibility
326 * 0 should be written.
352 #include <sys/types.h>
354 #define PAD3 int : 32; int : 32; int : 32
355 #define PAD4 int : 32; int : 32; int : 32; int : 32
360 u_int32_t id; PAD3; /* 0020 R/W */
361 u_int32_t version; PAD3; /* 0030 RO */
374 u_int32_t isr0; PAD3;
375 u_int32_t isr1; PAD3;
376 u_int32_t isr2; PAD3;
377 u_int32_t isr3; PAD3;
378 u_int32_t isr4; PAD3;
379 u_int32_t isr5; PAD3;
380 u_int32_t isr6; PAD3;
381 u_int32_t isr7; PAD3;
382 u_int32_t tmr0; PAD3;
383 u_int32_t tmr1; PAD3;
384 u_int32_t tmr2; PAD3;
385 u_int32_t tmr3; PAD3;
386 u_int32_t tmr4; PAD3;
387 u_int32_t tmr5; PAD3;
388 u_int32_t tmr6; PAD3;
389 u_int32_t tmr7; PAD3;
390 u_int32_t irr0; PAD3;
391 u_int32_t irr1; PAD3;
392 u_int32_t irr2; PAD3;
393 u_int32_t irr3; PAD3;
394 u_int32_t irr4; PAD3;
395 u_int32_t irr5; PAD3;
396 u_int32_t irr6; PAD3;
397 u_int32_t irr7; PAD3;
406 u_int32_t icr_lo; PAD3;
407 u_int32_t icr_hi; PAD3;
408 u_int32_t lvt_timer; PAD3;
410 u_int32_t lvt_pcint; PAD3;
411 u_int32_t lvt_lint0; PAD3;
412 u_int32_t lvt_lint1; PAD3;
413 u_int32_t lvt_error; PAD3;
414 u_int32_t icr_timer; PAD3;
415 u_int32_t ccr_timer; PAD3; /* e9 */
420 u_int32_t dcr_timer; PAD3; /* 3e */
421 u_int32_t self_ipi; PAD3; /* 3f - Only in x2APIC */
422 u_int32_t ext_feat; PAD3;
423 u_int32_t ext_ctrl; PAD3;
424 u_int32_t ext_seoi; PAD3;
430 u_int32_t ext_ier0; PAD3;
431 u_int32_t ext_ier1; PAD3;
432 u_int32_t ext_ier2; PAD3;
433 u_int32_t ext_ier3; PAD3;
434 u_int32_t ext_ier4; PAD3;
435 u_int32_t ext_ier5; PAD3;
436 u_int32_t ext_ier6; PAD3;
437 u_int32_t ext_ier7; PAD3;
443 typedef struct LAPIC lapic_t;
445 /******************************************************************************
450 u_int32_t ioregsel; PAD3;
451 u_int32_t iowin; PAD3;
454 typedef struct IOAPIC ioapic_t;
462 /******************************************************************************
463 * various code 'logical' values
467 * TPR loads to prioritize which cpu grabs an interrupt
469 * (note: some fields of the TPR are reserved)
471 #define LOPRIO_LEVEL 0x00000010 /* TPR of CPU accepting INTs */
472 #define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */
474 /******************************************************************************
479 * default physical location for the LOCAL (CPU) APIC
481 #define DEFAULT_APIC_BASE 0xfee00000
486 #define APIC_ID_MASK 0xff000000
487 #define APIC_ID_SHIFT 24
488 #define APIC_ID_CLUSTER 0xf0
489 #define APIC_ID_CLUSTER_ID 0x0f
490 #define APIC_MAX_CLUSTER 0xe
491 #define APIC_MAX_INTRACLUSTER_ID 3
492 #define APIC_ID_CLUSTER_SHIFT 4
494 #define APIC_ID(id) (((id) & APIC_ID_MASK) >> APIC_ID_SHIFT)
499 #define APIC_VER_VERSION 0x000000ff
500 #define APIC_VER_MAXLVT 0x00ff0000
501 #define MAXLVTSHIFT 16
502 #define APIC_VER_EOI_SUPP 0x01000000
503 #define APIC_VER_AMD_EXT_SPACE 0x80000000
508 #define APIC_LDR_RESERVED 0x00ffffff
513 * The logical APIC ID is used with logical interrupt
514 * delivery modes. Interpretation of logical destination
515 * information depends on the MODEL bits in the Destination
518 * MODEL=1111 FLAT MODEL - The MDA is interpreted as
519 * a decoded address. By setting
520 * one bit in the LDR for each
521 * local apic 8 APICs can coexist.
523 * MODEL=0000 CLUSTER MODEL -
525 #define APIC_DFR_RESERVED 0x0fffffff
526 #define APIC_DFR_MODEL_MASK 0xf0000000
527 #define APIC_DFR_MODEL_FLAT 0xf0000000
528 #define APIC_DFR_MODEL_CLUSTER 0x00000000
533 * Contains the spurious interrupt vector and bits to enable/disable
534 * the local apic and focus processor.
536 #define APIC_SVR_VECTOR 0x000000ff
537 #define APIC_SVR_ENABLE 0x00000100
538 #define APIC_SVR_FOCUS_DISABLE 0x00000200
539 #define APIC_SVR_EOI_SUPP 0x00001000
544 * PRIO (7:4). Main priority. If 15 the APIC will not
545 * accept any interrupts.
546 * SUBC (3:0) Sub priority. See APR/PPR.
548 #define APIC_TPR_PRIO 0x000000ff
549 #define APIC_TPR_INT 0x000000f0
550 #define APIC_TPR_SUB 0x0000000f
553 * lapic.icr_lo -------- ----XXRR TL-SDMMM vvvvvvvv
555 * The interrupt command register. Generally speaking
556 * writing to ICR_LO initiates a command. All fields
557 * are R/W except the 'S' (delivery status) field, which
560 * XX: Destination Shorthand field:
562 * 00 - Use Destination field
563 * 01 - Self only. Dest field ignored.
564 * 10 - All including self (uses a
565 * destination field of 0x0F)
566 * 11 - All excluding self (uses a
567 * destination field of 0x0F)
569 * RR: RR mode (? needs documentation)
571 * T: 1 = Level 0 = Edge Trigger modde, used for
572 * the INIT level de-assert delivery mode only
573 * to de-assert a request.
575 * L: 0 = De-Assert, 1 = Assert. Always write as
576 * 1 when initiating a new command. Can only
577 * write as 0 for INIT mode de-assertion of
580 * S: 1 = Send Pending. Interrupt has been injected but the APIC
581 * has not yet accepted it.
583 * D: 0 = physical 1 = logical. In physical mode only bits 24-27
584 * of the DEST field is used from ICR_HI.
588 * 000 - Fixed. Deliver to all processors according to the
589 * ICR. Always treated as edge triggered.
591 * 001 - Lowest Priority. Deliver to just the processor
592 * running at the lowest priority.
594 * 010 - SMI. The vector must be 00B. Only edge triggered
595 * is allowed. The vector field must be programmed to
598 * 011 - RR Delivery mode (?? needs documentation).
600 * 100 - NMI. Deliver as an NMI to all processors listed in
601 * the destination field. The vector is ignored. Always
602 * treated as edge triggered.
604 * 101 - INIT. Deliver as an INIT signal to all processors
605 * (like FIXED) according to the ICR. The vector is
606 * ignored and delivery is always edge-triggered.
608 * 110 - Startup. Send a special message between cpus. The
609 * vector contains a startup address for the MP boot
610 * protocol. Always edge triggered. Note: a startup
611 * interrupt is not automatically tried in case of failure.
615 #define APIC_VECTOR_MASK 0x000000ff
617 #define APIC_DELMODE_MASK 0x00000700
618 #define APIC_DELMODE_FIXED 0x00000000
619 #define APIC_DELMODE_LOWPRIO 0x00000100
620 #define APIC_DELMODE_SMI 0x00000200
621 #define APIC_DELMODE_RR 0x00000300
622 #define APIC_DELMODE_NMI 0x00000400
623 #define APIC_DELMODE_INIT 0x00000500
624 #define APIC_DELMODE_STARTUP 0x00000600
625 #define APIC_DELMODE_RESV7 0x00000700
627 #define APIC_DESTMODE_MASK 0x00000800
628 #define APIC_DESTMODE_PHY 0x00000000
629 #define APIC_DESTMODE_LOG 0x00000800
631 #define APIC_DELSTAT_MASK 0x00001000
632 #define APIC_DELSTAT_IDLE 0x00000000
633 #define APIC_DELSTAT_PEND 0x00001000
635 #define APIC_LEVEL_MASK 0x00004000
636 #define APIC_LEVEL_DEASSERT 0x00000000
637 #define APIC_LEVEL_ASSERT 0x00004000
639 #define APIC_TRIGMOD_MASK 0x00008000
640 #define APIC_TRIGMOD_EDGE 0x00000000
641 #define APIC_TRIGMOD_LEVEL 0x00008000
643 #define APIC_RRSTAT_MASK 0x00030000
644 #define APIC_RRSTAT_INVALID 0x00000000
645 #define APIC_RRSTAT_INPROG 0x00010000
646 #define APIC_RRSTAT_VALID 0x00020000
647 #define APIC_RRSTAT_RESV 0x00030000
649 #define APIC_DEST_MASK 0x000c0000
650 #define APIC_DEST_DESTFLD 0x00000000
651 #define APIC_DEST_SELF 0x00040000
652 #define APIC_DEST_ALLISELF 0x00080000
653 #define APIC_DEST_ALLESELF 0x000c0000
655 #define APIC_ICRLO_RESV_MASK 0xfff02000
660 #define APIC_ICRH_ID_MASK APIC_ID_MASK
669 * +-----------+--------10-+--FEDCBA98-+-----------+
670 * 0320 LTIMER | | TM | ---S---- | vector |
672 * +-----------+--------10-+--FEDCBA98-+-----------+
673 * 0340 LVPCINT | | -M | ---S-MMM | vector |
674 * 0350 LVINT0 | | -M | LRPS-MMM | vector |
675 * 0360 LVINT1 | | -M | LRPS-MMM | vector |
676 * 0370 LVERROR | | -M | -------- | vector |
677 * +-----------+-----------+-----------+-----------+
679 * T: 1 = periodic, 0 = one-shot
684 * L: 1 = level, 0 = edge
687 * R: For level triggered only, set to 1 when a
688 * level int is accepted, cleared by EOI.
691 * P: Pin Polarity 0 = Active High, 1 = Active Low
694 * S: 1 = Send Pending. Interrupt has been injected
695 * but APIC has not yet accepted it.
697 * MMM 000 = Fixed deliver to cpu according to LVT
699 * MMM 100 = NMI deliver as an NMI. Always edge
701 * MMM 111 = ExtInt deliver from 8259, routes INTA
702 * bus cycle to external
703 * controller. Controller is
704 * expected to supply vector.
707 #define APIC_LVT_VECTOR 0x000000ff
709 #define APIC_LVT_DM_MASK 0x00000700
710 #define APIC_LVT_DM_FIXED 0x00000000
711 #define APIC_LVT_DM_NMI 0x00000400
712 #define APIC_LVT_DM_EXTINT 0x00000700
714 #define APIC_LVT_DS 0x00001000 /* (S) Send Pending */
715 #define APIC_LVT_POLARITY_MASK 0x00002000
716 #define APIC_LVT_POLARITY_LO 0x00002000 /* (P) Pin Polarity */
717 #define APIC_LVT_POLARITY_HI 0x00000000
718 #define APIC_LVT_LEVELSTATUS 0x00004000 /* (R) level trig status */
719 #define APIC_LVT_TRIG_MASK 0x00008000
720 #define APIC_LVT_LEVELTRIG 0x00008000 /* (L) 1 = level, 0 = edge */
721 #define APIC_LVT_MASKED 0x00010000 /* (M) 1 = masked */
726 #define APIC_LVTT_VECTOR APIC_LVT_VECTOR
727 #define APIC_LVTT_DS APIC_LVT_DS
728 #define APIC_LVTT_MASKED APIC_LVT_MASKED
729 #define APIC_LVTT_PERIODIC 0x00020000
730 #define APIC_LVTT_TSCDLT 0x00040000
732 #define APIC_TIMER_MAX_COUNT 0xffffffff
735 * lapic.icr_timer - initial count register (32 bits)
736 * lapic.ccr_timer - current count register (32 bits)
740 * lapic.dcr_timer - timer divider register
747 * 0011 - divide by 16
748 * 1000 - divide by 32
749 * 1001 - divide by 64
750 * 1010 - divide by 128
753 #define APIC_TDCR_2 0x00
754 #define APIC_TDCR_4 0x01
755 #define APIC_TDCR_8 0x02
756 #define APIC_TDCR_16 0x03
757 #define APIC_TDCR_32 0x08
758 #define APIC_TDCR_64 0x09
759 #define APIC_TDCR_128 0x0a
760 #define APIC_TDCR_1 0x0b
763 * lapic.self_ipi (x2APIC only)
766 * lapic.ext_feat (AMD only)
768 #define APIC_EXTFEAT_MASK 0x00ff0000
769 #define APIC_EXTFEAT_SHIFT 16
770 #define APIC_EXTFEAT_EXTID_CAP 0x00000004
771 #define APIC_EXTFEAT_SEIO_CAP 0x00000002
772 #define APIC_EXTFEAT_IER_CAP 0x00000001
780 * lapic.ext_lvt[N].lvt
782 #define APIC_EXTLVT_IBS 0 /* Instruction based sampling */
783 #define APIC_EXTLVT_MCA 1 /* MCE thresholding */
784 #define APIC_EXTLVT_DEI 2 /* Deferred error interrupt */
785 #define APIC_EXTLVT_SBI 3 /* Sideband interface */
787 /******************************************************************************
791 /* default physical locations of an IO APIC */
792 #define DEFAULT_IO_APIC_BASE 0xfec00000
794 /* window register offset */
795 #define IOAPIC_WINDOW 0x10
798 * indexes into IO APIC (index into array of 32 bit entities)
800 #define IOAPIC_ID 0x00
801 #define IOAPIC_VER 0x01
802 #define IOAPIC_ARB 0x02
803 #define IOAPIC_REDTBL 0x10
804 #define IOAPIC_REDTBL0 IOAPIC_REDTBL
805 #define IOAPIC_REDTBL1 (IOAPIC_REDTBL+0x02)
806 #define IOAPIC_REDTBL2 (IOAPIC_REDTBL+0x04)
807 #define IOAPIC_REDTBL3 (IOAPIC_REDTBL+0x06)
808 #define IOAPIC_REDTBL4 (IOAPIC_REDTBL+0x08)
809 #define IOAPIC_REDTBL5 (IOAPIC_REDTBL+0x0a)
810 #define IOAPIC_REDTBL6 (IOAPIC_REDTBL+0x0c)
811 #define IOAPIC_REDTBL7 (IOAPIC_REDTBL+0x0e)
812 #define IOAPIC_REDTBL8 (IOAPIC_REDTBL+0x10)
813 #define IOAPIC_REDTBL9 (IOAPIC_REDTBL+0x12)
814 #define IOAPIC_REDTBL10 (IOAPIC_REDTBL+0x14)
815 #define IOAPIC_REDTBL11 (IOAPIC_REDTBL+0x16)
816 #define IOAPIC_REDTBL12 (IOAPIC_REDTBL+0x18)
817 #define IOAPIC_REDTBL13 (IOAPIC_REDTBL+0x1a)
818 #define IOAPIC_REDTBL14 (IOAPIC_REDTBL+0x1c)
819 #define IOAPIC_REDTBL15 (IOAPIC_REDTBL+0x1e)
820 #define IOAPIC_REDTBL16 (IOAPIC_REDTBL+0x20)
821 #define IOAPIC_REDTBL17 (IOAPIC_REDTBL+0x22)
822 #define IOAPIC_REDTBL18 (IOAPIC_REDTBL+0x24)
823 #define IOAPIC_REDTBL19 (IOAPIC_REDTBL+0x26)
824 #define IOAPIC_REDTBL20 (IOAPIC_REDTBL+0x28)
825 #define IOAPIC_REDTBL21 (IOAPIC_REDTBL+0x2a)
826 #define IOAPIC_REDTBL22 (IOAPIC_REDTBL+0x2c)
827 #define IOAPIC_REDTBL23 (IOAPIC_REDTBL+0x2e)
830 #define IOART_VER_VERSION 0x000000ff
831 #define IOART_VER_MAXREDIR 0x00ff0000
832 #define MAXREDIRSHIFT 16
835 * fields in the IO APIC's redirection table entries
839 * High 32 bit word. The high 8 bits contain the destination field.
841 * If this entry is set up for Physical Mode, bits 59:56 (the low 4 bits
842 * of the 8 bit destination field) contain an APIC ID.
844 * If this entry is set up for Logical Mode, the destination field potentially
845 * defines a set of processors. Bits 63:56 (all 8 bits) specify the logical
846 * destination address.
848 * Current we use IOART_HI_DEST_BROADCAST to broadcast to all LAPICs
850 #define IOART_HI_DEST_MASK APIC_ID_MASK
851 #define IOART_HI_DEST_RESV ~APIC_ID_MASK
852 #define IOART_HI_DEST_BROADCAST IOART_HI_DEST_MASK
853 #define IOART_HI_DEST_SHIFT 24
858 #define IOART_RESV 0x00fe0000 /* reserved */
861 * Interrupt mask bit. If 1 the interrupt is masked. An edge sensitive
862 * interrupt which is masked will be lost.
864 #define IOART_INTMASK 0x00010000 /* R/W: INTerrupt mask */
865 #define IOART_INTMCLR 0x00000000 /* clear, allow INTs */
866 #define IOART_INTMSET 0x00010000 /* set, inhibit INTs */
869 * Select trigger mode.
871 #define IOART_TRGRMOD 0x00008000 /* R/W: trigger mode */
872 #define IOART_TRGREDG 0x00000000 /* edge */
873 #define IOART_TRGRLVL 0x00008000 /* level */
876 * Remote IRR. Only applies to level triggered interrupts, this bit
877 * is set to 1 when the IOAPIC has delivered a level triggered interrupt
878 * to a local APIC. It is cleared when the LAPIC EOI's the interrupt.
879 * This field is read-only.
881 #define IOART_REM_IRR 0x00004000 /* RO: remote IRR */
884 * Select interrupt pin polarity
886 #define IOART_INTPOL 0x00002000 /* R/W: INT input pin polarity */
887 #define IOART_INTAHI 0x00000000 /* active high */
888 #define IOART_INTALO 0x00002000 /* active low */
891 * Delivery Status (read only). 0 = no interrupt pending, 1 = interrupt
892 * pending for tranmission to an LAPIC. Note that this bit does not
893 * indicate whether the interrupt has been processed or is undergoing
894 * processing by a cpu.
896 #define IOART_DELIVS 0x00001000 /* RO: delivery status */
901 * In physical mode the destination APIC is identified by its ID.
902 * Bits 56-63 specify the 8 bit APIC ID.
904 * In logical mode destinations are identified by matching on the logical
905 * destination under the control of the destination format register and
906 * logical destination register in each local APIC.
909 #define IOART_DESTMOD 0x00000800 /* R/W: destination mode */
910 #define IOART_DESTPHY 0x00000000 /* physical */
911 #define IOART_DESTLOG 0x00000800 /* logical */
916 * 000 Fixed Deliver the signal on the INTR signal for
917 * all processor core's LAPICs listed in the
918 * destination. The trigger mode may be
921 * 001 Lowest Pri Deliver to the processor core whos LAPIC
922 * is operating at the lowest priority (TPR).
923 * The trigger mode may be edge or level.
925 * 010 SMI System management interrupt. the vector
926 * information is ignored but must be programmed
927 * to all zero's for future compatibility.
928 * Must be edge triggered.
932 * 100 NMI Deliver on the NMI signal for all cpu cores
933 * listed in the destination. Vector information
934 * is ignored. NMIs are treated as edge triggered
935 * interrupts even if programmed as level
936 * triggered. For proper operation the pin must
937 * be programmed as an edge trigger.
939 * 101 INIT Deliver to all processor cores listed in
940 * the destination by asserting their INIT signal.
941 * All addressed LAPICs will assume their INIT
942 * state. Always treated as edge-triggered even
943 * if programmed as level. For proper operation
944 * the pin must be programed as an edge trigger.
948 * 111 ExINT Deliver as an INTR signal to all processor
949 * cores listed in the destination as an
950 * interrupt originating in an externally
951 * connected interrupt controller.
952 * The INTA cycle corresponding to this ExINT
953 * will be routed to the external controller
954 * that is expected to supply the vector.
955 * Must be edge triggered.
958 #define IOART_DELMOD 0x00000700 /* R/W: delivery mode */
959 #define IOART_DELFIXED 0x00000000 /* fixed */
960 #define IOART_DELLOPRI 0x00000100 /* lowest priority */
961 #define IOART_DELSMI 0x00000200 /* System Management INT */
962 #define IOART_DELRSV1 0x00000300 /* reserved */
963 #define IOART_DELNMI 0x00000400 /* NMI signal */
964 #define IOART_DELINIT 0x00000500 /* INIT signal */
965 #define IOART_DELRSV2 0x00000600 /* reserved */
966 #define IOART_DELEXINT 0x00000700 /* External INTerrupt */
969 * The interrupt vector. Valid values range from 0x10 to 0xFE.
971 #define IOART_INTVEC 0x000000ff /* R/W: INTerrupt vector field */
973 #endif /* _MACHINE_APIC_H_ */