xref: /openbsd-src/sys/arch/i386/include/i82093reg.h (revision 8162193374858e8d7dceca506657f13b21b8be44)
1*81621933Sguenther /*	$OpenBSD: i82093reg.h,v 1.6 2022/12/08 01:25:45 guenther Exp $	*/
2012ea299Sniklas /* $NetBSD: i82093reg.h,v 1.1.2.2 2000/02/21 18:54:07 sommerfeld Exp $ */
3012ea299Sniklas 
4012ea299Sniklas /*-
5012ea299Sniklas  * Copyright (c) 2000 The NetBSD Foundation, Inc.
6012ea299Sniklas  * All rights reserved.
7012ea299Sniklas  *
8012ea299Sniklas  * This code is derived from software contributed to The NetBSD Foundation
9012ea299Sniklas  * by RedBack Networks Inc.
10012ea299Sniklas  *
11012ea299Sniklas  * Author: Bill Sommerfeld
12012ea299Sniklas  *
13012ea299Sniklas  * Redistribution and use in source and binary forms, with or without
14012ea299Sniklas  * modification, are permitted provided that the following conditions
15012ea299Sniklas  * are met:
16012ea299Sniklas  * 1. Redistributions of source code must retain the above copyright
17012ea299Sniklas  *    notice, this list of conditions and the following disclaimer.
18012ea299Sniklas  * 2. Redistributions in binary form must reproduce the above copyright
19012ea299Sniklas  *    notice, this list of conditions and the following disclaimer in the
20012ea299Sniklas  *    documentation and/or other materials provided with the distribution.
21012ea299Sniklas  *
22012ea299Sniklas  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23012ea299Sniklas  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24012ea299Sniklas  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25012ea299Sniklas  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26012ea299Sniklas  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27012ea299Sniklas  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28012ea299Sniklas  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29012ea299Sniklas  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30012ea299Sniklas  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31012ea299Sniklas  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32012ea299Sniklas  * POSSIBILITY OF SUCH DAMAGE.
33012ea299Sniklas  */
34012ea299Sniklas 
35012ea299Sniklas /*
36012ea299Sniklas  * Typically, the first apic lives here.
37012ea299Sniklas  */
38012ea299Sniklas #define IOAPIC_BASE_DEFAULT	0xfec00000
39012ea299Sniklas 
40012ea299Sniklas /*
41012ea299Sniklas  * Memory-space registers.
42012ea299Sniklas  */
43012ea299Sniklas 
44012ea299Sniklas /*
45012ea299Sniklas  * The externally visible registers are all 32 bits wide;
46012ea299Sniklas  * store the register number of interest in IOAPIC_REG, and store/fetch
47012ea299Sniklas  * the real value in IOAPIC_DATA.
48012ea299Sniklas  */
49012ea299Sniklas #define	IOAPIC_REG		0x0000
50012ea299Sniklas #define IOAPIC_DATA		0x0010
51012ea299Sniklas 
52012ea299Sniklas /*
53012ea299Sniklas  * Internal I/O APIC registers.
54012ea299Sniklas  */
55012ea299Sniklas 
56012ea299Sniklas #define IOAPIC_ID		0x00
57012ea299Sniklas 
58012ea299Sniklas #define 	IOAPIC_ID_SHIFT		24
59012ea299Sniklas #define		IOAPIC_ID_MASK		0x0f000000
60012ea299Sniklas 
61012ea299Sniklas /* Version, and maximum interrupt pin number. */
62012ea299Sniklas 
63012ea299Sniklas #define IOAPIC_VER		0x01
64012ea299Sniklas 
65012ea299Sniklas #define		IOAPIC_VER_SHIFT		0
66012ea299Sniklas #define		IOAPIC_VER_MASK			0x000000ff
67012ea299Sniklas 
68012ea299Sniklas #define		IOAPIC_MAX_SHIFT	       	16
69012ea299Sniklas #define		IOAPIC_MAX_MASK	       	0x00ff0000
70012ea299Sniklas 
71012ea299Sniklas /*
72012ea299Sniklas  * Arbitration ID.  Same format as IOAPIC_ID register.
73012ea299Sniklas  */
74012ea299Sniklas #define IOAPIC_ARB		0x02
75012ea299Sniklas 
76012ea299Sniklas /*
77012ea299Sniklas  * Redirection table registers.
78012ea299Sniklas  */
79012ea299Sniklas 
80012ea299Sniklas #define IOAPIC_REDHI(pin)	(0x11 + ((pin)<<1))
81012ea299Sniklas #define IOAPIC_REDLO(pin)	(0x10 + ((pin)<<1))
82012ea299Sniklas 
83012ea299Sniklas #define IOAPIC_REDHI_DEST_SHIFT		24	   /* destination. */
84012ea299Sniklas #define IOAPIC_REDHI_DEST_MASK		0xff000000
85012ea299Sniklas 
86012ea299Sniklas #define IOAPIC_REDLO_MASK		0x00010000 /* 0=enabled; 1=masked */
87012ea299Sniklas 
88012ea299Sniklas #define IOAPIC_REDLO_LEVEL		0x00008000 /* 0=edge, 1=level */
89012ea299Sniklas #define IOAPIC_REDLO_RIRR		0x00004000 /* remote IRR; read only */
90012ea299Sniklas #define IOAPIC_REDLO_ACTLO		0x00002000 /* 0=act. hi; 1=act. lo */
91012ea299Sniklas #define IOAPIC_REDLO_DELSTS		0x00001000 /* 0=idle; 1=send pending */
92012ea299Sniklas #define IOAPIC_REDLO_DSTMOD		0x00000800 /* 0=physical; 1=logical */
93012ea299Sniklas 
94012ea299Sniklas #define IOAPIC_REDLO_DEL_MASK		0x00000700 /* del. mode mask */
95012ea299Sniklas #define IOAPIC_REDLO_DEL_SHIFT		8
96012ea299Sniklas 
97012ea299Sniklas #define IOAPIC_REDLO_DEL_FIXED		0
98012ea299Sniklas #define IOAPIC_REDLO_DEL_LOPRI		1
99012ea299Sniklas #define IOAPIC_REDLO_DEL_SMI		2
100012ea299Sniklas #define IOAPIC_REDLO_DEL_NMI		4
101012ea299Sniklas #define IOAPIC_REDLO_DEL_INIT		5
102012ea299Sniklas #define IOAPIC_REDLO_DEL_EXTINT		7
103012ea299Sniklas 
104012ea299Sniklas #define IOAPIC_REDLO_VECTOR_MASK	0x000000ff /* delivery vector */
105012ea299Sniklas 
106012ea299Sniklas #define IMCR_ADDR		0x22
107012ea299Sniklas #define IMCR_DATA		0x23
108012ea299Sniklas 
109012ea299Sniklas #define IMCR_REGISTER		0x70
110012ea299Sniklas #define		IMCR_PIC	0x00
111012ea299Sniklas #define 	IMCR_APIC	0x01
112012ea299Sniklas 
113e67a626dSderaadt #ifdef _KERNEL
114e67a626dSderaadt 
115012ea299Sniklas #define ioapic_asm_ack(num) \
116*81621933Sguenther 	movl	$0,local_apic + LAPIC_EOI
117e67a626dSderaadt 
118e67a626dSderaadt #endif
119