VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmgic.h@ 108695

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

include/VBox/vmm/pdmgic.h: Doxygen

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.7 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, GICv3 Interface.
3 */
4
5/*
6 * Copyright (C) 2023-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_pdmgic_h
37#define VBOX_INCLUDED_vmm_pdmgic_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/types.h>
43#include <iprt/assertcompile.h>
44struct PDMDEVREGCB;
45
46/** @defgroup grp_pdm_gic The local GIC PDM API
47 * @ingroup grp_pdm
48 * @{
49 */
50
51RT_C_DECLS_BEGIN
52
53/**
54 * The type of PDM GIC backend.
55 */
56typedef enum PDMGICBACKENDTYPE
57{
58 /** None/Invalid PDM GIC backend. */
59 PDMGICBACKENDTYPE_NONE = 0,
60 /** VirtualBox backend. */
61 PDMGICBACKENDTYPE_VBOX,
62 /** KVM backend. */
63 PDMGICBACKENDTYPE_KVM,
64 /** Hyper-V backend. */
65 PDMGICBACKENDTYPE_HYPERV,
66 /** Hypervisor.Framework backend. */
67 PDMGICBACKENDTYPE_HVF,
68 /** End of valid PDM GIC backend values. */
69 PDMGICBACKENDTYPE_END,
70 /** The usual 32-bit paranoia. */
71 PDMGICBACKENDTYPE_32BIT_HACK = 0x7fffffff
72} PDMGICBACKENDTYPE;
73
74/**
75 * PDM GIC backend ring-3 API.
76 */
77typedef struct PDMGICBACKENDR3
78{
79 /**
80 * Reads a GIC system register.
81 *
82 * @returns Strict VBox status code.
83 * @param pVCpu The cross context virtual CPU structure.
84 * @param u32Reg The system register being read.
85 * @param pu64Value Where to store the read value.
86 */
87 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnReadSysReg, (PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t *pu64Value));
88
89 /**
90 * Writes an GIC system register.
91 *
92 * @returns Strict VBox status code.
93 * @param pVCpu The cross context virtual CPU structure.
94 * @param u32Reg The system register being written (IPRT system register identifier).
95 * @param u64Value The value to write.
96 */
97 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnWriteSysReg, (PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t u64Value));
98
99 /**
100 * Sets the specified shared peripheral interrupt starting.
101 *
102 * @returns VBox status code.
103 * @param pVM The cross context virtual machine structure.
104 * @param uSpiIntId The SPI ID (minus GIC_INTID_RANGE_SPI_START) to
105 * assert/de-assert.
106 * @param fAsserted Flag whether to mark the interrupt as asserted/de-asserted.
107 */
108 DECLR3CALLBACKMEMBER(int, pfnSetSpi, (PVMCC pVM, uint32_t uSpiIntId, bool fAsserted));
109
110 /**
111 * Sets the specified private peripheral interrupt starting.
112 *
113 * @returns VBox status code.
114 * @param pVCpu The cross context virtual CPU structure.
115 * @param uPpiIntId The PPI ID (minus GIC_INTID_RANGE_PPI_START) to
116 * assert/de-assert.
117 * @param fAsserted Flag whether to mark the interrupt as asserted/de-asserted.
118 */
119 DECLR3CALLBACKMEMBER(int, pfnSetPpi, (PVMCPUCC pVCpu, uint32_t uPpiIntId, bool fAsserted));
120
121 /**
122 * Sends an MSI to the GIC ITS.
123 *
124 * @returns VBox status code.
125 * @param pVM The cross context virtual machine structure.
126 * @param uBusDevFn The bus:device:function of the device initiating the MSI.
127 * Cannot be NIL_PCIBDF.
128 * @param pMsi The MSI to send.
129 * @param uEventId TODO
130 * @param uTagSrc The IRQ tag and source (for tracing).
131 */
132 DECLR3CALLBACKMEMBER(int, pfnSendMsi, (PVMCC pVM, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uEventId, uint32_t uTagSrc));
133
134 /** @name Reserved for future (MBZ).
135 * @{ */
136 DECLR3CALLBACKMEMBER(int, pfnReserved5, (void));
137 DECLR3CALLBACKMEMBER(int, pfnReserved6, (void));
138 DECLR3CALLBACKMEMBER(int, pfnReserved7, (void));
139 DECLR3CALLBACKMEMBER(int, pfnReserved8, (void));
140 DECLR3CALLBACKMEMBER(int, pfnReserved9, (void));
141 DECLR3CALLBACKMEMBER(int, pfnReserved10, (void));
142 DECLR3CALLBACKMEMBER(int, pfnReserved11, (void));
143 DECLR3CALLBACKMEMBER(int, pfnReserved12, (void));
144 DECLR3CALLBACKMEMBER(int, pfnReserved13, (void));
145 DECLR3CALLBACKMEMBER(int, pfnReserved14, (void));
146 DECLR3CALLBACKMEMBER(int, pfnReserved15, (void));
147 DECLR3CALLBACKMEMBER(int, pfnReserved16, (void));
148 DECLR3CALLBACKMEMBER(int, pfnReserved17, (void));
149 DECLR3CALLBACKMEMBER(int, pfnReserved18, (void));
150 DECLR3CALLBACKMEMBER(int, pfnReserved19, (void));
151 DECLR3CALLBACKMEMBER(int, pfnReserved20, (void));
152 DECLR3CALLBACKMEMBER(int, pfnReserved21, (void));
153 DECLR3CALLBACKMEMBER(int, pfnReserved22, (void));
154 DECLR3CALLBACKMEMBER(int, pfnReserved23, (void));
155 DECLR3CALLBACKMEMBER(int, pfnReserved24, (void));
156 DECLR3CALLBACKMEMBER(int, pfnReserved25, (void));
157 DECLR3CALLBACKMEMBER(int, pfnReserved26, (void));
158 DECLR3CALLBACKMEMBER(int, pfnReserved27, (void));
159 DECLR3CALLBACKMEMBER(int, pfnReserved28, (void));
160 DECLR3CALLBACKMEMBER(int, pfnReserved29, (void));
161 /** @} */
162} PDMGICBACKENDR3;
163/** Pointer to ring-3 GIC backend. */
164typedef R3PTRTYPE(struct PDMGICBACKENDR3 *) PPDMGICBACKENDR3;
165/** Const pointer to ring-3 GIC backend. */
166typedef R3PTRTYPE(const struct PDMGICBACKENDR3 *) PCPDMGICBACKENDR3;
167AssertCompileSizeAlignment(PDMGICBACKENDR3, 8);
168
169/**
170 * PDM GIC backend ring-0 API.
171 */
172typedef struct PDMGICBACKENDR0
173{
174 /** @name Reserved for future (MBZ).
175 * @{ */
176 DECLR0CALLBACKMEMBER(int, pfnReserved0, (void));
177 DECLR0CALLBACKMEMBER(int, pfnReserved1, (void));
178 DECLR0CALLBACKMEMBER(int, pfnReserved2, (void));
179 DECLR0CALLBACKMEMBER(int, pfnReserved3, (void));
180 DECLR0CALLBACKMEMBER(int, pfnReserved4, (void));
181 DECLR0CALLBACKMEMBER(int, pfnReserved5, (void));
182 DECLR0CALLBACKMEMBER(int, pfnReserved6, (void));
183 DECLR0CALLBACKMEMBER(int, pfnReserved7, (void));
184 DECLR0CALLBACKMEMBER(int, pfnReserved8, (void));
185 DECLR0CALLBACKMEMBER(int, pfnReserved9, (void));
186 DECLR0CALLBACKMEMBER(int, pfnReserved10, (void));
187 DECLR0CALLBACKMEMBER(int, pfnReserved11, (void));
188 DECLR0CALLBACKMEMBER(int, pfnReserved12, (void));
189 DECLR0CALLBACKMEMBER(int, pfnReserved13, (void));
190 DECLR0CALLBACKMEMBER(int, pfnReserved14, (void));
191 DECLR0CALLBACKMEMBER(int, pfnReserved15, (void));
192 DECLR0CALLBACKMEMBER(int, pfnReserved16, (void));
193 DECLR0CALLBACKMEMBER(int, pfnReserved17, (void));
194 DECLR0CALLBACKMEMBER(int, pfnReserved18, (void));
195 DECLR0CALLBACKMEMBER(int, pfnReserved19, (void));
196 DECLR0CALLBACKMEMBER(int, pfnReserved20, (void));
197 DECLR0CALLBACKMEMBER(int, pfnReserved21, (void));
198 DECLR0CALLBACKMEMBER(int, pfnReserved22, (void));
199 DECLR0CALLBACKMEMBER(int, pfnReserved23, (void));
200 DECLR0CALLBACKMEMBER(int, pfnReserved24, (void));
201 DECLR0CALLBACKMEMBER(int, pfnReserved25, (void));
202 DECLR0CALLBACKMEMBER(int, pfnReserved26, (void));
203 DECLR0CALLBACKMEMBER(int, pfnReserved27, (void));
204 DECLR0CALLBACKMEMBER(int, pfnReserved28, (void));
205 DECLR0CALLBACKMEMBER(int, pfnReserved29, (void));
206 /** @} */
207} PDMGICBACKENDR0;
208/** Pointer to ring-0 GIC backend. */
209typedef R0PTRTYPE(struct PDMGICBACKENDR0 *) PPDMGICBACKENDR0;
210/** Const pointer to ring-0 GIC backend. */
211typedef R0PTRTYPE(const struct PDMGICBACKENDR0 *) PCPDMGICBACKENDR0;
212AssertCompileSizeAlignment(PDMGICBACKENDR0, 8);
213
214/**
215 * PDM GIC backend RC API.
216 */
217typedef struct PDMGICBACKENDRC
218{
219 /** @name Reserved for future (MBZ).
220 * @{ */
221 DECLRCCALLBACKMEMBER(int, pfnReserved0, (void));
222 DECLRCCALLBACKMEMBER(int, pfnReserved1, (void));
223 DECLRCCALLBACKMEMBER(int, pfnReserved2, (void));
224 DECLRCCALLBACKMEMBER(int, pfnReserved3, (void));
225 DECLRCCALLBACKMEMBER(int, pfnReserved4, (void));
226 DECLRCCALLBACKMEMBER(int, pfnReserved5, (void));
227 DECLRCCALLBACKMEMBER(int, pfnReserved6, (void));
228 DECLRCCALLBACKMEMBER(int, pfnReserved7, (void));
229 DECLRCCALLBACKMEMBER(int, pfnReserved8, (void));
230 DECLRCCALLBACKMEMBER(int, pfnReserved9, (void));
231 DECLRCCALLBACKMEMBER(int, pfnReserved10, (void));
232 DECLRCCALLBACKMEMBER(int, pfnReserved11, (void));
233 DECLRCCALLBACKMEMBER(int, pfnReserved12, (void));
234 DECLRCCALLBACKMEMBER(int, pfnReserved13, (void));
235 DECLRCCALLBACKMEMBER(int, pfnReserved14, (void));
236 DECLRCCALLBACKMEMBER(int, pfnReserved15, (void));
237 DECLRCCALLBACKMEMBER(int, pfnReserved16, (void));
238 DECLRCCALLBACKMEMBER(int, pfnReserved17, (void));
239 DECLRCCALLBACKMEMBER(int, pfnReserved18, (void));
240 DECLRCCALLBACKMEMBER(int, pfnReserved19, (void));
241 DECLRCCALLBACKMEMBER(int, pfnReserved20, (void));
242 DECLRCCALLBACKMEMBER(int, pfnReserved21, (void));
243 DECLRCCALLBACKMEMBER(int, pfnReserved22, (void));
244 DECLRCCALLBACKMEMBER(int, pfnReserved23, (void));
245 DECLRCCALLBACKMEMBER(int, pfnReserved24, (void));
246 DECLRCCALLBACKMEMBER(int, pfnReserved25, (void));
247 DECLRCCALLBACKMEMBER(int, pfnReserved26, (void));
248 DECLRCCALLBACKMEMBER(int, pfnReserved27, (void));
249 DECLRCCALLBACKMEMBER(int, pfnReserved28, (void));
250 DECLRCCALLBACKMEMBER(int, pfnReserved29, (void));
251 /** @} */
252} PDMGICBACKENDRC;
253/** Pointer to raw-mode context GIC backend. */
254typedef RCPTRTYPE(struct PDMGICBACKENDRC *) PPDMGICBACKENDRC;
255/** Const pointer to raw-mode context GIC backend. */
256typedef RCPTRTYPE(const struct PDMGICBACKENDRC *) PCPDMGICBACKENDRC;
257AssertCompileSizeAlignment(PDMGICBACKENDRC, 8);
258AssertCompile(sizeof(PDMGICBACKENDR3) == sizeof(PDMGICBACKENDR0));
259
260/** @typedef PDMGICBACKENDR3
261 * A current context PDM GIC backend. */
262/** @typedef PPDMGICBACKENDR3
263 * Pointer to a current context PDM GIC backend. */
264/** @typedef PCPDMGICBACKENDR3
265 * Pointer to a const current context PDM GIC backend. */
266#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
267typedef PDMGICBACKENDR3 PDMGICBACKEND;
268typedef PPDMGICBACKENDR3 PPDMGICBACKEND;
269typedef PCPDMGICBACKENDR3 PCPDMGICBACKEND;
270#elif defined(IN_RING0)
271typedef PDMGICBACKENDR0 PDMGICBACKEND;
272typedef PPDMGICBACKENDR0 PPDMGICBACKEND;
273typedef PCPDMGICBACKENDR0 PCPDMGICBACKEND;
274#elif defined(IN_RC)
275typedef PDMGICBACKENDRC PDMGICBACKEND;
276typedef PPDMGICBACKENDRC PPDMGICBACKEND;
277typedef PCPDMGICBACKENDRC PCPDMGICBACKEND;
278#else
279# error "Not IN_RING3, IN_RING0 or IN_RC"
280#endif
281
282VMM_INT_DECL(int) PDMGicRegisterBackend(PVMCC pVM, PDMGICBACKENDTYPE enmBackendType, PCPDMGICBACKEND pBackend);
283
284VMM_INT_DECL(VBOXSTRICTRC) PDMGicReadSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t *pu64Value);
285VMM_INT_DECL(VBOXSTRICTRC) PDMGicWriteSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t u64Value);
286VMM_INT_DECL(int) PDMGicSetSpi(PVMCC pVM, uint32_t uSpiIntId, bool fAsserted);
287VMM_INT_DECL(int) PDMGicSetPpi(PVMCPUCC pVCpu, uint32_t uIntId, bool fAsserted);
288
289RT_C_DECLS_END
290
291/** @} */
292
293#endif /* !VBOX_INCLUDED_vmm_pdmgic_h */
294
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