xref: /openbsd-src/sys/arch/amd64/include/i82489var.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: i82489var.h,v 1.17 2016/06/22 01:12:38 mikeb Exp $	*/
2 /*	$NetBSD: i82489var.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $	*/
3 
4 /*-
5  * Copyright (c) 1998 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Frank van der Linden.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _MACHINE_I82489VAR_H_
34 #define _MACHINE_I82489VAR_H_
35 
36 /*
37  * Software definitions belonging to Local APIC driver.
38  */
39 
40 #ifdef _KERNEL
41 extern volatile u_int32_t local_apic[];
42 extern volatile u_int32_t lapic_tpr;
43 #endif
44 
45 extern u_int32_t (*lapic_readreg)(int);
46 extern void (*lapic_writereg)(int, u_int32_t);
47 u_int32_t lapic_cpu_number(void);
48 
49 /*
50  * "spurious interrupt vector"; vector used by interrupt which was
51  * aborted because the CPU masked it after it happened but before it
52  * was delivered.. "Oh, sorry, i caught you at a bad time".
53  * Low-order 4 bits must be all ones.
54  */
55 extern void Xintrspurious(void);
56 #define LAPIC_SPURIOUS_VECTOR		0xef
57 
58 /*
59  * Vector used for inter-processor interrupts.
60  */
61 extern void Xintr_lapic_ipi(void);
62 extern void Xrecurse_lapic_ipi(void);
63 extern void Xresume_lapic_ipi(void);
64 #define LAPIC_IPI_VECTOR			0xe0
65 
66 /*
67  * We take 0xf0-0xfe for fast IPI handlers.
68  */
69 #define LAPIC_IPI_OFFSET			0xf0
70 #define LAPIC_IPI_INVLTLB			(LAPIC_IPI_OFFSET + 0)
71 #define LAPIC_IPI_INVLPG			(LAPIC_IPI_OFFSET + 1)
72 #define LAPIC_IPI_INVLRANGE			(LAPIC_IPI_OFFSET + 2)
73 
74 extern void Xipi_invltlb(void);
75 extern void Xipi_invlpg(void);
76 extern void Xipi_invlrange(void);
77 
78 /*
79  * Vector used for local apic timer interrupts.
80  */
81 
82 extern void Xintr_lapic_ltimer(void);
83 extern void Xresume_lapic_ltimer(void);
84 extern void Xrecurse_lapic_ltimer(void);
85 #define LAPIC_TIMER_VECTOR		0xc0
86 
87 /*
88  * 'pin numbers' for local APIC
89  */
90 #define LAPIC_PIN_TIMER		0
91 #define LAPIC_PIN_PCINT		2
92 #define LAPIC_PIN_LVINT0	3
93 #define LAPIC_PIN_LVINT1	4
94 #define LAPIC_PIN_LVERR		5
95 
96 extern void Xintr_lapic0(void);
97 extern void Xintr_lapic2(void);
98 extern void Xintr_lapic3(void);
99 extern void Xintr_lapic4(void);
100 extern void Xintr_lapic5(void);
101 
102 /*
103  * Vector used for Xen HVM Event Channel Interrupts.
104  */
105 extern void Xintr_xen_upcall(void);
106 extern void Xresume_xen_upcall(void);
107 extern void Xrecurse_xen_upcall(void);
108 #define LAPIC_XEN_VECTOR		0x70
109 
110 /*
111  * Vector used for Hyper-V Interrupts.
112  */
113 extern void Xintr_hyperv_upcall(void);
114 extern void Xresume_hyperv_upcall(void);
115 extern void Xrecurse_hyperv_upcall(void);
116 #define LAPIC_HYPERV_VECTOR		0x71
117 
118 struct cpu_info;
119 
120 extern void lapic_boot_init(paddr_t);
121 extern void lapic_set_lvt(void);
122 extern void lapic_enable(void);
123 extern void lapic_disable(void);
124 extern void lapic_calibrate_timer(struct cpu_info *ci);
125 extern void lapic_startclock(void);
126 extern void lapic_initclocks(void);
127 
128 #endif
129