xref: /openbsd-src/sys/arch/amd64/include/i82489var.h (revision daa3eda44bf2dacfe28170fc0af9c44a2cfcc969)
1 /*	$OpenBSD: i82489var.h,v 1.21 2024/11/07 17:24:42 bluhm 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 #include "vmm.h"
37 
38 /*
39  * Software definitions belonging to Local APIC driver.
40  */
41 
42 #ifdef _KERNEL
43 extern volatile u_int32_t local_apic[];
44 extern volatile u_int32_t lapic_tpr;
45 #endif
46 
47 extern u_int32_t (*lapic_readreg)(int);
48 extern void (*lapic_writereg)(int, u_int32_t);
49 u_int32_t lapic_cpu_number(void);
50 
51 /*
52  * "spurious interrupt vector"; vector used by interrupt which was
53  * aborted because the CPU masked it after it happened but before it
54  * was delivered.. "Oh, sorry, i caught you at a bad time".
55  * Low-order 4 bits must be all ones.
56  */
57 extern void Xintrspurious(void);
58 #define LAPIC_SPURIOUS_VECTOR		0xef
59 
60 /*
61  * Vector used for inter-processor interrupts.
62  */
63 extern void Xintr_lapic_ipi(void);
64 extern void Xrecurse_lapic_ipi(void);
65 extern void Xresume_lapic_ipi(void);
66 #define LAPIC_IPI_VECTOR			0xe0
67 
68 /*
69  * We take 0xf0-0xfe for fast IPI handlers.
70  */
71 #define LAPIC_IPI_OFFSET			0xf0
72 #define LAPIC_IPI_INVLTLB			(LAPIC_IPI_OFFSET + 0)
73 #define LAPIC_IPI_INVLPG			(LAPIC_IPI_OFFSET + 1)
74 #define LAPIC_IPI_INVLRANGE			(LAPIC_IPI_OFFSET + 2)
75 #define LAPIC_IPI_WBINVD			(LAPIC_IPI_OFFSET + 3)
76 #define LAPIC_IPI_INVEPT			(LAPIC_IPI_OFFSET + 4)
77 
78 extern void Xipi_invltlb(void);
79 extern void Xipi_invltlb_pcid(void);
80 extern void Xipi_invlpg(void);
81 extern void Xipi_invlpg_pcid(void);
82 extern void Xipi_invlrange(void);
83 extern void Xipi_invlrange_pcid(void);
84 extern void Xipi_wbinvd(void);
85 #if NVMM > 0
86 extern void Xipi_invept(void);
87 #endif /* NVMM > 0 */
88 
89 /*
90  * Vector used for local apic timer interrupts.
91  */
92 
93 extern void Xintr_lapic_ltimer(void);
94 extern void Xresume_lapic_ltimer(void);
95 extern void Xrecurse_lapic_ltimer(void);
96 #define LAPIC_TIMER_VECTOR		0xc0
97 
98 /*
99  * Vector used for Xen HVM Event Channel Interrupts.
100  */
101 extern void Xintr_xen_upcall(void);
102 extern void Xresume_xen_upcall(void);
103 extern void Xrecurse_xen_upcall(void);
104 #define LAPIC_XEN_VECTOR		0x70
105 
106 /*
107  * Vector used for Hyper-V Interrupts.
108  */
109 extern void Xintr_hyperv_upcall(void);
110 extern void Xresume_hyperv_upcall(void);
111 extern void Xrecurse_hyperv_upcall(void);
112 #define LAPIC_HYPERV_VECTOR		0x71
113 
114 struct cpu_info;
115 
116 extern void lapic_boot_init(paddr_t);
117 extern void lapic_set_lvt(void);
118 extern void lapic_enable(void);
119 extern void lapic_disable(void);
120 extern void lapic_calibrate_timer(struct cpu_info *ci);
121 extern void lapic_startclock(void);
122 extern void lapic_initclocks(void);
123 
124 #endif
125