VirtualBox

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

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

VMM: bugref:10759 Refactor GIC for use with different backends.

  • 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>
43struct PDMDEVREGCB;
44
45/** @defgroup grp_pdm_gic The local GIC PDM API
46 * @ingroup grp_pdm
47 * @{
48 */
49
50RT_C_DECLS_BEGIN
51
52/**
53 * The type of PDM GIC backend.
54 */
55typedef enum PDMGICBACKENDTYPE
56{
57 /** None/Invalid PDM GIC backend. */
58 PDMGICBACKENDTYPE_NONE = 0,
59 /** VirtualBox backend. */
60 PDMGICBACKENDTYPE_VBOX,
61 /** KVM backend. */
62 PDMGICBACKENDTYPE_KVM,
63 /** Hyper-V backend. */
64 PDMGICBACKENDTYPE_HYPERV,
65 /** Hypervisor.Framework backend. */
66 PDMGICBACKENDTYPE_HVF,
67 /** End of valid PDM GIC backend values. */
68 PDMGICBACKENDTYPE_END,
69 /** The usual 32-bit paranoia. */
70 PDMGICBACKENDTYPE_32BIT_HACK = 0x7fffffff
71} PDMGICBACKENDTYPE;
72
73/**
74 * PDM GIC backend ring-3 API.
75 */
76typedef struct PDMGICBACKENDR3
77{
78 /**
79 * Reads a GIC system register.
80 *
81 * @returns Strict VBox status code.
82 * @param pVCpu The cross context virtual CPU structure.
83 * @param u32Reg The system register being read.
84 * @param pu64Value Where to store the read value.
85 */
86 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnReadSysReg, (PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t *pu64Value));
87
88 /**
89 * Writes an GIC system register.
90 *
91 * @returns Strict VBox status code.
92 * @param pVCpu The cross context virtual CPU structure.
93 * @param u32Reg The system register being written (IPRT system register identifier).
94 * @param u64Value The value to write.
95 */
96 DECLR3CALLBACKMEMBER(VBOXSTRICTRC, pfnWriteSysReg, (PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t u64Value));
97
98 /**
99 * Sets the specified shared peripheral interrupt starting.
100 *
101 * @returns VBox status code.
102 * @param pVM The cross context virtual machine structure.
103 * @param uIntId The SPI ID (minus GIC_INTID_RANGE_SPI_START) to assert/de-assert.
104 * @param fAsserted Flag whether to mark the interrupt as asserted/de-asserted.
105 */
106 DECLR3CALLBACKMEMBER(int, pfnSetSpi, (PVMCC pVM, uint32_t uIntId, bool fAsserted));
107
108 /**
109 * Sets the specified private peripheral interrupt starting.
110 *
111 * @returns VBox status code.
112 * @param pVCpu The cross context virtual CPU structure.
113 * @param uIntId The PPI ID (minus GIC_INTID_RANGE_PPI_START) to assert/de-assert.
114 * @param fAsserted Flag whether to mark the interrupt as asserted/de-asserted.
115 */
116 DECLR3CALLBACKMEMBER(int, pfnSetPpi, (PVMCPUCC pVCpu, uint32_t uIntId, bool fAsserted));
117
118 /** @name Reserved for future (MBZ).
119 * @{ */
120 DECLR3CALLBACKMEMBER(int, pfnReserved0, (void));
121 DECLR3CALLBACKMEMBER(int, pfnReserved1, (void));
122 DECLR3CALLBACKMEMBER(int, pfnReserved2, (void));
123 DECLR3CALLBACKMEMBER(int, pfnReserved3, (void));
124 DECLR3CALLBACKMEMBER(int, pfnReserved4, (void));
125 DECLR3CALLBACKMEMBER(int, pfnReserved5, (void));
126 DECLR3CALLBACKMEMBER(int, pfnReserved6, (void));
127 DECLR3CALLBACKMEMBER(int, pfnReserved7, (void));
128 DECLR3CALLBACKMEMBER(int, pfnReserved8, (void));
129 DECLR3CALLBACKMEMBER(int, pfnReserved9, (void));
130 DECLR3CALLBACKMEMBER(int, pfnReserved10, (void));
131 DECLR3CALLBACKMEMBER(int, pfnReserved11, (void));
132 DECLR3CALLBACKMEMBER(int, pfnReserved12, (void));
133 DECLR3CALLBACKMEMBER(int, pfnReserved13, (void));
134 DECLR3CALLBACKMEMBER(int, pfnReserved14, (void));
135 DECLR3CALLBACKMEMBER(int, pfnReserved15, (void));
136 DECLR3CALLBACKMEMBER(int, pfnReserved16, (void));
137 DECLR3CALLBACKMEMBER(int, pfnReserved17, (void));
138 DECLR3CALLBACKMEMBER(int, pfnReserved18, (void));
139 DECLR3CALLBACKMEMBER(int, pfnReserved19, (void));
140 DECLR3CALLBACKMEMBER(int, pfnReserved20, (void));
141 DECLR3CALLBACKMEMBER(int, pfnReserved21, (void));
142 DECLR3CALLBACKMEMBER(int, pfnReserved22, (void));
143 DECLR3CALLBACKMEMBER(int, pfnReserved23, (void));
144 DECLR3CALLBACKMEMBER(int, pfnReserved24, (void));
145 DECLR3CALLBACKMEMBER(int, pfnReserved25, (void));
146 /** @} */
147} PDMGICBACKENDR3;
148/** Pointer to ring-3 GIC backend. */
149typedef R3PTRTYPE(struct PDMGICBACKENDR3 *) PPDMGICBACKENDR3;
150/** Const pointer to ring-3 GIC backend. */
151typedef R3PTRTYPE(const struct PDMGICBACKENDR3 *) PCPDMGICBACKENDR3;
152AssertCompileSizeAlignment(PDMGICBACKENDR3, 8);
153
154/**
155 * PDM GIC backend ring-0 API.
156 */
157typedef struct PDMGICBACKENDR0
158{
159 /** @name Reserved for future (MBZ).
160 * @{ */
161 DECLR0CALLBACKMEMBER(int, pfnReserved0, (void));
162 DECLR0CALLBACKMEMBER(int, pfnReserved1, (void));
163 DECLR0CALLBACKMEMBER(int, pfnReserved2, (void));
164 DECLR0CALLBACKMEMBER(int, pfnReserved3, (void));
165 DECLR0CALLBACKMEMBER(int, pfnReserved4, (void));
166 DECLR0CALLBACKMEMBER(int, pfnReserved5, (void));
167 DECLR0CALLBACKMEMBER(int, pfnReserved6, (void));
168 DECLR0CALLBACKMEMBER(int, pfnReserved7, (void));
169 DECLR0CALLBACKMEMBER(int, pfnReserved8, (void));
170 DECLR0CALLBACKMEMBER(int, pfnReserved9, (void));
171 DECLR0CALLBACKMEMBER(int, pfnReserved10, (void));
172 DECLR0CALLBACKMEMBER(int, pfnReserved11, (void));
173 DECLR0CALLBACKMEMBER(int, pfnReserved12, (void));
174 DECLR0CALLBACKMEMBER(int, pfnReserved13, (void));
175 DECLR0CALLBACKMEMBER(int, pfnReserved14, (void));
176 DECLR0CALLBACKMEMBER(int, pfnReserved15, (void));
177 DECLR0CALLBACKMEMBER(int, pfnReserved16, (void));
178 DECLR0CALLBACKMEMBER(int, pfnReserved17, (void));
179 DECLR0CALLBACKMEMBER(int, pfnReserved18, (void));
180 DECLR0CALLBACKMEMBER(int, pfnReserved19, (void));
181 DECLR0CALLBACKMEMBER(int, pfnReserved20, (void));
182 DECLR0CALLBACKMEMBER(int, pfnReserved21, (void));
183 DECLR0CALLBACKMEMBER(int, pfnReserved22, (void));
184 DECLR0CALLBACKMEMBER(int, pfnReserved23, (void));
185 DECLR0CALLBACKMEMBER(int, pfnReserved24, (void));
186 DECLR0CALLBACKMEMBER(int, pfnReserved25, (void));
187 DECLR0CALLBACKMEMBER(int, pfnReserved26, (void));
188 DECLR0CALLBACKMEMBER(int, pfnReserved27, (void));
189 DECLR0CALLBACKMEMBER(int, pfnReserved28, (void));
190 DECLR0CALLBACKMEMBER(int, pfnReserved29, (void));
191 /** @} */
192} PDMGICBACKENDR0;
193/** Pointer to ring-0 GIC backend. */
194typedef R0PTRTYPE(struct PDMGICBACKENDR0 *) PPDMGICBACKENDR0;
195/** Const pointer to ring-0 GIC backend. */
196typedef R0PTRTYPE(const struct PDMGICBACKENDR0 *) PCPDMGICBACKENDR0;
197AssertCompileSizeAlignment(PDMGICBACKENDR0, 8);
198
199/**
200 * PDM GIC backend RC API.
201 */
202typedef struct PDMGICBACKENDRC
203{
204 /** @name Reserved for future (MBZ).
205 * @{ */
206 DECLRCCALLBACKMEMBER(int, pfnReserved0, (void));
207 DECLRCCALLBACKMEMBER(int, pfnReserved1, (void));
208 DECLRCCALLBACKMEMBER(int, pfnReserved2, (void));
209 DECLRCCALLBACKMEMBER(int, pfnReserved3, (void));
210 DECLRCCALLBACKMEMBER(int, pfnReserved4, (void));
211 DECLRCCALLBACKMEMBER(int, pfnReserved5, (void));
212 DECLRCCALLBACKMEMBER(int, pfnReserved6, (void));
213 DECLRCCALLBACKMEMBER(int, pfnReserved7, (void));
214 DECLRCCALLBACKMEMBER(int, pfnReserved8, (void));
215 DECLRCCALLBACKMEMBER(int, pfnReserved9, (void));
216 DECLRCCALLBACKMEMBER(int, pfnReserved10, (void));
217 DECLRCCALLBACKMEMBER(int, pfnReserved11, (void));
218 DECLRCCALLBACKMEMBER(int, pfnReserved12, (void));
219 DECLRCCALLBACKMEMBER(int, pfnReserved13, (void));
220 DECLRCCALLBACKMEMBER(int, pfnReserved14, (void));
221 DECLRCCALLBACKMEMBER(int, pfnReserved15, (void));
222 DECLRCCALLBACKMEMBER(int, pfnReserved16, (void));
223 DECLRCCALLBACKMEMBER(int, pfnReserved17, (void));
224 DECLRCCALLBACKMEMBER(int, pfnReserved18, (void));
225 DECLRCCALLBACKMEMBER(int, pfnReserved19, (void));
226 DECLRCCALLBACKMEMBER(int, pfnReserved20, (void));
227 DECLRCCALLBACKMEMBER(int, pfnReserved21, (void));
228 DECLRCCALLBACKMEMBER(int, pfnReserved22, (void));
229 DECLRCCALLBACKMEMBER(int, pfnReserved23, (void));
230 DECLRCCALLBACKMEMBER(int, pfnReserved24, (void));
231 DECLRCCALLBACKMEMBER(int, pfnReserved25, (void));
232 DECLRCCALLBACKMEMBER(int, pfnReserved26, (void));
233 DECLRCCALLBACKMEMBER(int, pfnReserved27, (void));
234 DECLRCCALLBACKMEMBER(int, pfnReserved28, (void));
235 DECLRCCALLBACKMEMBER(int, pfnReserved29, (void));
236 /** @} */
237} PDMGICBACKENDRC;
238/** Pointer to raw-mode context GIC backend. */
239typedef RCPTRTYPE(struct PDMGICBACKENDRC *) PPDMGICBACKENDRC;
240/** Const pointer to raw-mode context GIC backend. */
241typedef RCPTRTYPE(const struct PDMGICBACKENDRC *) PCPDMGICBACKENDRC;
242AssertCompileSizeAlignment(PDMGICBACKENDRC, 8);
243AssertCompile(sizeof(PDMGICBACKENDR3) == sizeof(PDMGICBACKENDR0));
244
245/** @typedef PDMGICBACKENDR3
246 * A current context PDM GIC backend. */
247/** @typedef PPDMGICBACKENDR3
248 * Pointer to a current context PDM GIC backend. */
249/** @typedef PCPDMGICBACKENDR3
250 * Pointer to a const current context PDM GIC backend. */
251#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
252typedef PDMGICBACKENDR3 PDMGICBACKEND;
253typedef PPDMGICBACKENDR3 PPDMGICBACKEND;
254typedef PCPDMGICBACKENDR3 PCPDMGICBACKEND;
255#elif defined(IN_RING0)
256typedef PDMGICBACKENDR0 PDMGICBACKEND;
257typedef PPDMGICBACKENDR0 PPDMGICBACKEND;
258typedef PCPDMGICBACKENDR0 PCPDMGICBACKEND;
259#elif defined(IN_RC)
260typedef PDMGICBACKENDRC PDMGICBACKEND;
261typedef PPDMGICBACKENDRC PPDMGICBACKEND;
262typedef PCPDMGICBACKENDRC PCPDMGICBACKEND;
263#else
264# error "Not IN_RING3, IN_RING0 or IN_RC"
265#endif
266
267VMM_INT_DECL(int) PDMGicRegisterBackend(PVMCC pVM, PDMGICBACKENDTYPE enmBackendType, PCPDMGICBACKEND pBackend);
268
269VMM_INT_DECL(VBOXSTRICTRC) PDMGicReadSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t *pu64Value);
270VMM_INT_DECL(VBOXSTRICTRC) PDMGicWriteSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t u64Value);
271VMM_INT_DECL(int) PDMGicSetSpi(PVMCC pVM, uint32_t uIntId, bool fAsserted);
272VMM_INT_DECL(int) PDMGicSetPpi(PVMCPUCC pVCpu, uint32_t uIntId, bool fAsserted);
273
274RT_C_DECLS_END
275
276/** @} */
277
278#endif /* !VBOX_INCLUDED_vmm_pdmgic_h */
279
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