VirtualBox

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

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

VMM: bugref:10759 Refactor GIC for use with different backends. [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.1 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 uIntId The SPI ID (minus GIC_INTID_RANGE_SPI_START) to assert/de-assert.
105 * @param fAsserted Flag whether to mark the interrupt as asserted/de-asserted.
106 */
107 DECLR3CALLBACKMEMBER(int, pfnSetSpi, (PVMCC pVM, uint32_t uIntId, bool fAsserted));
108
109 /**
110 * Sets the specified private peripheral interrupt starting.
111 *
112 * @returns VBox status code.
113 * @param pVCpu The cross context virtual CPU structure.
114 * @param uIntId The PPI ID (minus GIC_INTID_RANGE_PPI_START) to assert/de-assert.
115 * @param fAsserted Flag whether to mark the interrupt as asserted/de-asserted.
116 */
117 DECLR3CALLBACKMEMBER(int, pfnSetPpi, (PVMCPUCC pVCpu, uint32_t uIntId, bool fAsserted));
118
119 /** @name Reserved for future (MBZ).
120 * @{ */
121 DECLR3CALLBACKMEMBER(int, pfnReserved4, (void));
122 DECLR3CALLBACKMEMBER(int, pfnReserved5, (void));
123 DECLR3CALLBACKMEMBER(int, pfnReserved6, (void));
124 DECLR3CALLBACKMEMBER(int, pfnReserved7, (void));
125 DECLR3CALLBACKMEMBER(int, pfnReserved8, (void));
126 DECLR3CALLBACKMEMBER(int, pfnReserved9, (void));
127 DECLR3CALLBACKMEMBER(int, pfnReserved10, (void));
128 DECLR3CALLBACKMEMBER(int, pfnReserved11, (void));
129 DECLR3CALLBACKMEMBER(int, pfnReserved12, (void));
130 DECLR3CALLBACKMEMBER(int, pfnReserved13, (void));
131 DECLR3CALLBACKMEMBER(int, pfnReserved14, (void));
132 DECLR3CALLBACKMEMBER(int, pfnReserved15, (void));
133 DECLR3CALLBACKMEMBER(int, pfnReserved16, (void));
134 DECLR3CALLBACKMEMBER(int, pfnReserved17, (void));
135 DECLR3CALLBACKMEMBER(int, pfnReserved18, (void));
136 DECLR3CALLBACKMEMBER(int, pfnReserved19, (void));
137 DECLR3CALLBACKMEMBER(int, pfnReserved20, (void));
138 DECLR3CALLBACKMEMBER(int, pfnReserved21, (void));
139 DECLR3CALLBACKMEMBER(int, pfnReserved22, (void));
140 DECLR3CALLBACKMEMBER(int, pfnReserved23, (void));
141 DECLR3CALLBACKMEMBER(int, pfnReserved24, (void));
142 DECLR3CALLBACKMEMBER(int, pfnReserved25, (void));
143 DECLR3CALLBACKMEMBER(int, pfnReserved26, (void));
144 DECLR3CALLBACKMEMBER(int, pfnReserved27, (void));
145 DECLR3CALLBACKMEMBER(int, pfnReserved28, (void));
146 DECLR3CALLBACKMEMBER(int, pfnReserved29, (void));
147 /** @} */
148} PDMGICBACKENDR3;
149/** Pointer to ring-3 GIC backend. */
150typedef R3PTRTYPE(struct PDMGICBACKENDR3 *) PPDMGICBACKENDR3;
151/** Const pointer to ring-3 GIC backend. */
152typedef R3PTRTYPE(const struct PDMGICBACKENDR3 *) PCPDMGICBACKENDR3;
153AssertCompileSizeAlignment(PDMGICBACKENDR3, 8);
154
155/**
156 * PDM GIC backend ring-0 API.
157 */
158typedef struct PDMGICBACKENDR0
159{
160 /** @name Reserved for future (MBZ).
161 * @{ */
162 DECLR0CALLBACKMEMBER(int, pfnReserved0, (void));
163 DECLR0CALLBACKMEMBER(int, pfnReserved1, (void));
164 DECLR0CALLBACKMEMBER(int, pfnReserved2, (void));
165 DECLR0CALLBACKMEMBER(int, pfnReserved3, (void));
166 DECLR0CALLBACKMEMBER(int, pfnReserved4, (void));
167 DECLR0CALLBACKMEMBER(int, pfnReserved5, (void));
168 DECLR0CALLBACKMEMBER(int, pfnReserved6, (void));
169 DECLR0CALLBACKMEMBER(int, pfnReserved7, (void));
170 DECLR0CALLBACKMEMBER(int, pfnReserved8, (void));
171 DECLR0CALLBACKMEMBER(int, pfnReserved9, (void));
172 DECLR0CALLBACKMEMBER(int, pfnReserved10, (void));
173 DECLR0CALLBACKMEMBER(int, pfnReserved11, (void));
174 DECLR0CALLBACKMEMBER(int, pfnReserved12, (void));
175 DECLR0CALLBACKMEMBER(int, pfnReserved13, (void));
176 DECLR0CALLBACKMEMBER(int, pfnReserved14, (void));
177 DECLR0CALLBACKMEMBER(int, pfnReserved15, (void));
178 DECLR0CALLBACKMEMBER(int, pfnReserved16, (void));
179 DECLR0CALLBACKMEMBER(int, pfnReserved17, (void));
180 DECLR0CALLBACKMEMBER(int, pfnReserved18, (void));
181 DECLR0CALLBACKMEMBER(int, pfnReserved19, (void));
182 DECLR0CALLBACKMEMBER(int, pfnReserved20, (void));
183 DECLR0CALLBACKMEMBER(int, pfnReserved21, (void));
184 DECLR0CALLBACKMEMBER(int, pfnReserved22, (void));
185 DECLR0CALLBACKMEMBER(int, pfnReserved23, (void));
186 DECLR0CALLBACKMEMBER(int, pfnReserved24, (void));
187 DECLR0CALLBACKMEMBER(int, pfnReserved25, (void));
188 DECLR0CALLBACKMEMBER(int, pfnReserved26, (void));
189 DECLR0CALLBACKMEMBER(int, pfnReserved27, (void));
190 DECLR0CALLBACKMEMBER(int, pfnReserved28, (void));
191 DECLR0CALLBACKMEMBER(int, pfnReserved29, (void));
192 /** @} */
193} PDMGICBACKENDR0;
194/** Pointer to ring-0 GIC backend. */
195typedef R0PTRTYPE(struct PDMGICBACKENDR0 *) PPDMGICBACKENDR0;
196/** Const pointer to ring-0 GIC backend. */
197typedef R0PTRTYPE(const struct PDMGICBACKENDR0 *) PCPDMGICBACKENDR0;
198AssertCompileSizeAlignment(PDMGICBACKENDR0, 8);
199
200/**
201 * PDM GIC backend RC API.
202 */
203typedef struct PDMGICBACKENDRC
204{
205 /** @name Reserved for future (MBZ).
206 * @{ */
207 DECLRCCALLBACKMEMBER(int, pfnReserved0, (void));
208 DECLRCCALLBACKMEMBER(int, pfnReserved1, (void));
209 DECLRCCALLBACKMEMBER(int, pfnReserved2, (void));
210 DECLRCCALLBACKMEMBER(int, pfnReserved3, (void));
211 DECLRCCALLBACKMEMBER(int, pfnReserved4, (void));
212 DECLRCCALLBACKMEMBER(int, pfnReserved5, (void));
213 DECLRCCALLBACKMEMBER(int, pfnReserved6, (void));
214 DECLRCCALLBACKMEMBER(int, pfnReserved7, (void));
215 DECLRCCALLBACKMEMBER(int, pfnReserved8, (void));
216 DECLRCCALLBACKMEMBER(int, pfnReserved9, (void));
217 DECLRCCALLBACKMEMBER(int, pfnReserved10, (void));
218 DECLRCCALLBACKMEMBER(int, pfnReserved11, (void));
219 DECLRCCALLBACKMEMBER(int, pfnReserved12, (void));
220 DECLRCCALLBACKMEMBER(int, pfnReserved13, (void));
221 DECLRCCALLBACKMEMBER(int, pfnReserved14, (void));
222 DECLRCCALLBACKMEMBER(int, pfnReserved15, (void));
223 DECLRCCALLBACKMEMBER(int, pfnReserved16, (void));
224 DECLRCCALLBACKMEMBER(int, pfnReserved17, (void));
225 DECLRCCALLBACKMEMBER(int, pfnReserved18, (void));
226 DECLRCCALLBACKMEMBER(int, pfnReserved19, (void));
227 DECLRCCALLBACKMEMBER(int, pfnReserved20, (void));
228 DECLRCCALLBACKMEMBER(int, pfnReserved21, (void));
229 DECLRCCALLBACKMEMBER(int, pfnReserved22, (void));
230 DECLRCCALLBACKMEMBER(int, pfnReserved23, (void));
231 DECLRCCALLBACKMEMBER(int, pfnReserved24, (void));
232 DECLRCCALLBACKMEMBER(int, pfnReserved25, (void));
233 DECLRCCALLBACKMEMBER(int, pfnReserved26, (void));
234 DECLRCCALLBACKMEMBER(int, pfnReserved27, (void));
235 DECLRCCALLBACKMEMBER(int, pfnReserved28, (void));
236 DECLRCCALLBACKMEMBER(int, pfnReserved29, (void));
237 /** @} */
238} PDMGICBACKENDRC;
239/** Pointer to raw-mode context GIC backend. */
240typedef RCPTRTYPE(struct PDMGICBACKENDRC *) PPDMGICBACKENDRC;
241/** Const pointer to raw-mode context GIC backend. */
242typedef RCPTRTYPE(const struct PDMGICBACKENDRC *) PCPDMGICBACKENDRC;
243AssertCompileSizeAlignment(PDMGICBACKENDRC, 8);
244AssertCompile(sizeof(PDMGICBACKENDR3) == sizeof(PDMGICBACKENDR0));
245
246/** @typedef PDMGICBACKENDR3
247 * A current context PDM GIC backend. */
248/** @typedef PPDMGICBACKENDR3
249 * Pointer to a current context PDM GIC backend. */
250/** @typedef PCPDMGICBACKENDR3
251 * Pointer to a const current context PDM GIC backend. */
252#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
253typedef PDMGICBACKENDR3 PDMGICBACKEND;
254typedef PPDMGICBACKENDR3 PPDMGICBACKEND;
255typedef PCPDMGICBACKENDR3 PCPDMGICBACKEND;
256#elif defined(IN_RING0)
257typedef PDMGICBACKENDR0 PDMGICBACKEND;
258typedef PPDMGICBACKENDR0 PPDMGICBACKEND;
259typedef PCPDMGICBACKENDR0 PCPDMGICBACKEND;
260#elif defined(IN_RC)
261typedef PDMGICBACKENDRC PDMGICBACKEND;
262typedef PPDMGICBACKENDRC PPDMGICBACKEND;
263typedef PCPDMGICBACKENDRC PCPDMGICBACKEND;
264#else
265# error "Not IN_RING3, IN_RING0 or IN_RC"
266#endif
267
268VMM_INT_DECL(int) PDMGicRegisterBackend(PVMCC pVM, PDMGICBACKENDTYPE enmBackendType, PCPDMGICBACKEND pBackend);
269
270VMM_INT_DECL(VBOXSTRICTRC) PDMGicReadSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t *pu64Value);
271VMM_INT_DECL(VBOXSTRICTRC) PDMGicWriteSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t u64Value);
272VMM_INT_DECL(int) PDMGicSetSpi(PVMCC pVM, uint32_t uIntId, bool fAsserted);
273VMM_INT_DECL(int) PDMGicSetPpi(PVMCPUCC pVCpu, uint32_t uIntId, bool fAsserted);
274
275RT_C_DECLS_END
276
277/** @} */
278
279#endif /* !VBOX_INCLUDED_vmm_pdmgic_h */
280
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