1 | /* $Id: VMMDevInterface.cpp 35346 2010-12-27 16:13:13Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox frontends: Basic Frontend (BFE):
|
---|
4 | * Implementation of VMMDev: driver interface to VMM device
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2010 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 |
|
---|
19 | #define LOG_GROUP LOG_GROUP_MAIN
|
---|
20 |
|
---|
21 | #ifdef VBOXBFE_WITHOUT_COM
|
---|
22 | # include "COMDefs.h"
|
---|
23 | #else
|
---|
24 | # include <VBox/com/defs.h>
|
---|
25 | #endif
|
---|
26 | #include <VBox/vmm/pdm.h>
|
---|
27 | #include <VBox/VMMDev.h>
|
---|
28 | #include <VBox/vmm/cfgm.h>
|
---|
29 | #include <VBox/err.h>
|
---|
30 | #include <iprt/assert.h>
|
---|
31 | #include <VBox/log.h>
|
---|
32 | #include <iprt/asm.h>
|
---|
33 | #include <iprt/uuid.h>
|
---|
34 |
|
---|
35 | #include "VBoxBFE.h"
|
---|
36 | #include "VMMDev.h"
|
---|
37 | #include "MouseImpl.h"
|
---|
38 | #include "DisplayImpl.h"
|
---|
39 | #include "ConsoleImpl.h"
|
---|
40 | #ifdef VBOX_WITH_HGCM
|
---|
41 | #include "HGCM.h"
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #ifdef RT_OS_OS2
|
---|
45 | # define VBOXSHAREDFOLDERS_DLL "VBoxSFld"
|
---|
46 | #else
|
---|
47 | # define VBOXSHAREDFOLDERS_DLL "VBoxSharedFolders"
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | #ifdef RT_OS_L4
|
---|
51 | #include <l4/util/util.h> /* for l4_sleep */
|
---|
52 | #endif
|
---|
53 | /**
|
---|
54 | * VMMDev driver instance data.
|
---|
55 | */
|
---|
56 | typedef struct DRVMAINVMMDEV
|
---|
57 | {
|
---|
58 | /** Pointer to the VMMDev object. */
|
---|
59 | VMMDev *pVMMDev;
|
---|
60 | /** Pointer to the driver instance structure. */
|
---|
61 | PPDMDRVINS pDrvIns;
|
---|
62 | /** Pointer to the VMMDev port interface of the driver/device above us. */
|
---|
63 | PPDMIVMMDEVPORT pUpPort;
|
---|
64 | /** Our VMM device connector interface. */
|
---|
65 | PDMIVMMDEVCONNECTOR Connector;
|
---|
66 |
|
---|
67 | #ifdef VBOX_WITH_HGCM
|
---|
68 | /** Pointer to the HGCM port interface of the driver/device above us. */
|
---|
69 | PPDMIHGCMPORT pHGCMPort;
|
---|
70 | /** Our HGCM connector interface. */
|
---|
71 | PDMIHGCMCONNECTOR HGCMConnector;
|
---|
72 | #endif
|
---|
73 | } DRVMAINVMMDEV, *PDRVMAINVMMDEV;
|
---|
74 |
|
---|
75 | /** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
|
---|
76 | #define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
|
---|
77 |
|
---|
78 | #ifdef VBOX_WITH_HGCM
|
---|
79 | /** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
|
---|
80 | #define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | VMMDev::VMMDev() : mpDrv(NULL)
|
---|
84 | {
|
---|
85 | #ifdef VBOX_WITH_HGCM
|
---|
86 | int rc = VINF_SUCCESS;
|
---|
87 | if (fActivateHGCM())
|
---|
88 | rc = HGCMHostInit();
|
---|
89 | AssertRC(rc);
|
---|
90 | #endif
|
---|
91 | }
|
---|
92 |
|
---|
93 | VMMDev::~VMMDev()
|
---|
94 | {
|
---|
95 | #ifdef VBOX_WITH_HGCM
|
---|
96 | if (fActivateHGCM())
|
---|
97 | HGCMHostShutdown ();
|
---|
98 | #endif /* VBOX_WITH_HGCM */
|
---|
99 | }
|
---|
100 |
|
---|
101 |
|
---|
102 | PPDMIVMMDEVPORT VMMDev::getVMMDevPort()
|
---|
103 | {
|
---|
104 | Assert(mpDrv);
|
---|
105 | return mpDrv->pUpPort;
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Reports Guest Additions status.
|
---|
111 | * Called whenever the Additions issue a guest status report request or the VM is reset.
|
---|
112 | *
|
---|
113 | * @param pInterface Pointer to this interface.
|
---|
114 | * @param guestInfo Pointer to guest information structure
|
---|
115 | * @thread The emulation thread.
|
---|
116 | */
|
---|
117 | DECLCALLBACK(void) VMMDev::UpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestStatus *guestStatus)
|
---|
118 | {
|
---|
119 | return;
|
---|
120 | }
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Report guest information.
|
---|
124 | * Called whenever the Additions issue a guest version report request.
|
---|
125 | *
|
---|
126 | * @param pInterface Pointer to this interface.
|
---|
127 | * @param guestInfo Pointer to guest information structure
|
---|
128 | * @thread The emulation thread.
|
---|
129 | */
|
---|
130 | DECLCALLBACK(void) VMMDev::UpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
|
---|
131 | {
|
---|
132 | return;
|
---|
133 | }
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Update the guest additions capabilities.
|
---|
137 | * This is called when the guest additions capabilities change. The new capabilities
|
---|
138 | * are given and the connector should update its internal state.
|
---|
139 | *
|
---|
140 | * @param pInterface Pointer to this interface.
|
---|
141 | * @param newCapabilities New capabilities.
|
---|
142 | * @thread The emulation thread.
|
---|
143 | */
|
---|
144 | DECLCALLBACK(void) VMMDev::UpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
145 | {
|
---|
146 | return;
|
---|
147 | }
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * Update the mouse capabilities.
|
---|
151 | * This is called when the mouse capabilities change. The new capabilities
|
---|
152 | * are given and the connector should update its internal state.
|
---|
153 | *
|
---|
154 | * @param pInterface Pointer to this interface.
|
---|
155 | * @param newCapabilities New capabilities.
|
---|
156 | * @thread The emulation thread.
|
---|
157 | */
|
---|
158 | DECLCALLBACK(void) VMMDev::UpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
|
---|
159 | {
|
---|
160 | /*
|
---|
161 | * Tell the console interface about the event so that it can notify its consumers.
|
---|
162 | */
|
---|
163 |
|
---|
164 | if (gMouse)
|
---|
165 | gMouse->onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
|
---|
166 | if (gConsole)
|
---|
167 | gConsole->resetCursor();
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Update the pointer shape or visibility.
|
---|
173 | *
|
---|
174 | * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
|
---|
175 | * The new shape is passed as a caller allocated buffer that will be freed after returning.
|
---|
176 | *
|
---|
177 | * @param pInterface Pointer to this interface.
|
---|
178 | * @param fVisible Whether the pointer is visible or not.
|
---|
179 | * @param fAlpha Alpha channel information is present.
|
---|
180 | * @param xHot Horizontal coordinate of the pointer hot spot.
|
---|
181 | * @param yHot Vertical coordinate of the pointer hot spot.
|
---|
182 | * @param width Pointer width in pixels.
|
---|
183 | * @param height Pointer height in pixels.
|
---|
184 | * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
|
---|
185 | * @thread The emulation thread.
|
---|
186 | */
|
---|
187 | DECLCALLBACK(void) VMMDev::UpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
188 | uint32_t xHot, uint32_t yHot,
|
---|
189 | uint32_t width, uint32_t height,
|
---|
190 | void *pShape)
|
---|
191 | {
|
---|
192 | if (gConsole)
|
---|
193 | gConsole->onMousePointerShapeChange(fVisible, fAlpha, xHot,
|
---|
194 | yHot, width, height, pShape);
|
---|
195 | }
|
---|
196 |
|
---|
197 | DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
198 | {
|
---|
199 | LogFlow(("VMMDev::VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
|
---|
200 | if (gDisplay)
|
---|
201 | gDisplay->VideoAccelEnable (fEnable, pVbvaMemory);
|
---|
202 | return VINF_SUCCESS;
|
---|
203 | }
|
---|
204 |
|
---|
205 | DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
|
---|
206 | {
|
---|
207 | if (gDisplay)
|
---|
208 | gDisplay->VideoAccelFlush ();
|
---|
209 | }
|
---|
210 |
|
---|
211 | DECLCALLBACK(int) iface_SetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
|
---|
212 | {
|
---|
213 | /* not implemented */
|
---|
214 | return VINF_SUCCESS;
|
---|
215 | }
|
---|
216 |
|
---|
217 | DECLCALLBACK(int) iface_QueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
|
---|
218 | {
|
---|
219 | /* not implemented */
|
---|
220 | return VINF_SUCCESS;
|
---|
221 | }
|
---|
222 |
|
---|
223 | DECLCALLBACK(int) VMMDev::VideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
|
---|
224 | uint32_t bpp, bool *fSupported)
|
---|
225 | {
|
---|
226 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
227 | (void)pDrv;
|
---|
228 |
|
---|
229 | if (!fSupported)
|
---|
230 | return VERR_INVALID_PARAMETER;
|
---|
231 | *fSupported = true;
|
---|
232 | return VINF_SUCCESS;
|
---|
233 | }
|
---|
234 |
|
---|
235 | DECLCALLBACK(int) VMMDev::GetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
|
---|
236 | {
|
---|
237 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
238 | (void)pDrv;
|
---|
239 |
|
---|
240 | if (!heightReduction)
|
---|
241 | return VERR_INVALID_PARAMETER;
|
---|
242 | /* XXX hard-coded */
|
---|
243 | *heightReduction = 18;
|
---|
244 | return VINF_SUCCESS;
|
---|
245 | }
|
---|
246 |
|
---|
247 | DECLCALLBACK(int) VMMDev::QueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pu32BalloonSize)
|
---|
248 | {
|
---|
249 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
250 | (void)pDrv;
|
---|
251 |
|
---|
252 | AssertPtr(pu32BalloonSize);
|
---|
253 | *pu32BalloonSize = 0;
|
---|
254 | return VINF_SUCCESS;
|
---|
255 | }
|
---|
256 |
|
---|
257 | #ifdef VBOX_WITH_HGCM
|
---|
258 |
|
---|
259 | /* HGCM connector interface */
|
---|
260 |
|
---|
261 | static DECLCALLBACK(int) iface_hgcmConnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
|
---|
262 | {
|
---|
263 | LogSunlover(("Enter\n"));
|
---|
264 |
|
---|
265 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
266 |
|
---|
267 | if ( !pServiceLocation
|
---|
268 | || ( pServiceLocation->type != VMMDevHGCMLoc_LocalHost
|
---|
269 | && pServiceLocation->type != VMMDevHGCMLoc_LocalHost_Existing))
|
---|
270 | {
|
---|
271 | return VERR_INVALID_PARAMETER;
|
---|
272 | }
|
---|
273 |
|
---|
274 | return HGCMGuestConnect (pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
|
---|
275 | }
|
---|
276 |
|
---|
277 | static DECLCALLBACK(int) iface_hgcmDisconnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
|
---|
278 | {
|
---|
279 | LogSunlover(("Enter\n"));
|
---|
280 |
|
---|
281 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
282 |
|
---|
283 | return HGCMGuestDisconnect (pDrv->pHGCMPort, pCmd, u32ClientID);
|
---|
284 | }
|
---|
285 |
|
---|
286 | static DECLCALLBACK(int) iface_hgcmCall (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
|
---|
287 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
288 | {
|
---|
289 | LogSunlover(("Enter\n"));
|
---|
290 |
|
---|
291 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
292 |
|
---|
293 | return HGCMGuestCall (pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms);
|
---|
294 | }
|
---|
295 |
|
---|
296 | /**
|
---|
297 | * Execute state save operation.
|
---|
298 | *
|
---|
299 | * @returns VBox status code.
|
---|
300 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
301 | * @param pSSM SSM operation handle.
|
---|
302 | */
|
---|
303 | static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
|
---|
304 | {
|
---|
305 | LogSunlover(("Enter\n"));
|
---|
306 | return HGCMHostSaveState (pSSM);
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 | /**
|
---|
311 | * Execute state load operation.
|
---|
312 | *
|
---|
313 | * @returns VBox status code.
|
---|
314 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
315 | * @param pSSM SSM operation handle.
|
---|
316 | * @param uVersion Data layout version.
|
---|
317 | * @param uPass The data pass.
|
---|
318 | */
|
---|
319 | static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
320 | {
|
---|
321 | LogFlowFunc(("Enter\n"));
|
---|
322 |
|
---|
323 | if (uVersion != HGCM_SSM_VERSION)
|
---|
324 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
325 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
326 |
|
---|
327 | return HGCMHostLoadState (pSSM);
|
---|
328 | }
|
---|
329 |
|
---|
330 | int VMMDev::hgcmLoadService (const char *pszServiceLibrary, const char *pszServiceName)
|
---|
331 | {
|
---|
332 | return HGCMHostLoad (pszServiceLibrary, pszServiceName);
|
---|
333 | }
|
---|
334 |
|
---|
335 | int VMMDev::hgcmHostCall (const char *pszServiceName, uint32_t u32Function,
|
---|
336 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
337 | {
|
---|
338 | return HGCMHostCall (pszServiceName, u32Function, cParms, paParms);
|
---|
339 | }
|
---|
340 | #endif /* HGCM */
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
344 | */
|
---|
345 | DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
346 | {
|
---|
347 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
348 | PDRVMAINVMMDEV pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
349 | if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
|
---|
350 | return &pDrvIns->IBase;
|
---|
351 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVCONNECTOR, &pDrv->Connector);
|
---|
352 | #ifdef VBOX_WITH_HGCM
|
---|
353 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMCONNECTOR, fActivateHGCM() ? &pDrv->HGCMConnector : NULL);
|
---|
354 | #endif
|
---|
355 | return NULL;
|
---|
356 | }
|
---|
357 |
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Destruct a VMMDev driver instance.
|
---|
361 | *
|
---|
362 | * @returns VBox status.
|
---|
363 | * @param pDrvIns The driver instance data.
|
---|
364 | */
|
---|
365 | DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
|
---|
366 | {
|
---|
367 | /*PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV); - unused variables makes gcc bitch. */
|
---|
368 | }
|
---|
369 |
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Construct a VMMDev driver instance.
|
---|
373 | *
|
---|
374 | * @copydoc FNPDMDRVCONSTRUCT
|
---|
375 | */
|
---|
376 | DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
|
---|
377 | {
|
---|
378 | PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
379 | LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
380 |
|
---|
381 | /*
|
---|
382 | * Validate configuration.
|
---|
383 | */
|
---|
384 | if (!CFGMR3AreValuesValid(pCfg, "Object\0"))
|
---|
385 | return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
|
---|
386 | AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
|
---|
387 | ("Configuration error: Not possible to attach anything to this driver!\n"),
|
---|
388 | VERR_PDM_DRVINS_NO_ATTACH);
|
---|
389 |
|
---|
390 | /*
|
---|
391 | * IBase.
|
---|
392 | */
|
---|
393 | pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
|
---|
394 |
|
---|
395 | pData->Connector.pfnUpdateGuestStatus = VMMDev::UpdateGuestStatus;
|
---|
396 | pData->Connector.pfnUpdateGuestInfo = VMMDev::UpdateGuestInfo;
|
---|
397 | pData->Connector.pfnUpdateGuestCapabilities = VMMDev::UpdateGuestCapabilities;
|
---|
398 | pData->Connector.pfnUpdateMouseCapabilities = VMMDev::UpdateMouseCapabilities;
|
---|
399 | pData->Connector.pfnUpdatePointerShape = VMMDev::UpdatePointerShape;
|
---|
400 | pData->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
|
---|
401 | pData->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
|
---|
402 | pData->Connector.pfnVideoModeSupported = VMMDev::VideoModeSupported;
|
---|
403 | pData->Connector.pfnGetHeightReduction = VMMDev::GetHeightReduction;
|
---|
404 | pData->Connector.pfnSetVisibleRegion = iface_SetVisibleRegion;
|
---|
405 | pData->Connector.pfnQueryVisibleRegion = iface_QueryVisibleRegion;
|
---|
406 | pData->Connector.pfnQueryBalloonSize = VMMDev::QueryBalloonSize;
|
---|
407 |
|
---|
408 | #ifdef VBOX_WITH_HGCM
|
---|
409 | if (fActivateHGCM())
|
---|
410 | {
|
---|
411 | pData->HGCMConnector.pfnConnect = iface_hgcmConnect;
|
---|
412 | pData->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
|
---|
413 | pData->HGCMConnector.pfnCall = iface_hgcmCall;
|
---|
414 | }
|
---|
415 | #endif
|
---|
416 |
|
---|
417 | /*
|
---|
418 | * Get the IVMMDevPort interface of the above driver/device.
|
---|
419 | */
|
---|
420 | pData->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIVMMDEVPORT);
|
---|
421 | AssertMsgReturn(pData->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
422 |
|
---|
423 | #ifdef VBOX_WITH_HGCM
|
---|
424 | if (fActivateHGCM())
|
---|
425 | {
|
---|
426 | pData->pHGCMPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIHGCMPORT);
|
---|
427 | AssertMsgReturn(pData->pHGCMPort, ("Configuration error: No HGCM port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
428 | }
|
---|
429 | #endif
|
---|
430 |
|
---|
431 | /*
|
---|
432 | * Get the VMMDev object pointer and update the mpDrv member.
|
---|
433 | */
|
---|
434 | void *pv;
|
---|
435 | int rc = CFGMR3QueryPtr(pCfg, "Object", &pv);
|
---|
436 | if (RT_FAILURE(rc))
|
---|
437 | {
|
---|
438 | AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
|
---|
439 | return rc;
|
---|
440 | }
|
---|
441 |
|
---|
442 | pData->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
|
---|
443 | pData->pVMMDev->mpDrv = pData;
|
---|
444 |
|
---|
445 | #ifdef VBOX_WITH_HGCM
|
---|
446 | if (fActivateHGCM())
|
---|
447 | {
|
---|
448 | rc = pData->pVMMDev->hgcmLoadService (VBOXSHAREDFOLDERS_DLL, "VBoxSharedFolders");
|
---|
449 | pData->pVMMDev->fSharedFolderActive = RT_SUCCESS(rc);
|
---|
450 | if (RT_SUCCESS(rc))
|
---|
451 | LogRel(("Shared Folders service loaded.\n"));
|
---|
452 | else
|
---|
453 | LogRel(("Failed to load Shared Folders service %Rrc\n", rc));
|
---|
454 |
|
---|
455 |
|
---|
456 | rc = PDMDrvHlpSSMRegisterEx(pDrvIns, HGCM_SSM_VERSION, 4096 /* bad guess */,
|
---|
457 | NULL, NULL, NULL,
|
---|
458 | NULL, iface_hgcmSave, NULL,
|
---|
459 | NULL, iface_hgcmLoad, NULL);
|
---|
460 | if (RT_FAILURE(rc))
|
---|
461 | return rc;
|
---|
462 |
|
---|
463 | }
|
---|
464 | #endif /* VBOX_WITH_HGCM */
|
---|
465 |
|
---|
466 | return VINF_SUCCESS;
|
---|
467 | }
|
---|
468 |
|
---|
469 |
|
---|
470 | /**
|
---|
471 | * VMMDevice driver registration record.
|
---|
472 | */
|
---|
473 | const PDMDRVREG VMMDev::DrvReg =
|
---|
474 | {
|
---|
475 | /* u32Version */
|
---|
476 | PDM_DRVREG_VERSION,
|
---|
477 | /* szName */
|
---|
478 | "HGCM",
|
---|
479 | /* szRCMod */
|
---|
480 | "",
|
---|
481 | /* szR0Mod */
|
---|
482 | "",
|
---|
483 | /* pszDescription */
|
---|
484 | "Main VMMDev driver (Main as in the API).",
|
---|
485 | /* fFlags */
|
---|
486 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
487 | /* fClass. */
|
---|
488 | PDM_DRVREG_CLASS_VMMDEV,
|
---|
489 | /* cMaxInstances */
|
---|
490 | ~0,
|
---|
491 | /* cbInstance */
|
---|
492 | sizeof(DRVMAINVMMDEV),
|
---|
493 | /* pfnConstruct */
|
---|
494 | VMMDev::drvConstruct,
|
---|
495 | /* pfnDestruct */
|
---|
496 | VMMDev::drvDestruct,
|
---|
497 | /* pfnRelocate */
|
---|
498 | NULL,
|
---|
499 | /* pfnIOCtl */
|
---|
500 | NULL,
|
---|
501 | /* pfnPowerOn */
|
---|
502 | NULL,
|
---|
503 | /* pfnReset */
|
---|
504 | NULL,
|
---|
505 | /* pfnSuspend */
|
---|
506 | NULL,
|
---|
507 | /* pfnResume */
|
---|
508 | NULL,
|
---|
509 | /* pfnAttach */
|
---|
510 | NULL,
|
---|
511 | /* pfnDetach */
|
---|
512 | NULL,
|
---|
513 | /* pfnPowerOff */
|
---|
514 | NULL,
|
---|
515 | /* pfnSoftReset */
|
---|
516 | NULL,
|
---|
517 | /* u32EndVersion */
|
---|
518 | PDM_DRVREG_VERSION
|
---|
519 | };
|
---|
520 |
|
---|