| 1 | /*	$OpenBSD: i82489var.h,v 1.22 2025/11/12 09:48:52 hshoexer 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_INVEPT			(LAPIC_IPI_OFFSET + 3) |
| 76 | |
| 77 | extern void Xipi_invltlb(void); |
| 78 | extern void Xipi_invltlb_pcid(void); |
| 79 | extern void Xipi_invlpg(void); |
| 80 | extern void Xipi_invlpg_pcid(void); |
| 81 | extern void Xipi_invlrange(void); |
| 82 | extern void Xipi_invlrange_pcid(void); |
| 83 | #if NVMM > 0 |
| 84 | extern void Xipi_invept(void); |
| 85 | #endif /* NVMM > 0 */ |
| 86 | |
| 87 | /* |
| 88 | * Vector used for local apic timer interrupts. |
| 89 | */ |
| 90 | |
| 91 | extern void Xintr_lapic_ltimer(void); |
| 92 | extern void Xresume_lapic_ltimer(void); |
| 93 | extern void Xrecurse_lapic_ltimer(void); |
| 94 | #define LAPIC_TIMER_VECTOR		0xc0 |
| 95 | |
| 96 | /* |
| 97 | * Vector used for Xen HVM Event Channel Interrupts. |
| 98 | */ |
| 99 | extern void Xintr_xen_upcall(void); |
| 100 | extern void Xresume_xen_upcall(void); |
| 101 | extern void Xrecurse_xen_upcall(void); |
| 102 | #define LAPIC_XEN_VECTOR		0x70 |
| 103 | |
| 104 | /* |
| 105 | * Vector used for Hyper-V Interrupts. |
| 106 | */ |
| 107 | extern void Xintr_hyperv_upcall(void); |
| 108 | extern void Xresume_hyperv_upcall(void); |
| 109 | extern void Xrecurse_hyperv_upcall(void); |
| 110 | #define LAPIC_HYPERV_VECTOR		0x71 |
| 111 | |
| 112 | struct cpu_info; |
| 113 | |
| 114 | extern void lapic_boot_init(paddr_t); |
| 115 | extern void lapic_set_lvt(void); |
| 116 | extern void lapic_enable(void); |
| 117 | extern void lapic_disable(void); |
| 118 | extern void lapic_calibrate_timer(struct cpu_info *ci); |
| 119 | extern void lapic_startclock(void); |
| 120 | extern void lapic_initclocks(void); |
| 121 | |
| 122 | #endif |