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