xref: /minix3/sys/arch/x86/include/i82489reg.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: i82489reg.h,v 1.13 2015/07/17 05:16:09 msaitoh Exp $	*/
21cd76c75SBen Gras 
31cd76c75SBen Gras /*-
41cd76c75SBen Gras  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
51cd76c75SBen Gras  * All rights reserved.
61cd76c75SBen Gras  *
71cd76c75SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
81cd76c75SBen Gras  * by Frank van der Linden.
91cd76c75SBen Gras  *
101cd76c75SBen Gras  * Redistribution and use in source and binary forms, with or without
111cd76c75SBen Gras  * modification, are permitted provided that the following conditions
121cd76c75SBen Gras  * are met:
131cd76c75SBen Gras  * 1. Redistributions of source code must retain the above copyright
141cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer.
151cd76c75SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
161cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer in the
171cd76c75SBen Gras  *    documentation and/or other materials provided with the distribution.
181cd76c75SBen Gras  *
191cd76c75SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201cd76c75SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211cd76c75SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221cd76c75SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231cd76c75SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241cd76c75SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251cd76c75SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261cd76c75SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271cd76c75SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281cd76c75SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291cd76c75SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
301cd76c75SBen Gras  */
311cd76c75SBen Gras 
321cd76c75SBen Gras 
331cd76c75SBen Gras /*
341cd76c75SBen Gras  * Registers and constants for the 82489DX and Pentium (and up) integrated
351cd76c75SBen Gras  * "local" APIC.
361cd76c75SBen Gras  */
371cd76c75SBen Gras 
381cd76c75SBen Gras #define	LAPIC_ID		0x020	/* ID. RW */
391cd76c75SBen Gras #	define LAPIC_ID_MASK		0xff000000
401cd76c75SBen Gras #	define LAPIC_ID_SHIFT		24
411cd76c75SBen Gras 
421cd76c75SBen Gras #define LAPIC_VERS		0x030	/* Version. R */
431cd76c75SBen Gras #	define LAPIC_VERSION_MASK	0x000000ff
441cd76c75SBen Gras #	define LAPIC_VERSION_LVT_MASK	0x00ff0000
451cd76c75SBen Gras #	define LAPIC_VERSION_LVT_SHIFT	16
461cd76c75SBen Gras 
471cd76c75SBen Gras #define LAPIC_TPRI		0x080	/* Task Prio. RW */
481cd76c75SBen Gras #	define LAPIC_TPRI_MASK		0x000000ff
491cd76c75SBen Gras #	define LAPIC_TPRI_INT_MASK	0x000000f0
501cd76c75SBen Gras #	define LAPIC_TPRI_SUB_MASK	0x0000000f
511cd76c75SBen Gras 
521cd76c75SBen Gras #define LAPIC_APRI		0x090	/* Arbitration prio R */
531cd76c75SBen Gras #	define LAPIC_APRI_MASK		0x000000ff
541cd76c75SBen Gras 
551cd76c75SBen Gras #define LAPIC_PPRI		0x0a0	/* Processor prio. R */
561cd76c75SBen Gras #define LAPIC_EOI		0x0b0	/* End Int. W */
571cd76c75SBen Gras #define LAPIC_RRR		0x0c0	/* Remote read R */
581cd76c75SBen Gras #define LAPIC_LDR		0x0d0	/* Logical dest. RW */
591cd76c75SBen Gras 
601cd76c75SBen Gras #define LAPIC_DFR		0x0e0	/* Dest. format RW */
611cd76c75SBen Gras #	define LAPIC_DFR_MASK		0xf0000000
621cd76c75SBen Gras #	define LAPIC_DFR_FLAT		0xf0000000
631cd76c75SBen Gras #	define LAPIC_DFR_CLUSTER	0x00000000
641cd76c75SBen Gras 
651cd76c75SBen Gras #define LAPIC_SVR		0x0f0	/* Spurious intvec RW */
661cd76c75SBen Gras #	define LAPIC_SVR_VECTOR_MASK	0x000000ff
671cd76c75SBen Gras #	define LAPIC_SVR_VEC_FIX	0x0000000f
681cd76c75SBen Gras #	define LAPIC_SVR_VEC_PROG	0x000000f0
691cd76c75SBen Gras #	define LAPIC_SVR_ENABLE		0x00000100
701cd76c75SBen Gras #	define LAPIC_SVR_SWEN		0x00000100
711cd76c75SBen Gras #	define LAPIC_SVR_FOCUS		0x00000200
721cd76c75SBen Gras #	define LAPIC_SVR_FDIS		0x00000200
731cd76c75SBen Gras 
741cd76c75SBen Gras #define LAPIC_ISR	0x100		/* In-Service Status */
751cd76c75SBen Gras #define LAPIC_TMR	0x180		/* Trigger Mode */
761cd76c75SBen Gras #define LAPIC_IRR	0x200		/* Interrupt Req */
771cd76c75SBen Gras #define LAPIC_ESR	0x280		/* Err status. R */
781cd76c75SBen Gras 
791cd76c75SBen Gras #define LAPIC_ICRLO	0x300		/* Int. cmd. RW */
801cd76c75SBen Gras #	define LAPIC_DLMODE_MASK	0x00000700
811cd76c75SBen Gras #	define LAPIC_DLMODE_FIXED	0x00000000
821cd76c75SBen Gras #	define LAPIC_DLMODE_LOW		0x00000100
831cd76c75SBen Gras #	define LAPIC_DLMODE_SMI		0x00000200
841cd76c75SBen Gras #	define LAPIC_DLMODE_NMI		0x00000400
851cd76c75SBen Gras #	define LAPIC_DLMODE_INIT	0x00000500
861cd76c75SBen Gras #	define LAPIC_DLMODE_STARTUP	0x00000600
871cd76c75SBen Gras #	define LAPIC_DLMODE_EXTINT	0x00000700
881cd76c75SBen Gras 
891cd76c75SBen Gras #	define LAPIC_DSTMODE_PHYS	0x00000000
901cd76c75SBen Gras #	define LAPIC_DSTMODE_LOG	0x00000800
911cd76c75SBen Gras 
921cd76c75SBen Gras #	define LAPIC_DLSTAT_BUSY	0x00001000
931cd76c75SBen Gras #	define LAPIC_DLSTAT_IDLE	0x00000000
941cd76c75SBen Gras 
951cd76c75SBen Gras #	define LAPIC_LEVEL_MASK		0x00004000
961cd76c75SBen Gras #	define LAPIC_LEVEL_ASSERT	0x00004000
971cd76c75SBen Gras #	define LAPIC_LEVEL_DEASSERT	0x00000000
981cd76c75SBen Gras 
991cd76c75SBen Gras #	define LAPIC_TRIGGER_MASK	0x00008000
1001cd76c75SBen Gras #	define LAPIC_TRIGGER_EDGE	0x00000000
1011cd76c75SBen Gras #	define LAPIC_TRIGGER_LEVEL	0x00008000
1021cd76c75SBen Gras 
1031cd76c75SBen Gras #	define LAPIC_DEST_MASK		0x000c0000
1041cd76c75SBen Gras #	define LAPIC_DEST_DEFAULT	0x00000000
1051cd76c75SBen Gras #	define LAPIC_DEST_SELF		0x00040000
1061cd76c75SBen Gras #	define LAPIC_DEST_ALLINCL	0x00080000
1071cd76c75SBen Gras #	define LAPIC_DEST_ALLEXCL	0x000c0000
1081cd76c75SBen Gras 
1091cd76c75SBen Gras 
1101cd76c75SBen Gras #define LAPIC_ICRHI	0x310		/* Int. cmd. RW */
1111cd76c75SBen Gras 
1121cd76c75SBen Gras #define LAPIC_LVTT	0x320		/* Loc.vec.(timer) RW */
1131cd76c75SBen Gras #	define LAPIC_LVTT_VEC_MASK	0x000000ff
1141cd76c75SBen Gras #	define LAPIC_LVTT_DS		0x00001000
1151cd76c75SBen Gras #	define LAPIC_LVTT_M		0x00010000
1161cd76c75SBen Gras #	define LAPIC_LVTT_TM		0x00020000
1171cd76c75SBen Gras 
1181cd76c75SBen Gras #define LAPIC_TMINT	0x330		/* Loc.vec (Thermal) */
1191cd76c75SBen Gras #define LAPIC_PCINT	0x340		/* Loc.vec (Perf Mon) */
1201cd76c75SBen Gras #define LAPIC_LVINT0	0x350		/* Loc.vec (LINT0) RW */
1211cd76c75SBen Gras #	define LAPIC_LVT_MASKED		0x00010000
1221cd76c75SBen Gras #	define LAPIC_LVT_LEVTRIG	0x00008000
1231cd76c75SBen Gras #	define LAPIC_LVT_REMOTE_IRR	0x00004000
1241cd76c75SBen Gras #	define LAPIC_INP_POL		0x00002000
1251cd76c75SBen Gras #	define LAPIC_PEND_SEND		0x00001000
1261cd76c75SBen Gras 
1271cd76c75SBen Gras #define LAPIC_LVINT1	0x360		/* Loc.vec (LINT1) RW */
1281cd76c75SBen Gras #define LAPIC_LVERR	0x370		/* Loc.vec (ERROR) RW */
1291cd76c75SBen Gras #define LAPIC_ICR_TIMER	0x380		/* Initial count RW */
1301cd76c75SBen Gras #define LAPIC_CCR_TIMER	0x390		/* Current count RO */
1311cd76c75SBen Gras 
1321cd76c75SBen Gras #define LAPIC_DCR_TIMER	0x3e0		/* Divisor config register */
1331cd76c75SBen Gras #	define LAPIC_DCRT_DIV1		0x0b
1341cd76c75SBen Gras #	define LAPIC_DCRT_DIV2		0x00
1351cd76c75SBen Gras #	define LAPIC_DCRT_DIV4		0x01
1361cd76c75SBen Gras #	define LAPIC_DCRT_DIV8		0x02
1371cd76c75SBen Gras #	define LAPIC_DCRT_DIV16		0x03
1381cd76c75SBen Gras #	define LAPIC_DCRT_DIV32		0x08
1391cd76c75SBen Gras #	define LAPIC_DCRT_DIV64		0x09
1401cd76c75SBen Gras #	define LAPIC_DCRT_DIV128	0x0a
1411cd76c75SBen Gras 
14284d9c625SLionel Sambuc #define LAPIC_MSIADDR_BASE		0xfee00000
14384d9c625SLionel Sambuc #define	LAPIC_MSIADDR_DSTID_MASK	__BITS(19, 12)
14484d9c625SLionel Sambuc #define	LAPIC_MSIADDR_RSVD0_MASK	__BITS(11, 4)
14584d9c625SLionel Sambuc #define	LAPIC_MSIADDR_RH		__BIT(3)
14684d9c625SLionel Sambuc #define	LAPIC_MSIADDR_DM		__BIT(2)
14784d9c625SLionel Sambuc #define	LAPIC_MSIADDR_RSVD1_MASK	__BITS(1, 0)
14884d9c625SLionel Sambuc 
14984d9c625SLionel Sambuc #define	LAPIC_MSIDATA_VECTOR_MASK	__BITS(7, 0)
15084d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_MASK		__BITS(10, 8)
15184d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_FIXED		__SHIFTIN(0, LAPIC_MSIDATA_DM_MASK)
15284d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_LOPRI		__SHIFTIN(1, LAPIC_MSIDATA_DM_MASK)
15384d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_SMI		__SHIFTIN(2, LAPIC_MSIDATA_DM_MASK)
15484d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_RSVD0		__SHIFTIN(3, LAPIC_MSIDATA_DM_MASK)
15584d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_NMI		__SHIFTIN(4, LAPIC_MSIDATA_DM_MASK)
15684d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_INIT		__SHIFTIN(5, LAPIC_MSIDATA_DM_MASK)
15784d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_RSVD1		__SHIFTIN(6, LAPIC_MSIDATA_DM_MASK)
15884d9c625SLionel Sambuc #define	LAPIC_MSIDATA_DM_EXTINT		__SHIFTIN(7, LAPIC_MSIDATA_DM_MASK)
15984d9c625SLionel Sambuc #define	LAPIC_MSIDATA_RSVD0_MASK	__BITS(13, 11)
16084d9c625SLionel Sambuc #define	LAPIC_MSIDATA_LEVEL_MASK	__BIT(14)
16184d9c625SLionel Sambuc #define	LAPIC_MSIDATA_LEVEL_DEASSERT	__SHIFTIN(0, LAPIC_MSIDATA_LEVEL_MASK)
16284d9c625SLionel Sambuc #define	LAPIC_MSIDATA_LEVEL_ASSERT	__SHIFTIN(1, LAPIC_MSIDATA_LEVEL_MASK)
16384d9c625SLionel Sambuc #define	LAPIC_MSIDATA_TRGMODE_MASK	__BIT(15)
16484d9c625SLionel Sambuc #define	LAPIC_MSIDATA_TRGMODE_EDGE	__SHIFTIN(0,LAPIC_MSIDATA_TRGMODE_MASK)
16584d9c625SLionel Sambuc #define	LAPIC_MSIDATA_TRGMODE_LEVEL	__SHIFTIN(1,LAPIC_MSIDATA_TRGMODE_MASK)
16684d9c625SLionel Sambuc #define	LAPIC_MSIDATA_RSVD1_MASK	__BITS(31, 16)
16784d9c625SLionel Sambuc 
1681cd76c75SBen Gras #define LAPIC_BASE		0xfee00000
1691cd76c75SBen Gras 
1701cd76c75SBen Gras #define LAPIC_IRQ_MASK(i)	(1 << ((i) + 1))
1711cd76c75SBen Gras 
1721cd76c75SBen Gras /* Extended APIC registers, valid when CPUID features4 EAPIC is present */
1731cd76c75SBen Gras #define LEAPIC_FR	0x400	/* Feature register */
1741cd76c75SBen Gras #	define LEAPIC_FR_ELC		__BITS(23,16) /* Ext. Lvt Count RO */
1751cd76c75SBen Gras #	define LEAPIC_FR_EIDCAP		__BIT(2)     /* Ext. Apic ID Cap. RO */
1761cd76c75SBen Gras #	define LEAPIC_FR_SEIOCAP	__BIT(1)     /* Specific EOI Cap. RO */
1771cd76c75SBen Gras #	define LEAPIC_FR_IERCAP		__BIT(0)     /* Intr. Enable Reg. RO */
1781cd76c75SBen Gras 
1791cd76c75SBen Gras #define LEAPIC_CR	0x410	/* Control Register */
1801cd76c75SBen Gras #	define LEAPIC_CR_EID_ENABLE	__BIT(2)     /* Ext. Apic ID enable */
1811cd76c75SBen Gras #	define LEAPIC_CR_SEOI_ENABLE	__BIT(1)     /* Specific EOI enable */
1821cd76c75SBen Gras #	define LEAPIC_CR_IER_ENABLE	__BIT(0)     /* Enable writes to IER */
1831cd76c75SBen Gras 
1841cd76c75SBen Gras #define LEAPIC_SEOIR	0x420	/* Specific EOI Register */
1851cd76c75SBen Gras #	define LEAPIC_SEOI_VEC	__BITS(7,0)
1861cd76c75SBen Gras 
1871cd76c75SBen Gras #define LEAPIC_IER_480	0x480	/* Interrupts 0-31 */
1881cd76c75SBen Gras #define LEAPIC_IER_490	0x490	/* Interrupts 32-63 */
1891cd76c75SBen Gras #define LEAPIC_IER_4B0	0x4B0	/* Interrupts 64-95 */
1901cd76c75SBen Gras #define LEAPIC_IER_4C0	0x4C0	/* Interrupts 96-127 */
1911cd76c75SBen Gras #define LEAPIC_IER_4D0	0x4D0	/* Interrupts 128-159 */
1921cd76c75SBen Gras #define LEAPIC_IER_4E0	0x4E0	/* Interrupts 160-191 */
1931cd76c75SBen Gras #define LEAPIC_IER_4F0	0x4F0	/* Interrupts 192-255 */
1941cd76c75SBen Gras 
1951cd76c75SBen Gras /* Extended Local Vector Table Entries */
1961cd76c75SBen Gras #define LEAPIC_LVTR_500	0x500
1971cd76c75SBen Gras #define LEAPIC_LVTR_504	0x504
1981cd76c75SBen Gras #define LEAPIC_LVTR_508	0x508
1991cd76c75SBen Gras #define LEAPIC_LVTR_50C	0x50C
2001cd76c75SBen Gras #define LEAPIC_LVTR_510	0x510
2011cd76c75SBen Gras #define LEAPIC_LVTR_514	0x514
2021cd76c75SBen Gras #define LEAPIC_LVTR_518	0x518
2031cd76c75SBen Gras #define LEAPIC_LVTR_51C	0x51C
2041cd76c75SBen Gras #define LEAPIC_LVTR_520	0x520
2051cd76c75SBen Gras #define LEAPIC_LVTR_524	0x524
2061cd76c75SBen Gras #define LEAPIC_LVTR_528	0x528
2071cd76c75SBen Gras #define LEAPIC_LVTR_52C	0x52C
2081cd76c75SBen Gras #define LEAPIC_LVTR_530	0x530
2091cd76c75SBen Gras #	define LEAPIC_LVTR_MASK		__BIT(16)     /* interrupt masked RW */
2101cd76c75SBen Gras #	define LEAPIC_LVTR_DSTAT	__BIT(12)	/* delivery state RO */
2111cd76c75SBen Gras #	define LEAPIC_LVTR_MSGTYPE	__BITS(10,8)	/* Message type */
2121cd76c75SBen Gras #	define LEAPIC_LVTR_VEC		__BITS(7,0)	/* the intr. vector */
2131cd76c75SBen Gras 
2141cd76c75SBen Gras /*
2151cd76c75SBen Gras  * Model specific registers
2161cd76c75SBen Gras  */
2171cd76c75SBen Gras 
2181cd76c75SBen Gras #define	LAPIC_MSR	0x001b
2191cd76c75SBen Gras #	define	LAPIC_MSR_BSP		0x00000100	/* boot processor */
2201cd76c75SBen Gras #	define	LAPIC_MSR_ENABLE_x2	0x00000400	/* x2APIC mode */
2211cd76c75SBen Gras #	define	LAPIC_MSR_ENABLE	0x00000800	/* software enable */
2221cd76c75SBen Gras #	define	LAPIC_MSR_ADDR		0xfffff000	/* physical address */
2231cd76c75SBen Gras 
224