VirtualBox

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

Last change on this file since 93593 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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