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 * 156*bb467734SMatthew 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. 327c8fe38aeSMatthew Dillon */ 328c8fe38aeSMatthew Dillon 329c8fe38aeSMatthew Dillon #ifndef LOCORE 330c8fe38aeSMatthew Dillon #include <sys/types.h> 331c8fe38aeSMatthew Dillon 332c8fe38aeSMatthew Dillon #define PAD3 int : 32; int : 32; int : 32 333c8fe38aeSMatthew Dillon #define PAD4 int : 32; int : 32; int : 32; int : 32 334c8fe38aeSMatthew Dillon 335c8fe38aeSMatthew Dillon struct LAPIC { 336c8fe38aeSMatthew Dillon /* reserved */ PAD4; 337c8fe38aeSMatthew Dillon /* reserved */ PAD4; 338c8fe38aeSMatthew Dillon u_int32_t id; PAD3; /* 0020 R/W */ 339c8fe38aeSMatthew Dillon u_int32_t version; PAD3; /* 0030 RO */ 340c8fe38aeSMatthew Dillon /* reserved */ PAD4; 341c8fe38aeSMatthew Dillon /* reserved */ PAD4; 342c8fe38aeSMatthew Dillon /* reserved */ PAD4; 343c8fe38aeSMatthew Dillon /* reserved */ PAD4; 344c8fe38aeSMatthew Dillon u_int32_t tpr; PAD3; 345c8fe38aeSMatthew Dillon u_int32_t apr; PAD3; 346c8fe38aeSMatthew Dillon u_int32_t ppr; PAD3; 347c8fe38aeSMatthew Dillon u_int32_t eoi; PAD3; 348c8fe38aeSMatthew Dillon /* reserved */ PAD4; 349c8fe38aeSMatthew Dillon u_int32_t ldr; PAD3; 350c8fe38aeSMatthew Dillon u_int32_t dfr; PAD3; 351c8fe38aeSMatthew Dillon u_int32_t svr; PAD3; 352c8fe38aeSMatthew Dillon u_int32_t isr0; PAD3; 353c8fe38aeSMatthew Dillon u_int32_t isr1; PAD3; 354c8fe38aeSMatthew Dillon u_int32_t isr2; PAD3; 355c8fe38aeSMatthew Dillon u_int32_t isr3; PAD3; 356c8fe38aeSMatthew Dillon u_int32_t isr4; PAD3; 357c8fe38aeSMatthew Dillon u_int32_t isr5; PAD3; 358c8fe38aeSMatthew Dillon u_int32_t isr6; PAD3; 359c8fe38aeSMatthew Dillon u_int32_t isr7; PAD3; 360c8fe38aeSMatthew Dillon u_int32_t tmr0; PAD3; 361c8fe38aeSMatthew Dillon u_int32_t tmr1; PAD3; 362c8fe38aeSMatthew Dillon u_int32_t tmr2; PAD3; 363c8fe38aeSMatthew Dillon u_int32_t tmr3; PAD3; 364c8fe38aeSMatthew Dillon u_int32_t tmr4; PAD3; 365c8fe38aeSMatthew Dillon u_int32_t tmr5; PAD3; 366c8fe38aeSMatthew Dillon u_int32_t tmr6; PAD3; 367c8fe38aeSMatthew Dillon u_int32_t tmr7; PAD3; 368c8fe38aeSMatthew Dillon u_int32_t irr0; PAD3; 369c8fe38aeSMatthew Dillon u_int32_t irr1; PAD3; 370c8fe38aeSMatthew Dillon u_int32_t irr2; PAD3; 371c8fe38aeSMatthew Dillon u_int32_t irr3; PAD3; 372c8fe38aeSMatthew Dillon u_int32_t irr4; PAD3; 373c8fe38aeSMatthew Dillon u_int32_t irr5; PAD3; 374c8fe38aeSMatthew Dillon u_int32_t irr6; PAD3; 375c8fe38aeSMatthew Dillon u_int32_t irr7; PAD3; 376c8fe38aeSMatthew Dillon u_int32_t esr; PAD3; 377c8fe38aeSMatthew Dillon /* reserved */ PAD4; 378c8fe38aeSMatthew Dillon /* reserved */ PAD4; 379c8fe38aeSMatthew Dillon /* reserved */ PAD4; 380c8fe38aeSMatthew Dillon /* reserved */ PAD4; 381c8fe38aeSMatthew Dillon /* reserved */ PAD4; 382c8fe38aeSMatthew Dillon /* reserved */ PAD4; 383c8fe38aeSMatthew Dillon /* reserved */ PAD4; 384c8fe38aeSMatthew Dillon u_int32_t icr_lo; PAD3; 385c8fe38aeSMatthew Dillon u_int32_t icr_hi; PAD3; 386c8fe38aeSMatthew Dillon u_int32_t lvt_timer; PAD3; 387c8fe38aeSMatthew Dillon /* reserved */ PAD4; 388c8fe38aeSMatthew Dillon u_int32_t lvt_pcint; PAD3; 389c8fe38aeSMatthew Dillon u_int32_t lvt_lint0; PAD3; 390c8fe38aeSMatthew Dillon u_int32_t lvt_lint1; PAD3; 391c8fe38aeSMatthew Dillon u_int32_t lvt_error; PAD3; 392c8fe38aeSMatthew Dillon u_int32_t icr_timer; PAD3; 393c8fe38aeSMatthew Dillon u_int32_t ccr_timer; PAD3; 394c8fe38aeSMatthew Dillon /* reserved */ PAD4; 395c8fe38aeSMatthew Dillon /* reserved */ PAD4; 396c8fe38aeSMatthew Dillon /* reserved */ PAD4; 397c8fe38aeSMatthew Dillon /* reserved */ PAD4; 398c8fe38aeSMatthew Dillon u_int32_t dcr_timer; PAD3; 399c8fe38aeSMatthew Dillon /* reserved */ PAD4; 400c8fe38aeSMatthew Dillon }; 401c8fe38aeSMatthew Dillon 402c8fe38aeSMatthew Dillon typedef struct LAPIC lapic_t; 403c8fe38aeSMatthew Dillon 404c8fe38aeSMatthew Dillon /****************************************************************************** 405c8fe38aeSMatthew Dillon * I/O APIC structure 406c8fe38aeSMatthew Dillon */ 407c8fe38aeSMatthew Dillon 408c8fe38aeSMatthew Dillon struct IOAPIC { 409c8fe38aeSMatthew Dillon u_int32_t ioregsel; PAD3; 410c8fe38aeSMatthew Dillon u_int32_t iowin; PAD3; 411c8fe38aeSMatthew Dillon }; 412c8fe38aeSMatthew Dillon 413c8fe38aeSMatthew Dillon typedef struct IOAPIC ioapic_t; 414c8fe38aeSMatthew Dillon 415c8fe38aeSMatthew Dillon #undef PAD4 416c8fe38aeSMatthew Dillon #undef PAD3 417c8fe38aeSMatthew Dillon 418c8fe38aeSMatthew Dillon #endif /* !LOCORE */ 419c8fe38aeSMatthew Dillon 420c8fe38aeSMatthew Dillon 421c8fe38aeSMatthew Dillon /****************************************************************************** 422c8fe38aeSMatthew Dillon * various code 'logical' values 423c8fe38aeSMatthew Dillon */ 424c8fe38aeSMatthew Dillon 425c8fe38aeSMatthew Dillon /* 426c8fe38aeSMatthew Dillon * TPR loads to prioritize which cpu grabs an interrupt 427c8fe38aeSMatthew Dillon * 428c8fe38aeSMatthew Dillon * (note: some fields of the TPR are reserved) 429c8fe38aeSMatthew Dillon */ 430c8fe38aeSMatthew Dillon #define LOPRIO_LEVEL 0x00000010 /* TPR of CPU accepting INTs */ 431c8fe38aeSMatthew Dillon #define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */ 432c8fe38aeSMatthew Dillon 433c8fe38aeSMatthew Dillon /****************************************************************************** 434c8fe38aeSMatthew Dillon * LOCAL APIC defines 435c8fe38aeSMatthew Dillon */ 436c8fe38aeSMatthew Dillon 437c8fe38aeSMatthew Dillon /* 438c8fe38aeSMatthew Dillon * default physical location for the LOCAL (CPU) APIC 439c8fe38aeSMatthew Dillon */ 440c8fe38aeSMatthew Dillon #define DEFAULT_APIC_BASE 0xfee00000 441c8fe38aeSMatthew Dillon 442c8fe38aeSMatthew Dillon /* 443c8fe38aeSMatthew Dillon * lapic.id (rw) 444c8fe38aeSMatthew Dillon */ 445c8fe38aeSMatthew Dillon #define APIC_ID_MASK 0xff000000 446c8fe38aeSMatthew Dillon #define APIC_ID_SHIFT 24 447c8fe38aeSMatthew Dillon #define APIC_ID_CLUSTER 0xf0 448c8fe38aeSMatthew Dillon #define APIC_ID_CLUSTER_ID 0x0f 449c8fe38aeSMatthew Dillon #define APIC_MAX_CLUSTER 0xe 450c8fe38aeSMatthew Dillon #define APIC_MAX_INTRACLUSTER_ID 3 451c8fe38aeSMatthew Dillon #define APIC_ID_CLUSTER_SHIFT 4 452c8fe38aeSMatthew Dillon 453c8fe38aeSMatthew Dillon /* 454c8fe38aeSMatthew Dillon * lapic.ver (ro) 455c8fe38aeSMatthew Dillon */ 456c8fe38aeSMatthew Dillon #define APIC_VER_VERSION 0x000000ff 457c8fe38aeSMatthew Dillon #define APIC_VER_MAXLVT 0x00ff0000 458c8fe38aeSMatthew Dillon #define MAXLVTSHIFT 16 459c8fe38aeSMatthew Dillon 460c8fe38aeSMatthew Dillon /* 461c8fe38aeSMatthew Dillon * lapic.ldr (rw) 462c8fe38aeSMatthew Dillon */ 463c8fe38aeSMatthew Dillon #define APIC_LDR_RESERVED 0x00ffffff 464c8fe38aeSMatthew Dillon 465c8fe38aeSMatthew Dillon /* 466c8fe38aeSMatthew Dillon * lapic.dfr (rw) 467c8fe38aeSMatthew Dillon * 468c8fe38aeSMatthew Dillon * The logical APIC ID is used with logical interrupt 469c8fe38aeSMatthew Dillon * delivery modes. Interpretation of logical destination 470c8fe38aeSMatthew Dillon * information depends on the MODEL bits in the Destination 471c8fe38aeSMatthew Dillon * Format Regiuster. 472c8fe38aeSMatthew Dillon * 473c8fe38aeSMatthew Dillon * MODEL=1111 FLAT MODEL - The MDA is interpreted as 474c8fe38aeSMatthew Dillon * a decoded address. By setting 475c8fe38aeSMatthew Dillon * one bit in the LDR for each 476c8fe38aeSMatthew Dillon * local apic 8 APICs can coexist. 477c8fe38aeSMatthew Dillon * 478c8fe38aeSMatthew Dillon * MODEL=0000 CLUSTER MODEL - 479c8fe38aeSMatthew Dillon */ 480c8fe38aeSMatthew Dillon #define APIC_DFR_RESERVED 0x0fffffff 481c8fe38aeSMatthew Dillon #define APIC_DFR_MODEL_MASK 0xf0000000 482c8fe38aeSMatthew Dillon #define APIC_DFR_MODEL_FLAT 0xf0000000 483c8fe38aeSMatthew Dillon #define APIC_DFR_MODEL_CLUSTER 0x00000000 484c8fe38aeSMatthew Dillon 485c8fe38aeSMatthew Dillon /* 486c8fe38aeSMatthew Dillon * lapic.svr 487c8fe38aeSMatthew Dillon * 488c8fe38aeSMatthew Dillon * Contains the spurious interrupt vector and bits to enable/disable 489c8fe38aeSMatthew Dillon * the local apic and focus processor. 490c8fe38aeSMatthew Dillon */ 491c8fe38aeSMatthew Dillon #define APIC_SVR_VECTOR 0x000000ff 492c8fe38aeSMatthew Dillon #define APIC_SVR_ENABLE 0x00000100 493c8fe38aeSMatthew Dillon #define APIC_SVR_FOCUS_DISABLE 0x00000200 494c8fe38aeSMatthew Dillon 495c8fe38aeSMatthew Dillon /* 496c8fe38aeSMatthew Dillon * lapic.tpr 497c8fe38aeSMatthew Dillon * 498c8fe38aeSMatthew Dillon * PRIO (7:4). Main priority. If 15 the APIC will not 499c8fe38aeSMatthew Dillon * accept any interrupts. 500c8fe38aeSMatthew Dillon * SUBC (3:0) Sub priority. See APR/PPR. 501c8fe38aeSMatthew Dillon */ 502c8fe38aeSMatthew Dillon #define APIC_TPR_PRIO 0x000000ff 503c8fe38aeSMatthew Dillon #define APIC_TPR_INT 0x000000f0 504c8fe38aeSMatthew Dillon #define APIC_TPR_SUB 0x0000000f 505c8fe38aeSMatthew Dillon 506c8fe38aeSMatthew Dillon /* 507c8fe38aeSMatthew Dillon * lapic.icr_lo -------- ----XXRR TL-SDMMM vvvvvvvv 508c8fe38aeSMatthew Dillon * 509c8fe38aeSMatthew Dillon * The interrupt command register. Generally speaking 510c8fe38aeSMatthew Dillon * writing to ICR_LO initiates a command. All fields 511c8fe38aeSMatthew Dillon * are R/W except the 'S' (delivery status) field, which 512c8fe38aeSMatthew Dillon * is read-only. When 513c8fe38aeSMatthew Dillon * 514c8fe38aeSMatthew Dillon * XX: Destination Shorthand field: 515c8fe38aeSMatthew Dillon * 516c8fe38aeSMatthew Dillon * 00 - Use Destination field 517c8fe38aeSMatthew Dillon * 01 - Self only. Dest field ignored. 518c8fe38aeSMatthew Dillon * 10 - All including self (uses a 519c8fe38aeSMatthew Dillon * destination field of 0x0F) 520c8fe38aeSMatthew Dillon * 11 - All excluding self (uses a 521c8fe38aeSMatthew Dillon * destination field of 0x0F) 522c8fe38aeSMatthew Dillon * 523c8fe38aeSMatthew Dillon * RR: RR mode (? needs documentation) 524c8fe38aeSMatthew Dillon * 525c8fe38aeSMatthew Dillon * T: 1 = Level 0 = Edge Trigger modde, used for 526c8fe38aeSMatthew Dillon * the INIT level de-assert delivery mode only 527c8fe38aeSMatthew Dillon * to de-assert a request. 528c8fe38aeSMatthew Dillon * 529c8fe38aeSMatthew Dillon * L: 0 = De-Assert, 1 = Assert. Always write as 530c8fe38aeSMatthew Dillon * 1 when initiating a new command. Can only 531c8fe38aeSMatthew Dillon * write as 0 for INIT mode de-assertion of 532c8fe38aeSMatthew Dillon * command. 533c8fe38aeSMatthew Dillon * 534c8fe38aeSMatthew Dillon * S: 1 = Send Pending. Interrupt has been injected but the APIC 535c8fe38aeSMatthew Dillon * has not yet accepted it. 536c8fe38aeSMatthew Dillon * 537c8fe38aeSMatthew Dillon * D: 0 = physical 1 = logical. In physical mode only bits 24-27 538c8fe38aeSMatthew Dillon * of the DEST field is used from ICR_HI. 539c8fe38aeSMatthew Dillon * 540c8fe38aeSMatthew Dillon * MMM: Delivery mode 541c8fe38aeSMatthew Dillon * 542c8fe38aeSMatthew Dillon * 000 - Fixed. Deliver to all processors according to the 543c8fe38aeSMatthew Dillon * ICR. Always treated as edge triggered. 544c8fe38aeSMatthew Dillon * 545c8fe38aeSMatthew Dillon * 001 - Lowest Priority. Deliver to just the processor 546c8fe38aeSMatthew Dillon * running at the lowest priority. 547c8fe38aeSMatthew Dillon * 548c8fe38aeSMatthew Dillon * 010 - SMI. The vector must be 00B. Only edge triggered 549c8fe38aeSMatthew Dillon * is allowed. The vector field must be programmed to 550c8fe38aeSMatthew Dillon * 0 (huh?) 551c8fe38aeSMatthew Dillon * 552c8fe38aeSMatthew Dillon * 011 - RR Delivery mode (?? needs documentation). 553c8fe38aeSMatthew Dillon * 554c8fe38aeSMatthew Dillon * 100 - NMI. Deliver as an NMI to all processors listed in 555c8fe38aeSMatthew Dillon * the destination field. The vector is ignored. Always 556c8fe38aeSMatthew Dillon * treated as edge triggered. 557c8fe38aeSMatthew Dillon * 558c8fe38aeSMatthew Dillon * 101 - INIT. Deliver as an INIT signal to all processors 559c8fe38aeSMatthew Dillon * (like FIXED) according to the ICR. The vector is 560c8fe38aeSMatthew Dillon * ignored and delivery is always edge-triggered. 561c8fe38aeSMatthew Dillon * 562c8fe38aeSMatthew Dillon * 110 - Startup. Send a special message between cpus. The 563c8fe38aeSMatthew Dillon * vector contains a startup address for the MP boot 564c8fe38aeSMatthew Dillon * protocol. Always edge triggered. Note: a startup 565c8fe38aeSMatthew Dillon * interrupt is not automatically tried in case of failure. 566c8fe38aeSMatthew Dillon * 567c8fe38aeSMatthew Dillon * 111 - <reserved> 568c8fe38aeSMatthew Dillon */ 569c8fe38aeSMatthew Dillon #define APIC_VECTOR_MASK 0x000000ff 570c8fe38aeSMatthew Dillon 571c8fe38aeSMatthew Dillon #define APIC_DELMODE_MASK 0x00000700 572c8fe38aeSMatthew Dillon #define APIC_DELMODE_FIXED 0x00000000 573c8fe38aeSMatthew Dillon #define APIC_DELMODE_LOWPRIO 0x00000100 574c8fe38aeSMatthew Dillon #define APIC_DELMODE_SMI 0x00000200 575c8fe38aeSMatthew Dillon #define APIC_DELMODE_RR 0x00000300 576c8fe38aeSMatthew Dillon #define APIC_DELMODE_NMI 0x00000400 577c8fe38aeSMatthew Dillon #define APIC_DELMODE_INIT 0x00000500 578c8fe38aeSMatthew Dillon #define APIC_DELMODE_STARTUP 0x00000600 579c8fe38aeSMatthew Dillon #define APIC_DELMODE_RESV7 0x00000700 580c8fe38aeSMatthew Dillon 581c8fe38aeSMatthew Dillon #define APIC_DESTMODE_MASK 0x00000800 582c8fe38aeSMatthew Dillon #define APIC_DESTMODE_PHY 0x00000000 583c8fe38aeSMatthew Dillon #define APIC_DESTMODE_LOG 0x00000800 584c8fe38aeSMatthew Dillon 585c8fe38aeSMatthew Dillon #define APIC_DELSTAT_MASK 0x00001000 586c8fe38aeSMatthew Dillon #define APIC_DELSTAT_IDLE 0x00000000 587c8fe38aeSMatthew Dillon #define APIC_DELSTAT_PEND 0x00001000 588c8fe38aeSMatthew Dillon 589c8fe38aeSMatthew Dillon #define APIC_LEVEL_MASK 0x00004000 590c8fe38aeSMatthew Dillon #define APIC_LEVEL_DEASSERT 0x00000000 591c8fe38aeSMatthew Dillon #define APIC_LEVEL_ASSERT 0x00004000 592c8fe38aeSMatthew Dillon 593c8fe38aeSMatthew Dillon #define APIC_TRIGMOD_MASK 0x00008000 594c8fe38aeSMatthew Dillon #define APIC_TRIGMOD_EDGE 0x00000000 595c8fe38aeSMatthew Dillon #define APIC_TRIGMOD_LEVEL 0x00008000 596c8fe38aeSMatthew Dillon 597c8fe38aeSMatthew Dillon #define APIC_RRSTAT_MASK 0x00030000 598c8fe38aeSMatthew Dillon #define APIC_RRSTAT_INVALID 0x00000000 599c8fe38aeSMatthew Dillon #define APIC_RRSTAT_INPROG 0x00010000 600c8fe38aeSMatthew Dillon #define APIC_RRSTAT_VALID 0x00020000 601c8fe38aeSMatthew Dillon #define APIC_RRSTAT_RESV 0x00030000 602c8fe38aeSMatthew Dillon 603c8fe38aeSMatthew Dillon #define APIC_DEST_MASK 0x000c0000 604c8fe38aeSMatthew Dillon #define APIC_DEST_DESTFLD 0x00000000 605c8fe38aeSMatthew Dillon #define APIC_DEST_SELF 0x00040000 606c8fe38aeSMatthew Dillon #define APIC_DEST_ALLISELF 0x00080000 607c8fe38aeSMatthew Dillon #define APIC_DEST_ALLESELF 0x000c0000 608c8fe38aeSMatthew Dillon 609c8fe38aeSMatthew Dillon #define APIC_ICRLO_RESV_MASK 0xfff02000 610c8fe38aeSMatthew Dillon 611c8fe38aeSMatthew Dillon /* 612c8fe38aeSMatthew Dillon * lapic.icr_hi 613c8fe38aeSMatthew Dillon */ 614c8fe38aeSMatthew Dillon #define APIC_ICRH_ID_MASK APIC_ID_MASK 615c8fe38aeSMatthew Dillon 616c8fe38aeSMatthew Dillon /* 617c8fe38aeSMatthew Dillon * lapic.lvt_timer 618c8fe38aeSMatthew Dillon * lapic.lvt_pcint 619c8fe38aeSMatthew Dillon * lapic.lvt_lint0 620c8fe38aeSMatthew Dillon * lapic.lvt_lint1 621c8fe38aeSMatthew Dillon * lapic.lvt_error 622c8fe38aeSMatthew Dillon * 623c8fe38aeSMatthew Dillon * +-----------+--------10-+--FEDCBA98-+-----------+ 624c8fe38aeSMatthew Dillon * 0320 LTIMER | | TM | ---S---- | vector | 625c8fe38aeSMatthew Dillon * 0330 | | | | | 626c8fe38aeSMatthew Dillon * +-----------+--------10-+--FEDCBA98-+-----------+ 627c8fe38aeSMatthew Dillon * 0340 LVPCINT | | -M | ---S-MMM | vector | 628c8fe38aeSMatthew Dillon * 0350 LVINT0 | | -M | LRPS-MMM | vector | 629c8fe38aeSMatthew Dillon * 0360 LVINT1 | | -M | LRPS-MMM | vector | 630c8fe38aeSMatthew Dillon * 0370 LVERROR | | -M | -------- | vector | 631c8fe38aeSMatthew Dillon * +-----------+-----------+-----------+-----------+ 632c8fe38aeSMatthew Dillon * 633c8fe38aeSMatthew Dillon * T: 1 = periodic, 0 = one-shot 634c8fe38aeSMatthew Dillon * (LTIMER only) 635c8fe38aeSMatthew Dillon * 636c8fe38aeSMatthew Dillon * M: 1 = masked 637c8fe38aeSMatthew Dillon * 638c8fe38aeSMatthew Dillon * L: 1 = level, 0 = edge 639c8fe38aeSMatthew Dillon * (LVINT0/1 only) 640c8fe38aeSMatthew Dillon * 641c8fe38aeSMatthew Dillon * R: For level triggered only, set to 1 when a 642c8fe38aeSMatthew Dillon * level int is accepted, cleared by EOI. 643c8fe38aeSMatthew Dillon * (LVINT0/1 only) 644c8fe38aeSMatthew Dillon * 645c8fe38aeSMatthew Dillon * P: Pin Polarity 0 = Active High, 1 = Active Low 646c8fe38aeSMatthew Dillon * (LVINT0/1 only) 647c8fe38aeSMatthew Dillon * 648c8fe38aeSMatthew Dillon * S: 1 = Send Pending. Interrupt has been injected 649c8fe38aeSMatthew Dillon * but APIC has not yet accepted it. 650c8fe38aeSMatthew Dillon * 651c8fe38aeSMatthew Dillon * MMM 000 = Fixed deliver to cpu according to LVT 652c8fe38aeSMatthew Dillon * 653c8fe38aeSMatthew Dillon * MMM 100 = NMI deliver as an NMI. Always edge 654c8fe38aeSMatthew Dillon * 655c8fe38aeSMatthew Dillon * MMM 111 = ExtInt deliver from 8259, routes INTA 656c8fe38aeSMatthew Dillon * bus cycle to external 657c8fe38aeSMatthew Dillon * controller. Controller is 658c8fe38aeSMatthew Dillon * expected to supply vector. 659c8fe38aeSMatthew Dillon * Always level. 660c8fe38aeSMatthew Dillon */ 661c8fe38aeSMatthew Dillon #define APIC_LVT_VECTOR 0x000000ff 662c8fe38aeSMatthew Dillon 663c8fe38aeSMatthew Dillon #define APIC_LVT_DM_MASK 0x00000700 664c8fe38aeSMatthew Dillon #define APIC_LVT_DM_FIXED 0x00000000 665c8fe38aeSMatthew Dillon #define APIC_LVT_DM_NMI 0x00000400 666c8fe38aeSMatthew Dillon #define APIC_LVT_DM_EXTINT 0x00000700 667c8fe38aeSMatthew Dillon 668c8fe38aeSMatthew Dillon #define APIC_LVT_DS 0x00001000 /* (S) Send Pending */ 669c8fe38aeSMatthew Dillon #define APIC_LVT_POLARITY_MASK 0x00002000 670c8fe38aeSMatthew Dillon #define APIC_LVT_POLARITY_LO 0x00002000 /* (P) Pin Polarity */ 671c8fe38aeSMatthew Dillon #define APIC_LVT_POLARITY_HI 0x00000000 672c8fe38aeSMatthew Dillon #define APIC_LVT_LEVELSTATUS 0x00004000 /* (R) level trig status */ 673c8fe38aeSMatthew Dillon #define APIC_LVT_TRIG_MASK 0x00008000 674c8fe38aeSMatthew Dillon #define APIC_LVT_LEVELTRIG 0x00008000 /* (L) 1 = level, 0 = edge */ 675c8fe38aeSMatthew Dillon #define APIC_LVT_MASKED 0x00010000 /* (M) 1 = masked */ 676c8fe38aeSMatthew Dillon 677c8fe38aeSMatthew Dillon /* 678c8fe38aeSMatthew Dillon * lapic.lvt_timer 679c8fe38aeSMatthew Dillon */ 680c8fe38aeSMatthew Dillon #define APIC_LVTT_VECTOR APIC_LVT_VECTOR 681c8fe38aeSMatthew Dillon #define APIC_LVTT_DS APIC_LVT_DS 682c8fe38aeSMatthew Dillon #define APIC_LVTT_MASKED APIC_LVT_MASKED 683c8fe38aeSMatthew Dillon #define APIC_LVTT_PERIODIC 0x00020000 684c8fe38aeSMatthew Dillon 685c8fe38aeSMatthew Dillon #define APIC_TIMER_MAX_COUNT 0xffffffff 686c8fe38aeSMatthew Dillon 687c8fe38aeSMatthew Dillon /* 688c8fe38aeSMatthew Dillon * lapic.icr_timer - initial count register (32 bits) 689c8fe38aeSMatthew Dillon * lapic.ccr_timer - current count register (32 bits) 690c8fe38aeSMatthew Dillon */ 691c8fe38aeSMatthew Dillon 692c8fe38aeSMatthew Dillon /* 693c8fe38aeSMatthew Dillon * lapic.dcr_timer - timer divider register 694c8fe38aeSMatthew Dillon * 695c8fe38aeSMatthew Dillon * d0dd 696c8fe38aeSMatthew Dillon * 697c8fe38aeSMatthew Dillon * 0000 - divide by 2 698c8fe38aeSMatthew Dillon * 0001 - divide by 4 699c8fe38aeSMatthew Dillon * 0010 - divide by 8 700c8fe38aeSMatthew Dillon * 0011 - divide by 16 701c8fe38aeSMatthew Dillon * 1000 - divide by 32 702c8fe38aeSMatthew Dillon * 1001 - divide by 64 703c8fe38aeSMatthew Dillon * 1010 - divide by 128 704c8fe38aeSMatthew Dillon * 1011 - divide by 1 705c8fe38aeSMatthew Dillon */ 706c8fe38aeSMatthew Dillon #define APIC_TDCR_2 0x00 707c8fe38aeSMatthew Dillon #define APIC_TDCR_4 0x01 708c8fe38aeSMatthew Dillon #define APIC_TDCR_8 0x02 709c8fe38aeSMatthew Dillon #define APIC_TDCR_16 0x03 710c8fe38aeSMatthew Dillon #define APIC_TDCR_32 0x08 711c8fe38aeSMatthew Dillon #define APIC_TDCR_64 0x09 712c8fe38aeSMatthew Dillon #define APIC_TDCR_128 0x0a 713c8fe38aeSMatthew Dillon #define APIC_TDCR_1 0x0b 714c8fe38aeSMatthew Dillon 715c8fe38aeSMatthew Dillon /* 716c8fe38aeSMatthew Dillon * fields in IRR 717c8fe38aeSMatthew Dillon * ISA INTerrupts are in bits 16-31 of the 1st IRR register. 718c8fe38aeSMatthew Dillon * these masks DON'T EQUAL the isa IRQs of the same name. 719c8fe38aeSMatthew Dillon */ 720c8fe38aeSMatthew Dillon #define APIC_IRQ0 0 721c8fe38aeSMatthew Dillon #define APIC_IRQ1 1 722c8fe38aeSMatthew Dillon #define APIC_IRQ2 2 723c8fe38aeSMatthew Dillon #define APIC_IRQ3 3 724c8fe38aeSMatthew Dillon #define APIC_IRQ4 4 725c8fe38aeSMatthew Dillon #define APIC_IRQ5 5 726c8fe38aeSMatthew Dillon #define APIC_IRQ6 6 727c8fe38aeSMatthew Dillon #define APIC_IRQ7 7 728c8fe38aeSMatthew Dillon #define APIC_IRQ8 8 729c8fe38aeSMatthew Dillon #define APIC_IRQ9 9 730c8fe38aeSMatthew Dillon #define APIC_IRQ10 10 731c8fe38aeSMatthew Dillon #define APIC_IRQ11 11 732c8fe38aeSMatthew Dillon #define APIC_IRQ12 12 733c8fe38aeSMatthew Dillon #define APIC_IRQ13 13 734c8fe38aeSMatthew Dillon #define APIC_IRQ14 14 735c8fe38aeSMatthew Dillon #define APIC_IRQ15 15 736c8fe38aeSMatthew Dillon #define APIC_IRQ16 16 737c8fe38aeSMatthew Dillon #define APIC_IRQ17 17 738c8fe38aeSMatthew Dillon #define APIC_IRQ18 18 739c8fe38aeSMatthew Dillon #define APIC_IRQ19 19 740c8fe38aeSMatthew Dillon #define APIC_IRQ20 20 741c8fe38aeSMatthew Dillon #define APIC_IRQ21 21 742c8fe38aeSMatthew Dillon #define APIC_IRQ22 22 743c8fe38aeSMatthew Dillon #define APIC_IRQ23 23 744c8fe38aeSMatthew Dillon 745c8fe38aeSMatthew Dillon /****************************************************************************** 746c8fe38aeSMatthew Dillon * I/O APIC defines 747c8fe38aeSMatthew Dillon */ 748c8fe38aeSMatthew Dillon 749c8fe38aeSMatthew Dillon /* default physical locations of an IO APIC */ 750c8fe38aeSMatthew Dillon #define DEFAULT_IO_APIC_BASE 0xfec00000 751c8fe38aeSMatthew Dillon 752c8fe38aeSMatthew Dillon /* window register offset */ 753c8fe38aeSMatthew Dillon #define IOAPIC_WINDOW 0x10 754c8fe38aeSMatthew Dillon 755c8fe38aeSMatthew Dillon /* 756c8fe38aeSMatthew Dillon * indexes into IO APIC (index into array of 32 bit entities) 757c8fe38aeSMatthew Dillon */ 758c8fe38aeSMatthew Dillon #define IOAPIC_ID 0x00 759c8fe38aeSMatthew Dillon #define IOAPIC_VER 0x01 760c8fe38aeSMatthew Dillon #define IOAPIC_ARB 0x02 761c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL 0x10 762c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL0 IOAPIC_REDTBL 763c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL1 (IOAPIC_REDTBL+0x02) 764c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL2 (IOAPIC_REDTBL+0x04) 765c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL3 (IOAPIC_REDTBL+0x06) 766c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL4 (IOAPIC_REDTBL+0x08) 767c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL5 (IOAPIC_REDTBL+0x0a) 768c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL6 (IOAPIC_REDTBL+0x0c) 769c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL7 (IOAPIC_REDTBL+0x0e) 770c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL8 (IOAPIC_REDTBL+0x10) 771c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL9 (IOAPIC_REDTBL+0x12) 772c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL10 (IOAPIC_REDTBL+0x14) 773c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL11 (IOAPIC_REDTBL+0x16) 774c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL12 (IOAPIC_REDTBL+0x18) 775c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL13 (IOAPIC_REDTBL+0x1a) 776c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL14 (IOAPIC_REDTBL+0x1c) 777c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL15 (IOAPIC_REDTBL+0x1e) 778c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL16 (IOAPIC_REDTBL+0x20) 779c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL17 (IOAPIC_REDTBL+0x22) 780c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL18 (IOAPIC_REDTBL+0x24) 781c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL19 (IOAPIC_REDTBL+0x26) 782c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL20 (IOAPIC_REDTBL+0x28) 783c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL21 (IOAPIC_REDTBL+0x2a) 784c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL22 (IOAPIC_REDTBL+0x2c) 785c8fe38aeSMatthew Dillon #define IOAPIC_REDTBL23 (IOAPIC_REDTBL+0x2e) 786c8fe38aeSMatthew Dillon 787c8fe38aeSMatthew Dillon /* fields in VER */ 788c8fe38aeSMatthew Dillon #define IOART_VER_VERSION 0x000000ff 789c8fe38aeSMatthew Dillon #define IOART_VER_MAXREDIR 0x00ff0000 790c8fe38aeSMatthew Dillon #define MAXREDIRSHIFT 16 791c8fe38aeSMatthew Dillon 792c8fe38aeSMatthew Dillon /* 793c8fe38aeSMatthew Dillon * fields in the IO APIC's redirection table entries 794c8fe38aeSMatthew Dillon */ 795c8fe38aeSMatthew Dillon 796c8fe38aeSMatthew Dillon /* 797c8fe38aeSMatthew Dillon * High 32 bit word. The high 8 bits contain the destination field. 798c8fe38aeSMatthew Dillon * 799c8fe38aeSMatthew Dillon * If this entry is set up for Physical Mode, bits 59:56 (the low 4 bits 800c8fe38aeSMatthew Dillon * of the 8 bit destination field) contain an APIC ID. 801c8fe38aeSMatthew Dillon * 802c8fe38aeSMatthew Dillon * If this entry is set up for Logical Mode, the destination field potentially 803c8fe38aeSMatthew Dillon * defines a set of processors. Bits 63:56 (all 8 bits) specify the logical 804c8fe38aeSMatthew Dillon * destination address. 805c8fe38aeSMatthew Dillon * 806c8fe38aeSMatthew Dillon * Current we use IOART_HI_DEST_BROADCAST to broadcast to all LAPICs 807c8fe38aeSMatthew Dillon */ 808c8fe38aeSMatthew Dillon #define IOART_HI_DEST_MASK APIC_ID_MASK 809c8fe38aeSMatthew Dillon #define IOART_HI_DEST_RESV ~APIC_ID_MASK 810c8fe38aeSMatthew Dillon #define IOART_HI_DEST_BROADCAST IOART_HI_DEST_MASK 81146d4e165SJordan Gordeev #define IOART_HI_DEST_SHIFT 24 812c8fe38aeSMatthew Dillon 813c8fe38aeSMatthew Dillon /* 814c8fe38aeSMatthew Dillon * Low 32 bit word 815c8fe38aeSMatthew Dillon */ 816c8fe38aeSMatthew Dillon #define IOART_RESV 0x00fe0000 /* reserved */ 817c8fe38aeSMatthew Dillon 818c8fe38aeSMatthew Dillon /* 819c8fe38aeSMatthew Dillon * Interrupt mask bit. If 1 the interrupt is masked. An edge sensitive 820c8fe38aeSMatthew Dillon * interrupt which is masked will be lost. 821c8fe38aeSMatthew Dillon */ 822c8fe38aeSMatthew Dillon #define IOART_INTMASK 0x00010000 /* R/W: INTerrupt mask */ 823c8fe38aeSMatthew Dillon #define IOART_INTMCLR 0x00000000 /* clear, allow INTs */ 824c8fe38aeSMatthew Dillon #define IOART_INTMSET 0x00010000 /* set, inhibit INTs */ 825c8fe38aeSMatthew Dillon 826c8fe38aeSMatthew Dillon /* 827c8fe38aeSMatthew Dillon * Select trigger mode. 828c8fe38aeSMatthew Dillon */ 829c8fe38aeSMatthew Dillon #define IOART_TRGRMOD 0x00008000 /* R/W: trigger mode */ 830c8fe38aeSMatthew Dillon #define IOART_TRGREDG 0x00000000 /* edge */ 831c8fe38aeSMatthew Dillon #define IOART_TRGRLVL 0x00008000 /* level */ 832c8fe38aeSMatthew Dillon 833c8fe38aeSMatthew Dillon /* 834c8fe38aeSMatthew Dillon * Remote IRR. Only applies to level triggered interrupts, this bit 835c8fe38aeSMatthew Dillon * is set to 1 when the IOAPIC has delivered a level triggered interrupt 836c8fe38aeSMatthew Dillon * to a local APIC. It is cleared when the LAPIC EOI's the interrupt. 837c8fe38aeSMatthew Dillon * This field is read-only. 838c8fe38aeSMatthew Dillon */ 839c8fe38aeSMatthew Dillon #define IOART_REM_IRR 0x00004000 /* RO: remote IRR */ 840c8fe38aeSMatthew Dillon 841c8fe38aeSMatthew Dillon /* 842c8fe38aeSMatthew Dillon * Select interrupt pin polarity 843c8fe38aeSMatthew Dillon */ 844c8fe38aeSMatthew Dillon #define IOART_INTPOL 0x00002000 /* R/W: INT input pin polarity */ 845c8fe38aeSMatthew Dillon #define IOART_INTAHI 0x00000000 /* active high */ 846c8fe38aeSMatthew Dillon #define IOART_INTALO 0x00002000 /* active low */ 847c8fe38aeSMatthew Dillon 848c8fe38aeSMatthew Dillon /* 849c8fe38aeSMatthew Dillon * Delivery Status (read only). 0 = no interrupt pending, 1 = interrupt 850c8fe38aeSMatthew Dillon * pending for tranmission to an LAPIC. Note that this bit does not 851c8fe38aeSMatthew Dillon * indicate whether the interrupt has been processed or is undergoing 852c8fe38aeSMatthew Dillon * processing by a cpu. 853c8fe38aeSMatthew Dillon */ 854c8fe38aeSMatthew Dillon #define IOART_DELIVS 0x00001000 /* RO: delivery status */ 855c8fe38aeSMatthew Dillon 856c8fe38aeSMatthew Dillon /* 857c8fe38aeSMatthew Dillon * Destination mode. 858c8fe38aeSMatthew Dillon * 859c8fe38aeSMatthew Dillon * In physical mode the destination APIC is identified by its ID. 860c8fe38aeSMatthew Dillon * Bits 56-59 specify the 4 bit APIC ID. 861c8fe38aeSMatthew Dillon * 862c8fe38aeSMatthew Dillon * In logical mode destinations are identified by matching on the logical 863c8fe38aeSMatthew Dillon * destination under the control of the destination format register and 864c8fe38aeSMatthew Dillon * logical destination register in each local APIC. 865c8fe38aeSMatthew Dillon * 866c8fe38aeSMatthew Dillon */ 867c8fe38aeSMatthew Dillon #define IOART_DESTMOD 0x00000800 /* R/W: destination mode */ 868c8fe38aeSMatthew Dillon #define IOART_DESTPHY 0x00000000 /* physical */ 869c8fe38aeSMatthew Dillon #define IOART_DESTLOG 0x00000800 /* logical */ 870c8fe38aeSMatthew Dillon 871c8fe38aeSMatthew Dillon /* 872c8fe38aeSMatthew Dillon * Delivery mode. 873c8fe38aeSMatthew Dillon * 874c8fe38aeSMatthew Dillon * 000 Fixed Deliver the signal on the INTR signal for 875c8fe38aeSMatthew Dillon * all processor core's LAPICs listed in the 876c8fe38aeSMatthew Dillon * destination. The trigger mode may be 877c8fe38aeSMatthew Dillon * edge or level. 878c8fe38aeSMatthew Dillon * 879c8fe38aeSMatthew Dillon * 001 Lowest Pri Deliver to the processor core whos LAPIC 880c8fe38aeSMatthew Dillon * is operating at the lowest priority (TPR). 881c8fe38aeSMatthew Dillon * The trigger mode may be edge or level. 882c8fe38aeSMatthew Dillon * 883c8fe38aeSMatthew Dillon * 010 SMI System management interrupt. the vector 884c8fe38aeSMatthew Dillon * information is ignored but must be programmed 885c8fe38aeSMatthew Dillon * to all zero's for future compatibility. 886c8fe38aeSMatthew Dillon * Must be edge triggered. 887c8fe38aeSMatthew Dillon * 888c8fe38aeSMatthew Dillon * 011 Reserved 889c8fe38aeSMatthew Dillon * 890c8fe38aeSMatthew Dillon * 100 NMI Deliver on the NMI signal for all cpu cores 891c8fe38aeSMatthew Dillon * listed in the destination. Vector information 892c8fe38aeSMatthew Dillon * is ignored. NMIs are treated as edge triggered 893c8fe38aeSMatthew Dillon * interrupts even if programmed as level 894c8fe38aeSMatthew Dillon * triggered. For proper operation the pin must 895c8fe38aeSMatthew Dillon * be programmed as an edge trigger. 896c8fe38aeSMatthew Dillon * 897c8fe38aeSMatthew Dillon * 101 INIT Deliver to all processor cores listed in 898c8fe38aeSMatthew Dillon * the destination by asserting their INIT signal. 899c8fe38aeSMatthew Dillon * All addressed LAPICs will assume their INIT 900c8fe38aeSMatthew Dillon * state. Always treated as edge-triggered even 901c8fe38aeSMatthew Dillon * if programmed as level. For proper operation 902c8fe38aeSMatthew Dillon * the pin must be programed as an edge trigger. 903c8fe38aeSMatthew Dillon * 904c8fe38aeSMatthew Dillon * 110 Reserved 905c8fe38aeSMatthew Dillon * 906c8fe38aeSMatthew Dillon * 111 ExINT Deliver as an INTR signal to all processor 907c8fe38aeSMatthew Dillon * cores listed in the destination as an 908c8fe38aeSMatthew Dillon * interrupt originating in an externally 909c8fe38aeSMatthew Dillon * connected interrupt controller. 910c8fe38aeSMatthew Dillon * The INTA cycle corresponding to this ExINT 911c8fe38aeSMatthew Dillon * will be routed to the external controller 912c8fe38aeSMatthew Dillon * that is expected to supply the vector. 913c8fe38aeSMatthew Dillon * Must be edge triggered. 914c8fe38aeSMatthew Dillon * 915c8fe38aeSMatthew Dillon */ 916c8fe38aeSMatthew Dillon #define IOART_DELMOD 0x00000700 /* R/W: delivery mode */ 917c8fe38aeSMatthew Dillon #define IOART_DELFIXED 0x00000000 /* fixed */ 918c8fe38aeSMatthew Dillon #define IOART_DELLOPRI 0x00000100 /* lowest priority */ 919c8fe38aeSMatthew Dillon #define IOART_DELSMI 0x00000200 /* System Management INT */ 920c8fe38aeSMatthew Dillon #define IOART_DELRSV1 0x00000300 /* reserved */ 921c8fe38aeSMatthew Dillon #define IOART_DELNMI 0x00000400 /* NMI signal */ 922c8fe38aeSMatthew Dillon #define IOART_DELINIT 0x00000500 /* INIT signal */ 923c8fe38aeSMatthew Dillon #define IOART_DELRSV2 0x00000600 /* reserved */ 924c8fe38aeSMatthew Dillon #define IOART_DELEXINT 0x00000700 /* External INTerrupt */ 925c8fe38aeSMatthew Dillon 926c8fe38aeSMatthew Dillon /* 927c8fe38aeSMatthew Dillon * The interrupt vector. Valid values range from 0x10 to 0xFE. 928c8fe38aeSMatthew Dillon */ 929c8fe38aeSMatthew Dillon #define IOART_INTVEC 0x000000ff /* R/W: INTerrupt vector field */ 930c8fe38aeSMatthew Dillon 931c8fe38aeSMatthew Dillon #endif /* _MACHINE_APIC_H_ */ 932