VirtualBox

source: vbox/trunk/src/VBox/VMM/include/GICInternal.h@ 106054

Last change on this file since 106054 was 105687, checked in by vboxsync, 4 months ago

VMMArm/GIC: Rename GICR3Kvm to GICR3Nem and add a stub for macOS Hypervisor.framework which will be handled by the NEM backend directly due to the hv_gic_* API being entangled with the rest of the hv_* API, bugref:10747

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1/* $Id: GICInternal.h 105687 2024-08-15 12:45:46Z vboxsync $ */
2/** @file
3 * GIC - Generic Interrupt Controller Architecture (GICv3).
4 */
5
6/*
7 * Copyright (C) 2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VMM_INCLUDED_SRC_include_GICInternal_h
29#define VMM_INCLUDED_SRC_include_GICInternal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/gic.h>
35#include <VBox/vmm/pdmdev.h>
36
37
38/** @defgroup grp_gic_int Internal
39 * @ingroup grp_gic
40 * @internal
41 * @{
42 */
43
44#define VMCPU_TO_GICCPU(a_pVCpu) (&(a_pVCpu)->gic.s)
45#define VM_TO_GIC(a_pVM) (&(a_pVM)->gic.s)
46#define VM_TO_GICDEV(a_pVM) CTX_SUFF(VM_TO_GIC(a_pVM)->pGicDev)
47#ifdef IN_RING3
48# define VMCPU_TO_DEVINS(a_pVCpu) ((a_pVCpu)->pVMR3->gic.s.pDevInsR3)
49#elif defined(IN_RING0)
50# error "Not implemented!"
51#endif
52
53/** Maximum number of SPI interrupts. */
54#define GIC_SPI_MAX 32
55
56/**
57 * GIC PDM instance data (per-VM).
58 */
59typedef struct GICDEV
60{
61 /** The distributor MMIO handle. */
62 IOMMMIOHANDLE hMmioDist;
63 /** The redistributor MMIO handle. */
64 IOMMMIOHANDLE hMmioReDist;
65
66 /** @name SPI distributor register state.
67 * @{ */
68 /** Interrupt Group 0 Register. */
69 volatile uint32_t u32RegIGrp0;
70 /** Interrupt Configuration Register 0. */
71 volatile uint32_t u32RegICfg0;
72 /** Interrupt Configuration Register 1. */
73 volatile uint32_t u32RegICfg1;
74 /** Interrupt enabled bitmap. */
75 volatile uint32_t bmIntEnabled;
76 /** Current interrupt pending state. */
77 volatile uint32_t bmIntPending;
78 /** The current interrupt active state. */
79 volatile uint32_t bmIntActive;
80 /** The interrupt priority for each of the SGI/PPIs */
81 volatile uint8_t abIntPriority[GIC_SPI_MAX];
82
83 /** Flag whether group 0 interrupts are currently enabled. */
84 volatile bool fIrqGrp0Enabled;
85 /** Flag whether group 1 interrupts are currently enabled. */
86 volatile bool fIrqGrp1Enabled;
87 /** @} */
88
89} GICDEV;
90/** Pointer to a GIC device. */
91typedef GICDEV *PGICDEV;
92/** Pointer to a const GIC device. */
93typedef GICDEV const *PCGICDEV;
94
95
96/**
97 * GIC VM Instance data.
98 */
99typedef struct GIC
100{
101 /** The ring-3 device instance. */
102 PPDMDEVINSR3 pDevInsR3;
103 /** Flag whether the GIC provided by NEM is used. */
104 bool fNemGic;
105} GIC;
106/** Pointer to GIC VM instance data. */
107typedef GIC *PGIC;
108/** Pointer to const GIC VM instance data. */
109typedef GIC const *PCGIC;
110AssertCompileSizeAlignment(GIC, 8);
111
112/**
113 * GIC VMCPU Instance data.
114 */
115typedef struct GICCPU
116{
117 /** @name The per vCPU redistributor data is kept here.
118 * @{ */
119
120 /** @name Physical LPI register state.
121 * @{ */
122 /** @} */
123
124 /** @name SGI and PPI redistributor register state.
125 * @{ */
126 /** Interrupt Group 0 Register. */
127 volatile uint32_t u32RegIGrp0;
128 /** Interrupt Configuration Register 0. */
129 volatile uint32_t u32RegICfg0;
130 /** Interrupt Configuration Register 1. */
131 volatile uint32_t u32RegICfg1;
132 /** Interrupt enabled bitmap. */
133 volatile uint32_t bmIntEnabled;
134 /** Current interrupt pending state. */
135 volatile uint32_t bmIntPending;
136 /** The current interrupt active state. */
137 volatile uint32_t bmIntActive;
138 /** The interrupt priority for each of the SGI/PPIs */
139 volatile uint8_t abIntPriority[GIC_INTID_RANGE_PPI_LAST + 1];
140 /** @} */
141
142 /** @name ICC system register state.
143 * @{ */
144 /** Flag whether group 0 interrupts are currently enabled. */
145 volatile bool fIrqGrp0Enabled;
146 /** Flag whether group 1 interrupts are currently enabled. */
147 volatile bool fIrqGrp1Enabled;
148 /** The current interrupt priority, only interrupts with a higher priority get signalled. */
149 volatile uint8_t bInterruptPriority;
150 /** The interrupt controller Binary Point Register for Group 0 interrupts. */
151 uint8_t bBinaryPointGrp0;
152 /** The interrupt controller Binary Point Register for Group 1 interrupts. */
153 uint8_t bBinaryPointGrp1;
154 /** The running poriorities caused by preemption. */
155 volatile uint8_t abRunningPriorities[256];
156 /** The index to the current running priority. */
157 volatile uint8_t idxRunningPriority;
158 /** @} */
159
160 /** @name Log Max counters
161 * @{ */
162 uint32_t cLogMaxAccessError;
163 uint32_t cLogMaxSetApicBaseAddr;
164 uint32_t cLogMaxGetApicBaseAddr;
165 uint32_t uAlignment4;
166 /** @} */
167
168 /** @name APIC statistics.
169 * @{ */
170#ifdef VBOX_WITH_STATISTICS
171 /** Number of MMIO reads in R3. */
172 STAMCOUNTER StatMmioReadR3;
173 /** Number of MMIO writes in R3. */
174 STAMCOUNTER StatMmioWriteR3;
175 /** Number of MSR reads in R3. */
176 STAMCOUNTER StatSysRegReadR3;
177 /** Number of MSR writes in R3. */
178 STAMCOUNTER StatSysRegWriteR3;
179
180# if 0 /* No R0 for now. */
181 /** Number of MMIO reads in RZ. */
182 STAMCOUNTER StatMmioReadRZ;
183 /** Number of MMIO writes in RZ. */
184 STAMCOUNTER StatMmioWriteRZ;
185 /** Number of MSR reads in RZ. */
186 STAMCOUNTER StatSysRegReadRZ;
187 /** Number of MSR writes in RZ. */
188 STAMCOUNTER StatSysRegWriteRZ;
189# endif
190#endif
191 /** @} */
192} GICCPU;
193/** Pointer to GIC VMCPU instance data. */
194typedef GICCPU *PGICCPU;
195/** Pointer to a const GIC VMCPU instance data. */
196typedef GICCPU const *PCGICCPU;
197
198DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
199DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
200
201DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
202DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
203
204DECLHIDDEN(void) gicResetCpu(PVMCPUCC pVCpu);
205
206DECLCALLBACK(int) gicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg);
207DECLCALLBACK(int) gicR3Destruct(PPDMDEVINS pDevIns);
208DECLCALLBACK(void) gicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
209DECLCALLBACK(void) gicR3Reset(PPDMDEVINS pDevIns);
210
211/** @} */
212
213#endif /* !VMM_INCLUDED_SRC_include_GICInternal_h */
214
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette