1 | /** @file
|
---|
2 | * APIC - Advanced Programmable Interrupt Controller.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef VBOX_INCLUDED_vmm_apic_h
|
---|
37 | #define VBOX_INCLUDED_vmm_apic_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <VBox/types.h>
|
---|
43 | #include <VBox/apic.h>
|
---|
44 | struct PDMDEVREGCB;
|
---|
45 |
|
---|
46 | /** @defgroup grp_apic The local APIC VMM API
|
---|
47 | * @ingroup grp_vmm
|
---|
48 | * @{
|
---|
49 | */
|
---|
50 |
|
---|
51 | RT_C_DECLS_BEGIN
|
---|
52 |
|
---|
53 | #ifdef VBOX_INCLUDED_vmm_pdmdev_h
|
---|
54 | extern const PDMDEVREG g_DeviceAPIC;
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | /* These functions are exported as they are called from external modules (recompiler). */
|
---|
58 | VMMDECL(void) APICUpdatePendingInterrupts(PVMCPUCC pVCpu);
|
---|
59 | VMMDECL(int) APICGetTpr(PCVMCPUCC pVCpu, uint8_t *pu8Tpr, bool *pfPending, uint8_t *pu8PendingIntr);
|
---|
60 | VMMDECL(int) APICSetTpr(PVMCPUCC pVCpu, uint8_t u8Tpr);
|
---|
61 |
|
---|
62 | /* These functions are VMM internal. */
|
---|
63 | VMM_INT_DECL(bool) APICIsEnabled(PCVMCPUCC pVCpu);
|
---|
64 | VMM_INT_DECL(bool) APICGetHighestPendingInterrupt(PVMCPUCC pVCpu, uint8_t *pu8PendingIntr);
|
---|
65 | VMM_INT_DECL(bool) APICQueueInterruptToService(PVMCPUCC pVCpu, uint8_t u8PendingIntr);
|
---|
66 | VMM_INT_DECL(void) APICDequeueInterruptFromService(PVMCPUCC pVCpu, uint8_t u8PendingIntr);
|
---|
67 | VMM_INT_DECL(VBOXSTRICTRC) APICReadMsr(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t *pu64Value);
|
---|
68 | VMM_INT_DECL(VBOXSTRICTRC) APICWriteMsr(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t u64Value);
|
---|
69 | VMM_INT_DECL(int) APICGetTimerFreq(PVMCC pVM, uint64_t *pu64Value);
|
---|
70 | VMM_INT_DECL(VBOXSTRICTRC) APICLocalInterrupt(PVMCPUCC pVCpu, uint8_t u8Pin, uint8_t u8Level, int rcRZ);
|
---|
71 | VMM_INT_DECL(uint64_t) APICGetBaseMsrNoCheck(PCVMCPUCC pVCpu);
|
---|
72 | VMM_INT_DECL(VBOXSTRICTRC) APICGetBaseMsr(PVMCPUCC pVCpu, uint64_t *pu64Value);
|
---|
73 | VMM_INT_DECL(int) APICSetBaseMsr(PVMCPUCC pVCpu, uint64_t u64BaseMsr);
|
---|
74 | VMM_INT_DECL(int) APICGetInterrupt(PVMCPUCC pVCpu, uint8_t *pu8Vector, uint32_t *pu32TagSrc);
|
---|
75 | VMM_INT_DECL(int) APICBusDeliver(PVMCC pVM, uint8_t uDest, uint8_t uDestMode, uint8_t uDeliveryMode, uint8_t uVector,
|
---|
76 | uint8_t uPolarity, uint8_t uTriggerMode, uint32_t uTagSrc);
|
---|
77 | VMM_INT_DECL(int) APICGetApicPageForCpu(PCVMCPUCC pVCpu, PRTHCPHYS pHCPhys, PRTR0PTR pR0Ptr, PRTR3PTR pR3Ptr);
|
---|
78 |
|
---|
79 | /** @name Hyper-V interface (Ring-3 and all-context API).
|
---|
80 | * @{ */
|
---|
81 | #ifdef IN_RING3
|
---|
82 | VMMR3_INT_DECL(void) APICR3HvSetCompatMode(PVM pVM, bool fHyperVCompatMode);
|
---|
83 | #endif
|
---|
84 | VMM_INT_DECL(void) APICHvSendInterrupt(PVMCPUCC pVCpu, uint8_t uVector, bool fAutoEoi, XAPICTRIGGERMODE enmTriggerMode);
|
---|
85 | VMM_INT_DECL(VBOXSTRICTRC) APICHvSetTpr(PVMCPUCC pVCpu, uint8_t uTpr);
|
---|
86 | VMM_INT_DECL(uint8_t) APICHvGetTpr(PVMCPUCC pVCpu);
|
---|
87 | VMM_INT_DECL(VBOXSTRICTRC) APICHvSetIcr(PVMCPUCC pVCpu, uint64_t uIcr);
|
---|
88 | VMM_INT_DECL(uint64_t) APICHvGetIcr(PVMCPUCC pVCpu);
|
---|
89 | VMM_INT_DECL(VBOXSTRICTRC) APICHvSetEoi(PVMCPUCC pVCpu, uint32_t uEoi);
|
---|
90 | /** @} */
|
---|
91 |
|
---|
92 | #ifdef IN_RING3
|
---|
93 | /** @defgroup grp_apic_r3 The APIC Host Context Ring-3 API
|
---|
94 | * @{
|
---|
95 | */
|
---|
96 | VMMR3_INT_DECL(int) APICR3RegisterDevice(struct PDMDEVREGCB *pCallbacks);
|
---|
97 | VMMR3_INT_DECL(void) APICR3InitIpi(PVMCPU pVCpu);
|
---|
98 | VMMR3_INT_DECL(void) APICR3HvEnable(PVM pVM);
|
---|
99 | /** @} */
|
---|
100 | #endif /* IN_RING3 */
|
---|
101 |
|
---|
102 | RT_C_DECLS_END
|
---|
103 |
|
---|
104 | /** @} */
|
---|
105 |
|
---|
106 | #endif /* !VBOX_INCLUDED_vmm_apic_h */
|
---|
107 |
|
---|