VirtualBox

source: vbox/trunk/include/VBox/pdmsrv.h@ 3880

Last change on this file since 3880 was 3854, checked in by vboxsync, 18 years ago

Splitting up pdm.h - export the fragments.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette