VirtualBox

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

Last change on this file since 106400 was 106400, checked in by vboxsync, 5 weeks ago

VMMArm: Add a GIC NEM backend skeleton for Windows, bugref:10392 [missing file]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/* $Id: GICInternal.h 106400 2024-10-16 20:55:48Z vboxsync $ */
2/** @file
3 * GIC - Generic Interrupt Controller Architecture (GICv3).
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
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 /** The interrupt routing information. */
83 volatile uint32_t au32IntRouting[GIC_SPI_MAX];
84
85 /** Flag whether group 0 interrupts are currently enabled. */
86 volatile bool fIrqGrp0Enabled;
87 /** Flag whether group 1 interrupts are currently enabled. */
88 volatile bool fIrqGrp1Enabled;
89 /** @} */
90
91} GICDEV;
92/** Pointer to a GIC device. */
93typedef GICDEV *PGICDEV;
94/** Pointer to a const GIC device. */
95typedef GICDEV const *PCGICDEV;
96
97
98/**
99 * GIC VM Instance data.
100 */
101typedef struct GIC
102{
103 /** The ring-3 device instance. */
104 PPDMDEVINSR3 pDevInsR3;
105#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
106 /** Flag whether the in-kernel (KVM/Hyper-V) GIC of the NEM backend is used. */
107 bool fNemGic;
108#endif
109} GIC;
110/** Pointer to GIC VM instance data. */
111typedef GIC *PGIC;
112/** Pointer to const GIC VM instance data. */
113typedef GIC const *PCGIC;
114AssertCompileSizeAlignment(GIC, 8);
115
116/**
117 * GIC VMCPU Instance data.
118 */
119typedef struct GICCPU
120{
121 /** @name The per vCPU redistributor data is kept here.
122 * @{ */
123
124 /** @name Physical LPI register state.
125 * @{ */
126 /** @} */
127
128 /** @name SGI and PPI redistributor register state.
129 * @{ */
130 /** Interrupt Group 0 Register. */
131 volatile uint32_t u32RegIGrp0;
132 /** Interrupt Configuration Register 0. */
133 volatile uint32_t u32RegICfg0;
134 /** Interrupt Configuration Register 1. */
135 volatile uint32_t u32RegICfg1;
136 /** Interrupt enabled bitmap. */
137 volatile uint32_t bmIntEnabled;
138 /** Current interrupt pending state. */
139 volatile uint32_t bmIntPending;
140 /** The current interrupt active state. */
141 volatile uint32_t bmIntActive;
142 /** The interrupt priority for each of the SGI/PPIs */
143 volatile uint8_t abIntPriority[GIC_INTID_RANGE_PPI_LAST + 1];
144 /** @} */
145
146 /** @name ICC system register state.
147 * @{ */
148 /** Flag whether group 0 interrupts are currently enabled. */
149 volatile bool fIrqGrp0Enabled;
150 /** Flag whether group 1 interrupts are currently enabled. */
151 volatile bool fIrqGrp1Enabled;
152 /** The current interrupt priority, only interrupts with a higher priority get signalled. */
153 volatile uint8_t bInterruptPriority;
154 /** The interrupt controller Binary Point Register for Group 0 interrupts. */
155 uint8_t bBinaryPointGrp0;
156 /** The interrupt controller Binary Point Register for Group 1 interrupts. */
157 uint8_t bBinaryPointGrp1;
158 /** The running poriorities caused by preemption. */
159 volatile uint8_t abRunningPriorities[256];
160 /** The index to the current running priority. */
161 volatile uint8_t idxRunningPriority;
162 /** @} */
163
164 /** @name Log Max counters
165 * @{ */
166 uint32_t cLogMaxAccessError;
167 uint32_t cLogMaxSetApicBaseAddr;
168 uint32_t cLogMaxGetApicBaseAddr;
169 uint32_t uAlignment4;
170 /** @} */
171
172 /** @name APIC statistics.
173 * @{ */
174#ifdef VBOX_WITH_STATISTICS
175 /** Number of MMIO reads in R3. */
176 STAMCOUNTER StatMmioReadR3;
177 /** Number of MMIO writes in R3. */
178 STAMCOUNTER StatMmioWriteR3;
179 /** Number of MSR reads in R3. */
180 STAMCOUNTER StatSysRegReadR3;
181 /** Number of MSR writes in R3. */
182 STAMCOUNTER StatSysRegWriteR3;
183
184# if 0 /* No R0 for now. */
185 /** Number of MMIO reads in RZ. */
186 STAMCOUNTER StatMmioReadRZ;
187 /** Number of MMIO writes in RZ. */
188 STAMCOUNTER StatMmioWriteRZ;
189 /** Number of MSR reads in RZ. */
190 STAMCOUNTER StatSysRegReadRZ;
191 /** Number of MSR writes in RZ. */
192 STAMCOUNTER StatSysRegWriteRZ;
193# endif
194#endif
195 /** @} */
196} GICCPU;
197/** Pointer to GIC VMCPU instance data. */
198typedef GICCPU *PGICCPU;
199/** Pointer to a const GIC VMCPU instance data. */
200typedef GICCPU const *PCGICCPU;
201
202DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
203DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
204
205DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb);
206DECL_HIDDEN_CALLBACK(VBOXSTRICTRC) gicReDistMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb);
207
208DECLHIDDEN(void) gicResetCpu(PVMCPUCC pVCpu);
209
210DECLCALLBACK(int) gicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg);
211DECLCALLBACK(int) gicR3Destruct(PPDMDEVINS pDevIns);
212DECLCALLBACK(void) gicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
213DECLCALLBACK(void) gicR3Reset(PPDMDEVINS pDevIns);
214
215/** @} */
216
217#endif /* !VMM_INCLUDED_SRC_include_GICInternal_h */
218
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