VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmsrv.h@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 11.6 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, VM Services.
3 *
4 * @todo This has not been implemented, consider dropping the concept.
5 */
6
7/*
8 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
9 *
10 * This file is part of VirtualBox base platform packages, as
11 * available from https://www.virtualbox.org.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation, in version 3 of the
16 * License.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see <https://www.gnu.org/licenses>.
25 *
26 * The contents of this file may alternatively be used under the terms
27 * of the Common Development and Distribution License Version 1.0
28 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
29 * in the VirtualBox distribution, in which case the provisions of the
30 * CDDL are applicable instead of those of the GPL.
31 *
32 * You may elect to license modified versions of this file under the
33 * terms and conditions of either the GPL or the CDDL or both.
34 *
35 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36 */
37
38#ifndef VBOX_INCLUDED_vmm_pdmsrv_h
39#define VBOX_INCLUDED_vmm_pdmsrv_h
40#ifndef RT_WITHOUT_PRAGMA_ONCE
41# pragma once
42#endif
43
44#include <VBox/vmm/pdmifs.h>
45#include <VBox/vmm/ssm.h>
46#include <VBox/vmm/cfgm.h>
47
48RT_C_DECLS_BEGIN
49
50/** @defgroup grp_pdm_services The PDM Services API
51 * @ingroup grp_pdm
52 * @{
53 */
54
55/**
56 * Construct a service instance for a VM.
57 *
58 * @returns VBox status.
59 * @param pSrvIns The service instance data.
60 * If the registration structure is needed, pSrvIns->pReg points to it.
61 * @param pCfg Configuration node handle for the service. Use this to obtain the configuration
62 * of the driver instance. It's also found in pSrvIns->pCfg, but since it's primary
63 * usage is expected in this function it is passed as a parameter.
64 */
65typedef DECLCALLBACKTYPE(int, FNPDMSRVCONSTRUCT,(PPDMSRVINS pSrvIns, PCFGMNODE pCfg));
66/** Pointer to a FNPDMSRVCONSTRUCT() function. */
67typedef FNPDMSRVCONSTRUCT *PFNPDMSRVCONSTRUCT;
68
69/**
70 * Destruct a driver instance.
71 *
72 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
73 * resources can be freed correctly.
74 *
75 * @param pSrvIns The service instance data.
76 */
77typedef DECLCALLBACKTYPE(void, FNPDMSRVDESTRUCT,(PPDMSRVINS pSrvIns));
78/** Pointer to a FNPDMSRVDESTRUCT() function. */
79typedef FNPDMSRVDESTRUCT *PFNPDMSRVDESTRUCT;
80
81/**
82 * Power On notification.
83 *
84 * @param pSrvIns The service instance data.
85 */
86typedef DECLCALLBACKTYPE(void, FNPDMSRVPOWERON,(PPDMSRVINS pSrvIns));
87/** Pointer to a FNPDMSRVPOWERON() function. */
88typedef FNPDMSRVPOWERON *PFNPDMSRVPOWERON;
89
90/**
91 * Reset notification.
92 *
93 * @returns VBox status.
94 * @param pSrvIns The service instance data.
95 */
96typedef DECLCALLBACKTYPE(void, FNPDMSRVRESET,(PPDMSRVINS pSrvIns));
97/** Pointer to a FNPDMSRVRESET() function. */
98typedef FNPDMSRVRESET *PFNPDMSRVRESET;
99
100/**
101 * Suspend notification.
102 *
103 * @returns VBox status.
104 * @param pSrvIns The service instance data.
105 */
106typedef DECLCALLBACKTYPE(void, FNPDMSRVSUSPEND,(PPDMSRVINS pSrvIns));
107/** Pointer to a FNPDMSRVSUSPEND() function. */
108typedef FNPDMSRVSUSPEND *PFNPDMSRVSUSPEND;
109
110/**
111 * Resume notification.
112 *
113 * @returns VBox status.
114 * @param pSrvIns The service instance data.
115 */
116typedef DECLCALLBACKTYPE(void, FNPDMSRVRESUME,(PPDMSRVINS pSrvIns));
117/** Pointer to a FNPDMSRVRESUME() function. */
118typedef FNPDMSRVRESUME *PFNPDMSRVRESUME;
119
120/**
121 * Power Off notification.
122 *
123 * @param pSrvIns The service instance data.
124 */
125typedef DECLCALLBACKTYPE(void, FNPDMSRVPOWEROFF,(PPDMSRVINS pSrvIns));
126/** Pointer to a FNPDMSRVPOWEROFF() function. */
127typedef FNPDMSRVPOWEROFF *PFNPDMSRVPOWEROFF;
128
129/**
130 * Detach notification.
131 *
132 * This is called when a driver or device is detached from the service
133 *
134 * @param pSrvIns The service instance data.
135 * @param pDevIns The device instance to detach.
136 * @param pDrvIns The driver instance to detach.
137 */
138typedef DECLCALLBACKTYPE(void, FNPDMSRVDETACH,(PPDMSRVINS pSrvIns, PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns));
139/** Pointer to a FNPDMSRVDETACH() function. */
140typedef FNPDMSRVDETACH *PFNPDMSRVDETACH;
141
142
143
144/** PDM Service Registration Structure,
145 * This structure is used when registering a driver from
146 * VBoxServicesRegister() (HC Ring-3). PDM will continue use till
147 * the VM is terminated.
148 */
149typedef struct PDMSRVREG
150{
151 /** Structure version. PDM_SRVREG_VERSION defines the current version. */
152 uint32_t u32Version;
153 /** Driver name. */
154 char szServiceName[32];
155 /** The description of the driver. The UTF-8 string pointed to shall, like this structure,
156 * remain unchanged from registration till VM destruction. */
157 const char *pszDescription;
158
159 /** Flags, combination of the PDM_SRVREG_FLAGS_* \#defines. */
160 RTUINT fFlags;
161 /** Size of the instance data. */
162 RTUINT cbInstance;
163
164 /** Construct instance - required. */
165 PFNPDMSRVCONSTRUCT pfnConstruct;
166 /** Destruct instance - optional. */
167 PFNPDMSRVDESTRUCT pfnDestruct;
168 /** Power on notification - optional. */
169 PFNPDMSRVPOWERON pfnPowerOn;
170 /** Reset notification - optional. */
171 PFNPDMSRVRESET pfnReset;
172 /** Suspend notification - optional. */
173 PFNPDMSRVSUSPEND pfnSuspend;
174 /** Resume notification - optional. */
175 PFNPDMSRVRESUME pfnResume;
176 /** Detach notification - optional. */
177 PFNPDMSRVDETACH pfnDetach;
178 /** Power off notification - optional. */
179 PFNPDMSRVPOWEROFF pfnPowerOff;
180
181} PDMSRVREG;
182/** Pointer to a PDM Driver Structure. */
183typedef PDMSRVREG *PPDMSRVREG;
184/** Const pointer to a PDM Driver Structure. */
185typedef PDMSRVREG const *PCPDMSRVREG;
186
187
188
189/**
190 * PDM Service API.
191 */
192typedef struct PDMSRVHLP
193{
194 /** Structure version. PDM_SRVHLP_VERSION defines the current version. */
195 uint32_t u32Version;
196
197 /**
198 * Assert that the current thread is the emulation thread.
199 *
200 * @returns True if correct.
201 * @returns False if wrong.
202 * @param pSrvIns Service instance.
203 * @param pszFile Filename of the assertion location.
204 * @param iLine Linenumber of the assertion location.
205 * @param pszFunction Function of the assertion location.
206 */
207 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMSRVINS pSrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
208
209 /**
210 * Assert that the current thread is NOT the emulation thread.
211 *
212 * @returns True if correct.
213 * @returns False if wrong.
214 * @param pSrvIns Service instance.
215 * @param pszFile Filename of the assertion location.
216 * @param iLine Linenumber of the assertion location.
217 * @param pszFunction Function of the assertion location.
218 */
219 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMSRVINS pSrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
220
221 /**
222 * Creates a timer.
223 *
224 * @returns VBox status.
225 * @param pVM The cross context VM structure.
226 * @param pSrvIns Service instance.
227 * @param enmClock The clock to use on this timer.
228 * @param pfnCallback Callback function.
229 * @param pszDesc Pointer to description string which must stay around
230 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
231 * @param ppTimer Where to store the timer on success.
232 */
233 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMSRVINS pSrvIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer));
234
235 /**
236 * Query the virtual timer frequency.
237 *
238 * @returns Frequency in Hz.
239 * @param pSrvIns Service instance.
240 * @thread Any thread.
241 */
242 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMSRVINS pSrvIns));
243
244 /**
245 * Query the virtual time.
246 *
247 * @returns The current virtual time.
248 * @param pSrvIns Service instance.
249 * @thread Any thread.
250 */
251 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMSRVINS pSrvIns));
252
253} PDMSRVHLP;
254/** Pointer PDM Service API. */
255typedef PDMSRVHLP *PPDMSRVHLP;
256/** Pointer const PDM Service API. */
257typedef const PDMSRVHLP *PCPDMSRVHLP;
258
259/** Current SRVHLP version number. */
260#define PDM_SRVHLP_VERSION PDM_VERSION_MAKE(0xdfff, 1, 0)
261
262
263/**
264 * PDM Service Instance.
265 */
266typedef struct PDMSRVINS
267{
268 /** Structure version. PDM_SRVINS_VERSION defines the current version. */
269 uint32_t u32Version;
270
271 /** Internal data. */
272 union
273 {
274#ifdef PDMSRVINSINT_DECLARED
275 PDMSRVINSINT s;
276#endif
277 uint8_t padding[HC_ARCH_BITS == 32 ? 32 : 32];
278 } Internal;
279
280 /** Pointer the PDM Service API. */
281 R3PTRTYPE(PCPDMSRVHLP) pHlp;
282 /** Pointer to driver registration structure. */
283 R3PTRTYPE(PCPDMSRVREG) pReg;
284 /** Configuration handle. */
285 R3PTRTYPE(PCFGMNODE) pCfg;
286 /** The base interface of the service.
287 * The service constructor initializes this. */
288 PDMIBASE IBase;
289 /* padding to make achInstanceData aligned at 16 byte boundary. */
290 uint32_t au32Padding[2];
291 /** Pointer to driver instance data. */
292 R3PTRTYPE(void *) pvInstanceData;
293 /** Driver instance data. The size of this area is defined
294 * in the PDMSRVREG::cbInstanceData field. */
295 char achInstanceData[4];
296} PDMSRVINS;
297
298/** Current PDMSRVREG version number. */
299#define PDM_SRVINS_VERSION PDM_VERSION_MAKE(0xdffe, 1, 0)
300
301/** Converts a pointer to the PDMSRVINS::IBase to a pointer to PDMSRVINS. */
302#define PDMIBASE_2_PDMSRV(pInterface) ( (PPDMSRVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMSRVINS, IBase)) )
303
304
305
306/** Pointer to callbacks provided to the VBoxServiceRegister() call. */
307typedef struct PDMSRVREGCB *PPDMSRVREGCB;
308
309/**
310 * Callbacks for VBoxServiceRegister().
311 */
312typedef struct PDMSRVREGCB
313{
314 /** Interface version.
315 * This is set to PDM_SRVREG_CB_VERSION. */
316 uint32_t u32Version;
317
318 /**
319 * Registers a service with the current VM instance.
320 *
321 * @returns VBox status code.
322 * @param pCallbacks Pointer to the callback table.
323 * @param pSrvReg Pointer to the device registration record.
324 * This data must be permanent and readonly.
325 */
326 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMSRVREGCB pCallbacks, PCPDMSRVREG pSrvReg));
327} PDMSRVREGCB;
328
329/** Current version of the PDMSRVREGCB structure. */
330#define PDM_SRVREG_CB_VERSION PDM_VERSION_MAKE(0xdffd, 1, 0)
331
332
333/**
334 * The VBoxServicesRegister callback function.
335 *
336 * PDM will invoke this function after loading a device module and letting
337 * the module decide which devices to register and how to handle conflicts.
338 *
339 * @returns VBox status code.
340 * @param pCallbacks Pointer to the callback table.
341 * @param u32Version VBox version number.
342 */
343typedef DECLCALLBACKTYPE(int, FNPDMVBOXSERVICESREGISTER,(PPDMSRVREGCB pCallbacks, uint32_t u32Version));
344
345
346/** @} */
347
348RT_C_DECLS_END
349
350#endif /* !VBOX_INCLUDED_vmm_pdmsrv_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use