VirtualBox

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

Last change on this file since 107929 was 107929, checked in by vboxsync, 3 months ago

VMM: GIC: bugref:10404 Renamed some places where GICv3 to GIC, a doxygen fix plus some minor updates. No functional changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
Line 
1/* $Id: GICInternal.h 107929 2025-01-24 09:43:16Z vboxsync $ */
2/** @file
3 * GIC - Generic Interrupt Controller Architecture (GIC).
4 */
5
6/*
7 * Copyright (C) 2023-2024 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#include <VBox/vmm/pdmgic.h>
37#include <VBox/vmm/stam.h>
38
39
40/** @defgroup grp_gic_int Internal
41 * @ingroup grp_gic
42 * @internal
43 * @{
44 */
45
46#ifdef VBOX_INCLUDED_vmm_pdmgic_h
47/** The VirtualBox GIC backend. */
48extern const PDMGICBACKEND g_GicBackend;
49# ifdef RT_OS_DARWIN
50/** The Hypervisor.Framework GIC backend. */
51extern const PDMGICBACKEND g_GicHvfBackend;
52# elif defined(RT_OS_WINDOWS)
53/** The Hyper-V GIC backend. */
54extern const PDMGICBACKEND g_GicHvBackend;
55# endif
56#endif
57
58#define VMCPU_TO_GICCPU(a_pVCpu) (&(a_pVCpu)->gic.s)
59#define VM_TO_GIC(a_pVM) (&(a_pVM)->gic.s)
60#define VM_TO_GICDEV(a_pVM) CTX_SUFF(VM_TO_GIC(a_pVM)->pGicDev)
61#ifdef IN_RING3
62# define VMCPU_TO_DEVINS(a_pVCpu) ((a_pVCpu)->pVMR3->gic.s.pDevInsR3)
63#elif defined(IN_RING0)
64# error "Not implemented!"
65#endif
66
67/** Maximum number of SPI interrupts. */
68#define GIC_SPI_MAX 32
69
70/**
71 * GIC PDM instance data (per-VM).
72 */
73typedef struct GICDEV
74{
75 /** The distributor MMIO handle. */
76 IOMMMIOHANDLE hMmioDist;
77 /** The redistributor MMIO handle. */
78 IOMMMIOHANDLE hMmioReDist;
79
80 /** @name SPI distributor register state.
81 * @{ */
82 /** Interrupt Group 0 Register. */
83 volatile uint32_t u32RegIGrp0;
84 /** Interrupt Configuration Register 0. */
85 volatile uint32_t u32RegICfg0;
86 /** Interrupt Configuration Register 1. */
87 volatile uint32_t u32RegICfg1;
88 /** Interrupt enabled bitmap. */
89 volatile uint32_t bmIntEnabled;
90 /** Current interrupt pending state. */
91 volatile uint32_t bmIntPending;
92 /** The current interrupt active state. */
93 volatile uint32_t bmIntActive;
94 /** The interrupt priority for each of the SGI/PPIs */
95 volatile uint8_t abIntPriority[GIC_SPI_MAX];
96 /** The interrupt routing information. */
97 volatile uint32_t au32IntRouting[GIC_SPI_MAX];
98
99 /** Flag whether group 0 interrupts are currently enabled. */
100 volatile bool fIrqGrp0Enabled;
101 /** Flag whether group 1 interrupts are currently enabled. */
102 volatile bool fIrqGrp1Enabled;
103 /** @} */
104
105 /** @name Configurables.
106 * @{ */
107 /** The GICD_TYPER.ItsLinesNumber bits. */
108 uint16_t uItLinesNumber;
109 /** @} */
110} GICDEV;
111/** Pointer to a GIC device. */
112typedef GICDEV *PGICDEV;
113/** Pointer to a const GIC device. */
114typedef GICDEV const *PCGICDEV;
115
116
117/**
118 * GIC VM Instance data.
119 */
120typedef struct GIC
121{
122 /** The ring-3 device instance. */
123 PPDMDEVINSR3 pDevInsR3;
124} GIC;
125/** Pointer to GIC VM instance data. */
126typedef GIC *PGIC;
127/** Pointer to const GIC VM instance data. */
128typedef GIC const *PCGIC;
129AssertCompileSizeAlignment(GIC, 8);
130
131/**
132 * GIC VMCPU Instance data.
133 */
134typedef struct GICCPU
135{
136 /** @name The per vCPU redistributor data is kept here.
137 * @{ */
138 /** @} */
139
140 /** @name Physical LPI register state.
141 * @{ */
142 /** @} */
143
144 /** @name SGI and PPI redistributor register state.
145 * @{ */
146 /** Interrupt Group 0 Register. */
147 volatile uint32_t u32RegIGrp0;
148 /** Interrupt Configuration Register 0. */
149 volatile uint32_t u32RegICfg0;
150 /** Interrupt Configuration Register 1. */
151 volatile uint32_t u32RegICfg1;
152 /** Interrupt enabled bitmap. */
153 volatile uint32_t bmIntEnabled;
154 /** Current interrupt pending state. */
155 volatile uint32_t bmIntPending;
156 /** The current interrupt active state. */
157 volatile uint32_t bmIntActive;
158 /** The interrupt priority for each of the SGI/PPIs */
159 volatile uint8_t abIntPriority[GIC_INTID_RANGE_PPI_LAST + 1];
160 /** @} */
161
162 /** @name ICC system register state.
163 * @{ */
164 /** Flag whether group 0 interrupts are currently enabled. */
165 volatile bool fIrqGrp0Enabled;
166 /** Flag whether group 1 interrupts are currently enabled. */
167 volatile bool fIrqGrp1Enabled;
168 /** The current interrupt priority, only interrupts with a higher priority get signalled. */
169 volatile uint8_t bInterruptPriority;
170 /** The interrupt controller Binary Point Register for Group 0 interrupts. */
171 uint8_t bBinaryPointGrp0;
172 /** The interrupt controller Binary Point Register for Group 1 interrupts. */
173 uint8_t bBinaryPointGrp1;
174 /** The running poriorities caused by preemption. */
175 volatile uint8_t abRunningPriorities[256];
176 /** The index to the current running priority. */
177 volatile uint8_t idxRunningPriority;
178 /** @} */
179
180 /** @name Log Max counters
181 * @{ */
182 uint32_t cLogMaxAccessError;
183 uint32_t cLogMaxSetApicBaseAddr;
184 uint32_t cLogMaxGetApicBaseAddr;
185 uint32_t uAlignment4;
186 /** @} */
187
188 /** @name APIC statistics.
189 * @{ */
190#ifdef VBOX_WITH_STATISTICS
191 /** Number of MMIO reads in R3. */
192 STAMCOUNTER StatMmioReadR3;
193 /** Number of MMIO writes in R3. */
194 STAMCOUNTER StatMmioWriteR3;
195 /** Number of MSR reads in R3. */
196 STAMCOUNTER StatSysRegReadR3;
197 /** Number of MSR writes in R3. */
198 STAMCOUNTER StatSysRegWriteR3;
199
200# if 0 /* No R0 for now. */
201 /** Number of MMIO reads in RZ. */
202 STAMCOUNTER StatMmioReadRZ;
203 /** Number of MMIO writes in RZ. */
204 STAMCOUNTER StatMmioWriteRZ;
205 /** Number of MSR reads in RZ. */
206 STAMCOUNTER StatSysRegReadRZ;
207 /** Number of MSR writes in RZ. */
208 STAMCOUNTER StatSysRegWriteRZ;
209# endif
210#endif
211 /** @} */
212} GICCPU;
213/** Pointer to GIC VMCPU instance data. */
214typedef GICCPU *PGICCPU;
215/** Pointer to a const GIC VMCPU instance data. */
216typedef GICCPU const *PCGICCPU;
217
218DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
219DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
220
221DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
222DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
223
224DECLHIDDEN(void) gicResetCpu(PVMCPUCC pVCpu);
225
226DECLCALLBACK(int) gicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg);
227DECLCALLBACK(int) gicR3Destruct(PPDMDEVINS pDevIns);
228DECLCALLBACK(void) gicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
229DECLCALLBACK(void) gicR3Reset(PPDMDEVINS pDevIns);
230
231/** @} */
232
233#endif /* !VMM_INCLUDED_SRC_include_GICInternal_h */
234
Note: See TracBrowser for help on using the repository browser.

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