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