1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Basic Frontend (BFE):
|
---|
4 | * Implementation of VMMDev: driver interface to VMM device
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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/pdm.h>
|
---|
27 | #include <VBox/VBoxDev.h>
|
---|
28 | #include <VBox/VBoxGuest.h>
|
---|
29 | #include <VBox/cfgm.h>
|
---|
30 | #include <VBox/err.h>
|
---|
31 | #include <iprt/assert.h>
|
---|
32 | #include <VBox/log.h>
|
---|
33 | #include <iprt/asm.h>
|
---|
34 |
|
---|
35 | #include "VBoxBFE.h"
|
---|
36 | #include "VMMDevInterface.h"
|
---|
37 | #include "MouseImpl.h"
|
---|
38 | #include "DisplayImpl.h"
|
---|
39 | #include "ConsoleImpl.h"
|
---|
40 | #ifdef VBOX_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_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_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_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_HGCM
|
---|
96 | if (fActivateHGCM())
|
---|
97 | HGCMHostShutdown ();
|
---|
98 | #endif /* VBOX_HGCM */
|
---|
99 | }
|
---|
100 |
|
---|
101 |
|
---|
102 | PPDMIVMMDEVPORT VMMDev::getVMMDevPort()
|
---|
103 | {
|
---|
104 | Assert(mpDrv);
|
---|
105 | return mpDrv->pUpPort;
|
---|
106 | }
|
---|
107 |
|
---|
108 | int VMMDev::SetMouseCapabilities(uint32_t mouseCaps)
|
---|
109 | {
|
---|
110 | return mpDrv->pUpPort->pfnSetMouseCapabilities(mpDrv->pUpPort, mouseCaps);
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | int VMMDev::SetAbsoluteMouse(uint32_t mouseXAbs, uint32_t mouseYAbs)
|
---|
115 | {
|
---|
116 | return mpDrv->pUpPort->pfnSetAbsoluteMouse(mpDrv->pUpPort, mouseXAbs, mouseYAbs);
|
---|
117 | }
|
---|
118 |
|
---|
119 | void VMMDev::QueryMouseCapabilities(uint32_t *pMouseCaps)
|
---|
120 | {
|
---|
121 |
|
---|
122 | Assert(mpDrv);
|
---|
123 | mpDrv->pUpPort->pfnQueryMouseCapabilities(mpDrv->pUpPort, pMouseCaps);
|
---|
124 | }
|
---|
125 |
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Report guest OS version.
|
---|
129 | * Called whenever the Additions issue a guest version report request.
|
---|
130 | *
|
---|
131 | * @param pInterface Pointer to this interface.
|
---|
132 | * @param guestInfo Pointer to guest information structure
|
---|
133 | * @thread The emulation thread.
|
---|
134 | */
|
---|
135 | DECLCALLBACK(void) VMMDev::UpdateGuestVersion(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestInfo *guestInfo)
|
---|
136 | {
|
---|
137 | return;
|
---|
138 | }
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Update the guest additions capabilities.
|
---|
142 | * This is called when the guest additions capabilities change. The new capabilities
|
---|
143 | * are given and the connector should update its internal state.
|
---|
144 | *
|
---|
145 | * @param pInterface Pointer to this interface.
|
---|
146 | * @param newCapabilities New capabilities.
|
---|
147 | * @thread The emulation thread.
|
---|
148 | */
|
---|
149 | DECLCALLBACK(void) VMMDev::UpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
150 | {
|
---|
151 | return;
|
---|
152 | }
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Update the mouse capabilities.
|
---|
156 | * This is called when the mouse capabilities change. The new capabilities
|
---|
157 | * are given and the connector should update its internal state.
|
---|
158 | *
|
---|
159 | * @param pInterface Pointer to this interface.
|
---|
160 | * @param newCapabilities New capabilities.
|
---|
161 | * @thread The emulation thread.
|
---|
162 | */
|
---|
163 | DECLCALLBACK(void) VMMDev::UpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
164 | {
|
---|
165 | /*
|
---|
166 | * Tell the console interface about the event so that it can notify its consumers.
|
---|
167 | */
|
---|
168 |
|
---|
169 | if (gMouse)
|
---|
170 | {
|
---|
171 | gMouse->setAbsoluteCoordinates(!!(newCapabilities & VMMDEV_MOUSEGUESTWANTSABS));
|
---|
172 | gMouse->setNeedsHostCursor(!!(newCapabilities & VMMDEV_MOUSEGUESTNEEDSHOSTCUR));
|
---|
173 | }
|
---|
174 | if (gConsole)
|
---|
175 | {
|
---|
176 | gConsole->resetCursor();
|
---|
177 | }
|
---|
178 | }
|
---|
179 |
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Update the pointer shape or visibility.
|
---|
183 | *
|
---|
184 | * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
|
---|
185 | * The new shape is passed as a caller allocated buffer that will be freed after returning.
|
---|
186 | *
|
---|
187 | * @param pInterface Pointer to this interface.
|
---|
188 | * @param fVisible Whether the pointer is visible or not.
|
---|
189 | * @param fAlpha Alpha channel information is present.
|
---|
190 | * @param xHot Horizontal coordinate of the pointer hot spot.
|
---|
191 | * @param yHot Vertical coordinate of the pointer hot spot.
|
---|
192 | * @param width Pointer width in pixels.
|
---|
193 | * @param height Pointer height in pixels.
|
---|
194 | * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
|
---|
195 | * @thread The emulation thread.
|
---|
196 | */
|
---|
197 | DECLCALLBACK(void) VMMDev::UpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
198 | uint32_t xHot, uint32_t yHot,
|
---|
199 | uint32_t width, uint32_t height,
|
---|
200 | void *pShape)
|
---|
201 | {
|
---|
202 | if (gConsole)
|
---|
203 | gConsole->onMousePointerShapeChange(fVisible, fAlpha, xHot,
|
---|
204 | yHot, width, height, pShape);
|
---|
205 | }
|
---|
206 |
|
---|
207 | DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
208 | {
|
---|
209 | LogFlow(("VMMDev::VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
|
---|
210 | if (gDisplay)
|
---|
211 | gDisplay->VideoAccelEnable (fEnable, pVbvaMemory);
|
---|
212 | return VINF_SUCCESS;
|
---|
213 | }
|
---|
214 |
|
---|
215 | DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
|
---|
216 | {
|
---|
217 | if (gDisplay)
|
---|
218 | gDisplay->VideoAccelFlush ();
|
---|
219 | }
|
---|
220 |
|
---|
221 | DECLCALLBACK(int) iface_SetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
|
---|
222 | {
|
---|
223 | /* not implemented */
|
---|
224 | return VINF_SUCCESS;
|
---|
225 | }
|
---|
226 |
|
---|
227 | DECLCALLBACK(int) iface_QueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
|
---|
228 | {
|
---|
229 | /* not implemented */
|
---|
230 | return VINF_SUCCESS;
|
---|
231 | }
|
---|
232 |
|
---|
233 | DECLCALLBACK(int) VMMDev::VideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t width, uint32_t height,
|
---|
234 | uint32_t bpp, bool *fSupported)
|
---|
235 | {
|
---|
236 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
237 | (void)pDrv;
|
---|
238 |
|
---|
239 | if (!fSupported)
|
---|
240 | return VERR_INVALID_PARAMETER;
|
---|
241 | *fSupported = true;
|
---|
242 | return VINF_SUCCESS;
|
---|
243 | }
|
---|
244 |
|
---|
245 | DECLCALLBACK(int) VMMDev::GetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
|
---|
246 | {
|
---|
247 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
248 | (void)pDrv;
|
---|
249 |
|
---|
250 | if (!heightReduction)
|
---|
251 | return VERR_INVALID_PARAMETER;
|
---|
252 | /* XXX hard-coded */
|
---|
253 | *heightReduction = 18;
|
---|
254 | return VINF_SUCCESS;
|
---|
255 | }
|
---|
256 |
|
---|
257 | #ifdef VBOX_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 u32Version Data layout version.
|
---|
317 | */
|
---|
318 | static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t u32Version)
|
---|
319 | {
|
---|
320 | LogFlowFunc(("Enter\n"));
|
---|
321 |
|
---|
322 | if (u32Version != HGCM_SSM_VERSION)
|
---|
323 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
324 |
|
---|
325 | return HGCMHostLoadState (pSSM);
|
---|
326 | }
|
---|
327 |
|
---|
328 | int VMMDev::hgcmLoadService (const char *pszServiceLibrary, const char *pszServiceName)
|
---|
329 | {
|
---|
330 | return HGCMHostLoad (pszServiceLibrary, pszServiceName);
|
---|
331 | }
|
---|
332 |
|
---|
333 | int VMMDev::hgcmHostCall (const char *pszServiceName, uint32_t u32Function,
|
---|
334 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
335 | {
|
---|
336 | return HGCMHostCall (pszServiceName, u32Function, cParms, paParms);
|
---|
337 | }
|
---|
338 | #endif /* HGCM */
|
---|
339 |
|
---|
340 | /**
|
---|
341 | * Queries an interface to the driver.
|
---|
342 | *
|
---|
343 | * @returns Pointer to interface.
|
---|
344 | * @returns NULL if the interface was not supported by the driver.
|
---|
345 | * @param pInterface Pointer to this interface structure.
|
---|
346 | * @param enmInterface The requested interface identification.
|
---|
347 | */
|
---|
348 | DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
|
---|
349 | {
|
---|
350 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
351 | PDRVMAINVMMDEV pDrv = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
352 | switch (enmInterface)
|
---|
353 | {
|
---|
354 | case PDMINTERFACE_BASE:
|
---|
355 | return &pDrvIns->IBase;
|
---|
356 | case PDMINTERFACE_VMMDEV_CONNECTOR:
|
---|
357 | return &pDrv->Connector;
|
---|
358 | #ifdef VBOX_HGCM
|
---|
359 | case PDMINTERFACE_HGCM_CONNECTOR:
|
---|
360 | if (fActivateHGCM())
|
---|
361 | return &pDrv->HGCMConnector;
|
---|
362 | else
|
---|
363 | return NULL;
|
---|
364 | #endif
|
---|
365 | default:
|
---|
366 | return NULL;
|
---|
367 | }
|
---|
368 | }
|
---|
369 |
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Destruct a VMMDev driver instance.
|
---|
373 | *
|
---|
374 | * @returns VBox status.
|
---|
375 | * @param pDrvIns The driver instance data.
|
---|
376 | */
|
---|
377 | DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
|
---|
378 | {
|
---|
379 | /*PDRVMAINVMMDEV pData = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV); - unused variables makes gcc bitch. */
|
---|
380 | }
|
---|
381 |
|
---|
382 |
|
---|
383 | /**
|
---|
384 | * Construct a VMMDev driver instance.
|
---|
385 | *
|
---|
386 | * @returns VBox status.
|
---|
387 | * @param pDrvIns The driver instance data.
|
---|
388 | * If the registration structure is needed, pDrvIns->pDrvReg points to it.
|
---|
389 | * @param pCfgHandle Configuration node handle for the driver. Use this to obtain the configuration
|
---|
390 | * of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
|
---|
391 | * iInstance it's expected to be used a bit in this function.
|
---|
392 | */
|
---|
393 | DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
|
---|
394 | {
|
---|
395 | PDRVMAINVMMDEV pData = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
396 | LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
397 |
|
---|
398 | /*
|
---|
399 | * Validate configuration.
|
---|
400 | */
|
---|
401 | if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
|
---|
402 | return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
|
---|
403 |
|
---|
404 | PPDMIBASE pBaseIgnore;
|
---|
405 | int rc = pDrvIns->pDrvHlp->pfnAttach(pDrvIns, &pBaseIgnore);
|
---|
406 | if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
407 | {
|
---|
408 | AssertMsgFailed(("Configuration error: Not possible to attach anything to this driver!\n"));
|
---|
409 | return VERR_PDM_DRVINS_NO_ATTACH;
|
---|
410 | }
|
---|
411 |
|
---|
412 | /*
|
---|
413 | * IBase.
|
---|
414 | */
|
---|
415 | pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
|
---|
416 |
|
---|
417 | pData->Connector.pfnUpdateGuestVersion = VMMDev::UpdateGuestVersion;
|
---|
418 | pData->Connector.pfnUpdateGuestCapabilities = VMMDev::UpdateGuestCapabilities;
|
---|
419 | pData->Connector.pfnUpdateMouseCapabilities = VMMDev::UpdateMouseCapabilities;
|
---|
420 | pData->Connector.pfnUpdatePointerShape = VMMDev::UpdatePointerShape;
|
---|
421 | pData->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
|
---|
422 | pData->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
|
---|
423 | pData->Connector.pfnVideoModeSupported = VMMDev::VideoModeSupported;
|
---|
424 | pData->Connector.pfnGetHeightReduction = VMMDev::GetHeightReduction;
|
---|
425 | pData->Connector.pfnSetVisibleRegion = iface_SetVisibleRegion;
|
---|
426 | pData->Connector.pfnQueryVisibleRegion = iface_QueryVisibleRegion;
|
---|
427 |
|
---|
428 | #ifdef VBOX_HGCM
|
---|
429 | if (fActivateHGCM())
|
---|
430 | {
|
---|
431 | pData->HGCMConnector.pfnConnect = iface_hgcmConnect;
|
---|
432 | pData->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
|
---|
433 | pData->HGCMConnector.pfnCall = iface_hgcmCall;
|
---|
434 | }
|
---|
435 | #endif
|
---|
436 |
|
---|
437 | /*
|
---|
438 | * Get the IVMMDevPort interface of the above driver/device.
|
---|
439 | */
|
---|
440 | pData->pUpPort = (PPDMIVMMDEVPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_VMMDEV_PORT);
|
---|
441 | if (!pData->pUpPort)
|
---|
442 | {
|
---|
443 | AssertMsgFailed(("Configuration error: No VMMDev port interface above!\n"));
|
---|
444 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
445 | }
|
---|
446 |
|
---|
447 | #ifdef VBOX_HGCM
|
---|
448 | if (fActivateHGCM())
|
---|
449 | {
|
---|
450 | pData->pHGCMPort = (PPDMIHGCMPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HGCM_PORT);
|
---|
451 | if (!pData->pHGCMPort)
|
---|
452 | {
|
---|
453 | AssertMsgFailed(("Configuration error: No HGCM port interface above!\n"));
|
---|
454 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
455 | }
|
---|
456 | }
|
---|
457 | #endif
|
---|
458 |
|
---|
459 | /*
|
---|
460 | * Get the VMMDev object pointer and update the mpDrv member.
|
---|
461 | */
|
---|
462 | void *pv;
|
---|
463 | rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
|
---|
464 | if (VBOX_FAILURE(rc))
|
---|
465 | {
|
---|
466 | AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Vrc\n", rc));
|
---|
467 | return rc;
|
---|
468 | }
|
---|
469 |
|
---|
470 | pData->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
|
---|
471 | pData->pVMMDev->mpDrv = pData;
|
---|
472 |
|
---|
473 | #ifdef VBOX_HGCM
|
---|
474 | if (fActivateHGCM())
|
---|
475 | {
|
---|
476 | rc = pData->pVMMDev->hgcmLoadService (VBOXSHAREDFOLDERS_DLL, "VBoxSharedFolders");
|
---|
477 | pData->pVMMDev->fSharedFolderActive = VBOX_SUCCESS(rc);
|
---|
478 | if (VBOX_SUCCESS(rc))
|
---|
479 | LogRel(("Shared Folders service loaded.\n"));
|
---|
480 | else
|
---|
481 | LogRel(("Failed to load Shared Folders service %Vrc\n", rc));
|
---|
482 |
|
---|
483 | pDrvIns->pDrvHlp->pfnSSMRegister(pDrvIns, "HGCM", 0, HGCM_SSM_VERSION, 4096/* bad guess */, NULL, iface_hgcmSave, NULL, NULL, iface_hgcmLoad, NULL);
|
---|
484 | }
|
---|
485 | #endif /* VBOX_HGCM */
|
---|
486 |
|
---|
487 | return VINF_SUCCESS;
|
---|
488 | }
|
---|
489 |
|
---|
490 |
|
---|
491 | /**
|
---|
492 | * VMMDevice driver registration record.
|
---|
493 | */
|
---|
494 | const PDMDRVREG VMMDev::DrvReg =
|
---|
495 | {
|
---|
496 | /* u32Version */
|
---|
497 | PDM_DRVREG_VERSION,
|
---|
498 | /* szDriverName */
|
---|
499 | "MainVMMDev",
|
---|
500 | /* pszDescription */
|
---|
501 | "Main VMMDev driver (Main as in the API).",
|
---|
502 | /* fFlags */
|
---|
503 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
504 | /* fClass. */
|
---|
505 | PDM_DRVREG_CLASS_VMMDEV,
|
---|
506 | /* cMaxInstances */
|
---|
507 | ~0,
|
---|
508 | /* cbInstance */
|
---|
509 | sizeof(DRVMAINVMMDEV),
|
---|
510 | /* pfnConstruct */
|
---|
511 | VMMDev::drvConstruct,
|
---|
512 | /* pfnDestruct */
|
---|
513 | VMMDev::drvDestruct,
|
---|
514 | /* pfnIOCtl */
|
---|
515 | NULL,
|
---|
516 | /* pfnPowerOn */
|
---|
517 | NULL,
|
---|
518 | /* pfnReset */
|
---|
519 | NULL,
|
---|
520 | /* pfnSuspend */
|
---|
521 | NULL,
|
---|
522 | /* pfnResume */
|
---|
523 | NULL,
|
---|
524 | /* pfnDetach */
|
---|
525 | NULL
|
---|
526 | };
|
---|