VirtualBox

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

Last change on this file since 77548 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 11.1 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-2019 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 DECLCALLBACK(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 DECLCALLBACK(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 DECLCALLBACK(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 DECLCALLBACK(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 DECLCALLBACK(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 DECLCALLBACK(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 DECLCALLBACK(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 */
126typedef DECLCALLBACK(void) FNPDMSRVDETACH(PPDMSRVINS pSrvIns, PPDMDEVINS pDevIns, PPDMDRVINS pDrvIns);
127/** Pointer to a FNPDMSRVDETACH() function. */
128typedef FNPDMSRVDETACH *PFNPDMSRVDETACH;
129
130
131
132/** PDM Service Registration Structure,
133 * This structure is used when registering a driver from
134 * VBoxServicesRegister() (HC Ring-3). PDM will continue use till
135 * the VM is terminated.
136 */
137typedef struct PDMSRVREG
138{
139 /** Structure version. PDM_SRVREG_VERSION defines the current version. */
140 uint32_t u32Version;
141 /** Driver name. */
142 char szServiceName[32];
143 /** The description of the driver. The UTF-8 string pointed to shall, like this structure,
144 * remain unchanged from registration till VM destruction. */
145 const char *pszDescription;
146
147 /** Flags, combination of the PDM_SRVREG_FLAGS_* \#defines. */
148 RTUINT fFlags;
149 /** Size of the instance data. */
150 RTUINT cbInstance;
151
152 /** Construct instance - required. */
153 PFNPDMSRVCONSTRUCT pfnConstruct;
154 /** Destruct instance - optional. */
155 PFNPDMSRVDESTRUCT pfnDestruct;
156 /** Power on notification - optional. */
157 PFNPDMSRVPOWERON pfnPowerOn;
158 /** Reset notification - optional. */
159 PFNPDMSRVRESET pfnReset;
160 /** Suspend notification - optional. */
161 PFNPDMSRVSUSPEND pfnSuspend;
162 /** Resume notification - optional. */
163 PFNPDMSRVRESUME pfnResume;
164 /** Detach notification - optional. */
165 PFNPDMSRVDETACH pfnDetach;
166 /** Power off notification - optional. */
167 PFNPDMSRVPOWEROFF pfnPowerOff;
168
169} PDMSRVREG;
170/** Pointer to a PDM Driver Structure. */
171typedef PDMSRVREG *PPDMSRVREG;
172/** Const pointer to a PDM Driver Structure. */
173typedef PDMSRVREG const *PCPDMSRVREG;
174
175
176
177/**
178 * PDM Service API.
179 */
180typedef struct PDMSRVHLP
181{
182 /** Structure version. PDM_SRVHLP_VERSION defines the current version. */
183 uint32_t u32Version;
184
185 /**
186 * Assert that the current thread is the emulation thread.
187 *
188 * @returns True if correct.
189 * @returns False if wrong.
190 * @param pSrvIns Service instance.
191 * @param pszFile Filename of the assertion location.
192 * @param iLine Linenumber of the assertion location.
193 * @param pszFunction Function of the assertion location.
194 */
195 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMSRVINS pSrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
196
197 /**
198 * Assert that the current thread is NOT 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, pfnAssertOther,(PPDMSRVINS pSrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
208
209 /**
210 * Creates a timer.
211 *
212 * @returns VBox status.
213 * @param pVM The cross context VM structure.
214 * @param pSrvIns Service instance.
215 * @param enmClock The clock to use on this timer.
216 * @param pfnCallback Callback function.
217 * @param pszDesc Pointer to description string which must stay around
218 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
219 * @param ppTimer Where to store the timer on success.
220 */
221 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMSRVINS pSrvIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer));
222
223 /**
224 * Query the virtual timer frequency.
225 *
226 * @returns Frequency in Hz.
227 * @param pSrvIns Service instance.
228 * @thread Any thread.
229 */
230 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMSRVINS pSrvIns));
231
232 /**
233 * Query the virtual time.
234 *
235 * @returns The current virtual time.
236 * @param pSrvIns Service instance.
237 * @thread Any thread.
238 */
239 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMSRVINS pSrvIns));
240
241} PDMSRVHLP;
242/** Pointer PDM Service API. */
243typedef PDMSRVHLP *PPDMSRVHLP;
244/** Pointer const PDM Service API. */
245typedef const PDMSRVHLP *PCPDMSRVHLP;
246
247/** Current SRVHLP version number. */
248#define PDM_SRVHLP_VERSION PDM_VERSION_MAKE(0xdfff, 1, 0)
249
250
251/**
252 * PDM Service Instance.
253 */
254typedef struct PDMSRVINS
255{
256 /** Structure version. PDM_SRVINS_VERSION defines the current version. */
257 uint32_t u32Version;
258
259 /** Internal data. */
260 union
261 {
262#ifdef PDMSRVINSINT_DECLARED
263 PDMSRVINSINT s;
264#endif
265 uint8_t padding[HC_ARCH_BITS == 32 ? 32 : 32];
266 } Internal;
267
268 /** Pointer the PDM Service API. */
269 R3PTRTYPE(PCPDMSRVHLP) pHlp;
270 /** Pointer to driver registration structure. */
271 R3PTRTYPE(PCPDMSRVREG) pReg;
272 /** Configuration handle. */
273 R3PTRTYPE(PCFGMNODE) pCfg;
274 /** The base interface of the service.
275 * The service constructor initializes this. */
276 PDMIBASE IBase;
277 /* padding to make achInstanceData aligned at 16 byte boundary. */
278 uint32_t au32Padding[2];
279 /** Pointer to driver instance data. */
280 R3PTRTYPE(void *) pvInstanceData;
281 /** Driver instance data. The size of this area is defined
282 * in the PDMSRVREG::cbInstanceData field. */
283 char achInstanceData[4];
284} PDMSRVINS;
285
286/** Current PDMSRVREG version number. */
287#define PDM_SRVINS_VERSION PDM_VERSION_MAKE(0xdffe, 1, 0)
288
289/** Converts a pointer to the PDMSRVINS::IBase to a pointer to PDMSRVINS. */
290#define PDMIBASE_2_PDMSRV(pInterface) ( (PPDMSRVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMSRVINS, IBase)) )
291
292
293
294/** Pointer to callbacks provided to the VBoxServiceRegister() call. */
295typedef struct PDMSRVREGCB *PPDMSRVREGCB;
296
297/**
298 * Callbacks for VBoxServiceRegister().
299 */
300typedef struct PDMSRVREGCB
301{
302 /** Interface version.
303 * This is set to PDM_SRVREG_CB_VERSION. */
304 uint32_t u32Version;
305
306 /**
307 * Registers a service with the current VM instance.
308 *
309 * @returns VBox status code.
310 * @param pCallbacks Pointer to the callback table.
311 * @param pSrvReg Pointer to the device registration record.
312 * This data must be permanent and readonly.
313 */
314 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMSRVREGCB pCallbacks, PCPDMSRVREG pSrvReg));
315} PDMSRVREGCB;
316
317/** Current version of the PDMSRVREGCB structure. */
318#define PDM_SRVREG_CB_VERSION PDM_VERSION_MAKE(0xdffd, 1, 0)
319
320
321/**
322 * The VBoxServicesRegister callback function.
323 *
324 * PDM will invoke this function after loading a device module and letting
325 * the module decide which devices to register and how to handle conflicts.
326 *
327 * @returns VBox status code.
328 * @param pCallbacks Pointer to the callback table.
329 * @param u32Version VBox version number.
330 */
331typedef DECLCALLBACK(int) FNPDMVBOXSERVICESREGISTER(PPDMSRVREGCB pCallbacks, uint32_t u32Version);
332
333
334/** @} */
335
336RT_C_DECLS_END
337
338#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