VirtualBox

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

Last change on this file since 107984 was 107984, checked in by vboxsync, 3 weeks ago

VMM/GIC: bugref:10404 CFGM bits.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1/* $Id: GICInternal.h 107984 2025-01-30 06:43:18Z 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 GIC architecture (GICD_PIDR2.ArchRev and GICR_PIDR2.ArchRev). */
108 uint8_t uArchRev;
109 /** Extended PPIs supported (GICR_TYPER.PpiNum). */
110 uint8_t fPpiNum;
111 /** Whether extended SPIs are supported (GICD_TYPER.ESPI). */
112 bool fExtSpi;
113 /** Whether NMIs are supported (GICD_TYPER.NMI). */
114 bool fNmi;
115 /** The maximum SPI supported (GICD_TYPER.ItsLinesNumber). */
116 uint16_t uMaxSpi;
117 /** Maximum extended SPI supported (GICR_TYPER.ESPI_range). */
118 uint16_t uMaxExtSpi;
119 /** @} */
120} GICDEV;
121/** Pointer to a GIC device. */
122typedef GICDEV *PGICDEV;
123/** Pointer to a const GIC device. */
124typedef GICDEV const *PCGICDEV;
125
126
127/**
128 * GIC VM Instance data.
129 */
130typedef struct GIC
131{
132 /** The ring-3 device instance. */
133 PPDMDEVINSR3 pDevInsR3;
134} GIC;
135/** Pointer to GIC VM instance data. */
136typedef GIC *PGIC;
137/** Pointer to const GIC VM instance data. */
138typedef GIC const *PCGIC;
139AssertCompileSizeAlignment(GIC, 8);
140
141/**
142 * GIC VMCPU Instance data.
143 */
144typedef struct GICCPU
145{
146 /** @name The per vCPU redistributor data is kept here.
147 * @{ */
148 /** @} */
149
150 /** @name Physical LPI register state.
151 * @{ */
152 /** @} */
153
154 /** @name SGI and PPI redistributor register state.
155 * @{ */
156 /** Interrupt Group 0 Register. */
157 volatile uint32_t u32RegIGrp0;
158 /** Interrupt Configuration Register 0. */
159 volatile uint32_t u32RegICfg0;
160 /** Interrupt Configuration Register 1. */
161 volatile uint32_t u32RegICfg1;
162 /** Interrupt enabled bitmap. */
163 volatile uint32_t bmIntEnabled;
164 /** Current interrupt pending state. */
165 volatile uint32_t bmIntPending;
166 /** The current interrupt active state. */
167 volatile uint32_t bmIntActive;
168 /** The interrupt priority for each of the SGI/PPIs */
169 volatile uint8_t abIntPriority[GIC_INTID_RANGE_PPI_LAST + 1];
170 /** @} */
171
172 /** @name ICC system register state.
173 * @{ */
174 /** Flag whether group 0 interrupts are currently enabled. */
175 volatile bool fIrqGrp0Enabled;
176 /** Flag whether group 1 interrupts are currently enabled. */
177 volatile bool fIrqGrp1Enabled;
178 /** The current interrupt priority, only interrupts with a higher priority get signalled. */
179 volatile uint8_t bInterruptPriority;
180 /** The interrupt controller Binary Point Register for Group 0 interrupts. */
181 uint8_t bBinaryPointGrp0;
182 /** The interrupt controller Binary Point Register for Group 1 interrupts. */
183 uint8_t bBinaryPointGrp1;
184 /** The running priorities caused by preemption. */
185 volatile uint8_t abRunningPriorities[256];
186 /** The index to the current running priority. */
187 volatile uint8_t idxRunningPriority;
188 /** @} */
189
190 /** @name Log Max counters
191 * @{ */
192 uint32_t cLogMaxAccessError;
193 uint32_t cLogMaxSetApicBaseAddr;
194 uint32_t cLogMaxGetApicBaseAddr;
195 uint32_t uAlignment4;
196 /** @} */
197
198 /** @name APIC statistics.
199 * @{ */
200#ifdef VBOX_WITH_STATISTICS
201 /** Number of MMIO reads in R3. */
202 STAMCOUNTER StatMmioReadR3;
203 /** Number of MMIO writes in R3. */
204 STAMCOUNTER StatMmioWriteR3;
205 /** Number of MSR reads in R3. */
206 STAMCOUNTER StatSysRegReadR3;
207 /** Number of MSR writes in R3. */
208 STAMCOUNTER StatSysRegWriteR3;
209
210# if 0 /* No R0 for now. */
211 /** Number of MMIO reads in RZ. */
212 STAMCOUNTER StatMmioReadRZ;
213 /** Number of MMIO writes in RZ. */
214 STAMCOUNTER StatMmioWriteRZ;
215 /** Number of MSR reads in RZ. */
216 STAMCOUNTER StatSysRegReadRZ;
217 /** Number of MSR writes in RZ. */
218 STAMCOUNTER StatSysRegWriteRZ;
219# endif
220#endif
221 /** @} */
222} GICCPU;
223/** Pointer to GIC VMCPU instance data. */
224typedef GICCPU *PGICCPU;
225/** Pointer to a const GIC VMCPU instance data. */
226typedef GICCPU const *PCGICCPU;
227
228DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
229DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
230
231DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
232DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
233
234DECLHIDDEN(void) gicResetCpu(PVMCPUCC pVCpu);
235
236DECLCALLBACK(int) gicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg);
237DECLCALLBACK(int) gicR3Destruct(PPDMDEVINS pDevIns);
238DECLCALLBACK(void) gicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
239DECLCALLBACK(void) gicR3Reset(PPDMDEVINS pDevIns);
240
241/** @} */
242
243#endif /* !VMM_INCLUDED_SRC_include_GICInternal_h */
244
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