VirtualBox

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

Last change on this file since 107957 was 107957, checked in by vboxsync, 4 weeks ago

VMM/GIC: bugref:10404 Some register renaming, minor bits.

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