VirtualBox

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

Last change on this file since 106443 was 106419, checked in by vboxsync, 6 weeks ago

VMMArm: Add a GIC NEM backend skeleton for Windows, bugref:10392 [build fix]

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