1 | /* $Id: VMMDevInterface.cpp 45029 2013-03-13 20:57:11Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Driver Interface to VMM device.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include "VMMDev.h"
|
---|
19 | #include "ConsoleImpl.h"
|
---|
20 | #include "DisplayImpl.h"
|
---|
21 | #include "GuestImpl.h"
|
---|
22 | #include "MouseImpl.h"
|
---|
23 |
|
---|
24 | #include "Logging.h"
|
---|
25 |
|
---|
26 | #include <VBox/vmm/pdmdrv.h>
|
---|
27 | #include <VBox/VMMDev.h>
|
---|
28 | #include <VBox/shflsvc.h>
|
---|
29 | #include <iprt/asm.h>
|
---|
30 |
|
---|
31 | #ifdef VBOX_WITH_HGCM
|
---|
32 | # include "HGCM.h"
|
---|
33 | # include "HGCMObjects.h"
|
---|
34 | # if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
|
---|
35 | # include <VBox/HostServices/VBoxCrOpenGLSvc.h>
|
---|
36 | # endif
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | //
|
---|
40 | // defines
|
---|
41 | //
|
---|
42 |
|
---|
43 | #ifdef RT_OS_OS2
|
---|
44 | # define VBOXSHAREDFOLDERS_DLL "VBoxSFld"
|
---|
45 | #else
|
---|
46 | # define VBOXSHAREDFOLDERS_DLL "VBoxSharedFolders"
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | //
|
---|
50 | // globals
|
---|
51 | //
|
---|
52 |
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * VMMDev driver instance data.
|
---|
56 | */
|
---|
57 | typedef struct DRVMAINVMMDEV
|
---|
58 | {
|
---|
59 | /** Pointer to the VMMDev object. */
|
---|
60 | VMMDev *pVMMDev;
|
---|
61 | /** Pointer to the driver instance structure. */
|
---|
62 | PPDMDRVINS pDrvIns;
|
---|
63 | /** Pointer to the VMMDev port interface of the driver/device above us. */
|
---|
64 | PPDMIVMMDEVPORT pUpPort;
|
---|
65 | /** Our VMM device connector interface. */
|
---|
66 | PDMIVMMDEVCONNECTOR Connector;
|
---|
67 |
|
---|
68 | #ifdef VBOX_WITH_HGCM
|
---|
69 | /** Pointer to the HGCM port interface of the driver/device above us. */
|
---|
70 | PPDMIHGCMPORT pHGCMPort;
|
---|
71 | /** Our HGCM connector interface. */
|
---|
72 | PDMIHGCMCONNECTOR HGCMConnector;
|
---|
73 | #endif
|
---|
74 | } DRVMAINVMMDEV, *PDRVMAINVMMDEV;
|
---|
75 |
|
---|
76 | /** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
|
---|
77 | #define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
|
---|
78 |
|
---|
79 | #ifdef VBOX_WITH_HGCM
|
---|
80 | /** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
|
---|
81 | #define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | //
|
---|
85 | // constructor / destructor
|
---|
86 | //
|
---|
87 | VMMDev::VMMDev(Console *console)
|
---|
88 | : mpDrv(NULL),
|
---|
89 | mParent(console)
|
---|
90 | {
|
---|
91 | int rc = RTSemEventCreate(&mCredentialsEvent);
|
---|
92 | AssertRC(rc);
|
---|
93 | #ifdef VBOX_WITH_HGCM
|
---|
94 | rc = HGCMHostInit ();
|
---|
95 | AssertRC(rc);
|
---|
96 | m_fHGCMActive = true;
|
---|
97 | #endif /* VBOX_WITH_HGCM */
|
---|
98 | mu32CredentialsFlags = 0;
|
---|
99 | }
|
---|
100 |
|
---|
101 | VMMDev::~VMMDev()
|
---|
102 | {
|
---|
103 | #ifdef VBOX_WITH_HGCM
|
---|
104 | if (hgcmIsActive())
|
---|
105 | {
|
---|
106 | ASMAtomicWriteBool(&m_fHGCMActive, false);
|
---|
107 | HGCMHostShutdown();
|
---|
108 | }
|
---|
109 | #endif /* VBOX_WITH_HGCM */
|
---|
110 | RTSemEventDestroy (mCredentialsEvent);
|
---|
111 | if (mpDrv)
|
---|
112 | mpDrv->pVMMDev = NULL;
|
---|
113 | mpDrv = NULL;
|
---|
114 | }
|
---|
115 |
|
---|
116 | PPDMIVMMDEVPORT VMMDev::getVMMDevPort()
|
---|
117 | {
|
---|
118 | if (!mpDrv)
|
---|
119 | return NULL;
|
---|
120 | return mpDrv->pUpPort;
|
---|
121 | }
|
---|
122 |
|
---|
123 |
|
---|
124 |
|
---|
125 | //
|
---|
126 | // public methods
|
---|
127 | //
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * Wait on event semaphore for guest credential judgement result.
|
---|
131 | */
|
---|
132 | int VMMDev::WaitCredentialsJudgement(uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
|
---|
133 | {
|
---|
134 | if (u32Timeout == 0)
|
---|
135 | {
|
---|
136 | u32Timeout = 5000;
|
---|
137 | }
|
---|
138 |
|
---|
139 | int rc = RTSemEventWait (mCredentialsEvent, u32Timeout);
|
---|
140 |
|
---|
141 | if (RT_SUCCESS(rc))
|
---|
142 | {
|
---|
143 | *pu32CredentialsFlags = mu32CredentialsFlags;
|
---|
144 | }
|
---|
145 |
|
---|
146 | return rc;
|
---|
147 | }
|
---|
148 |
|
---|
149 | int VMMDev::SetCredentialsJudgementResult(uint32_t u32Flags)
|
---|
150 | {
|
---|
151 | mu32CredentialsFlags = u32Flags;
|
---|
152 |
|
---|
153 | int rc = RTSemEventSignal (mCredentialsEvent);
|
---|
154 | AssertRC(rc);
|
---|
155 |
|
---|
156 | return rc;
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestStatus}
|
---|
162 | */
|
---|
163 | DECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFacility, uint16_t uStatus,
|
---|
164 | uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS)
|
---|
165 | {
|
---|
166 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
167 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
168 |
|
---|
169 | /* Store that information in IGuest */
|
---|
170 | Guest* guest = pConsole->getGuest();
|
---|
171 | Assert(guest);
|
---|
172 | if (!guest)
|
---|
173 | return;
|
---|
174 |
|
---|
175 | guest->setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS);
|
---|
176 | pConsole->onAdditionsStateChange();
|
---|
177 | }
|
---|
178 |
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * Reports Guest Additions API and OS version.
|
---|
182 | *
|
---|
183 | * Called whenever the Additions issue a guest version report request or the VM
|
---|
184 | * is reset.
|
---|
185 | *
|
---|
186 | * @param pInterface Pointer to this interface.
|
---|
187 | * @param guestInfo Pointer to guest information structure.
|
---|
188 | * @thread The emulation thread.
|
---|
189 | */
|
---|
190 | DECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
|
---|
191 | {
|
---|
192 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
193 |
|
---|
194 | Assert(guestInfo);
|
---|
195 | if (!guestInfo)
|
---|
196 | return;
|
---|
197 |
|
---|
198 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
199 |
|
---|
200 | /* Store that information in IGuest */
|
---|
201 | Guest* guest = pConsole->getGuest();
|
---|
202 | Assert(guest);
|
---|
203 | if (!guest)
|
---|
204 | return;
|
---|
205 |
|
---|
206 | if (guestInfo->interfaceVersion != 0)
|
---|
207 | {
|
---|
208 | char version[16];
|
---|
209 | RTStrPrintf(version, sizeof(version), "%d", guestInfo->interfaceVersion);
|
---|
210 | guest->setAdditionsInfo(Bstr(version), guestInfo->osType);
|
---|
211 |
|
---|
212 | /*
|
---|
213 | * Tell the console interface about the event
|
---|
214 | * so that it can notify its consumers.
|
---|
215 | */
|
---|
216 | pConsole->onAdditionsStateChange();
|
---|
217 |
|
---|
218 | if (guestInfo->interfaceVersion < VMMDEV_VERSION)
|
---|
219 | pConsole->onAdditionsOutdated();
|
---|
220 | }
|
---|
221 | else
|
---|
222 | {
|
---|
223 | /*
|
---|
224 | * The guest additions was disabled because of a reset
|
---|
225 | * or driver unload.
|
---|
226 | */
|
---|
227 | guest->setAdditionsInfo(Bstr(), guestInfo->osType); /* Clear interface version + OS type. */
|
---|
228 | /** @todo Would be better if GuestImpl.cpp did all this in the above method call
|
---|
229 | * while holding down the. */
|
---|
230 | guest->setAdditionsInfo2(0, "", 0, 0); /* Clear Guest Additions version. */
|
---|
231 | RTTIMESPEC TimeSpecTS;
|
---|
232 | RTTimeNow(&TimeSpecTS);
|
---|
233 | guest->setAdditionsStatus(VBoxGuestFacilityType_All, VBoxGuestFacilityStatus_Inactive, 0 /*fFlags*/, &TimeSpecTS);
|
---|
234 | pConsole->onAdditionsStateChange();
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | /**
|
---|
239 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestInfo2}
|
---|
240 | */
|
---|
241 | DECLCALLBACK(void) vmmdevUpdateGuestInfo2(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFullVersion,
|
---|
242 | const char *pszName, uint32_t uRevision, uint32_t fFeatures)
|
---|
243 | {
|
---|
244 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
245 | AssertPtr(pszName);
|
---|
246 | Assert(uFullVersion);
|
---|
247 |
|
---|
248 | /* Store that information in IGuest. */
|
---|
249 | Guest *pGuest = pDrv->pVMMDev->getParent()->getGuest();
|
---|
250 | Assert(pGuest);
|
---|
251 | if (!pGuest)
|
---|
252 | return;
|
---|
253 |
|
---|
254 | /* Just pass it on... */
|
---|
255 | pGuest->setAdditionsInfo2(uFullVersion, pszName, uRevision, fFeatures);
|
---|
256 |
|
---|
257 | /*
|
---|
258 | * No need to tell the console interface about the update;
|
---|
259 | * vmmdevUpdateGuestInfo takes care of that when called as the
|
---|
260 | * last event in the chain.
|
---|
261 | */
|
---|
262 | }
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * Update the guest additions capabilities.
|
---|
266 | * This is called when the guest additions capabilities change. The new capabilities
|
---|
267 | * are given and the connector should update its internal state.
|
---|
268 | *
|
---|
269 | * @param pInterface Pointer to this interface.
|
---|
270 | * @param newCapabilities New capabilities.
|
---|
271 | * @thread The emulation thread.
|
---|
272 | */
|
---|
273 | DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
274 | {
|
---|
275 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
276 | AssertPtr(pDrv);
|
---|
277 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
278 |
|
---|
279 | /* store that information in IGuest */
|
---|
280 | Guest* pGuest = pConsole->getGuest();
|
---|
281 | AssertPtr(pGuest);
|
---|
282 | if (!pGuest)
|
---|
283 | return;
|
---|
284 |
|
---|
285 | /*
|
---|
286 | * Report our current capabilities (and assume none is active yet).
|
---|
287 | */
|
---|
288 | pGuest->setSupportedFeatures(newCapabilities);
|
---|
289 |
|
---|
290 | /*
|
---|
291 | * Tell the console interface about the event
|
---|
292 | * so that it can notify its consumers.
|
---|
293 | */
|
---|
294 | pConsole->onAdditionsStateChange();
|
---|
295 | }
|
---|
296 |
|
---|
297 | /**
|
---|
298 | * Update the mouse capabilities.
|
---|
299 | * This is called when the mouse capabilities change. The new capabilities
|
---|
300 | * are given and the connector should update its internal state.
|
---|
301 | *
|
---|
302 | * @param pInterface Pointer to this interface.
|
---|
303 | * @param newCapabilities New capabilities.
|
---|
304 | * @thread The emulation thread.
|
---|
305 | */
|
---|
306 | DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
|
---|
307 | {
|
---|
308 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
309 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
310 |
|
---|
311 | /*
|
---|
312 | * Tell the console interface about the event
|
---|
313 | * so that it can notify its consumers.
|
---|
314 | */
|
---|
315 | Mouse *pMouse = pConsole->getMouse();
|
---|
316 | if (pMouse) /** @todo and if not? Can that actually happen? */
|
---|
317 | pMouse->onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
|
---|
318 | }
|
---|
319 |
|
---|
320 | /**
|
---|
321 | * Update the pointer shape or visibility.
|
---|
322 | *
|
---|
323 | * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
|
---|
324 | * The new shape is passed as a caller allocated buffer that will be freed after returning.
|
---|
325 | *
|
---|
326 | * @param pInterface Pointer to this interface.
|
---|
327 | * @param fVisible Whether the pointer is visible or not.
|
---|
328 | * @param fAlpha Alpha channel information is present.
|
---|
329 | * @param xHot Horizontal coordinate of the pointer hot spot.
|
---|
330 | * @param yHot Vertical coordinate of the pointer hot spot.
|
---|
331 | * @param width Pointer width in pixels.
|
---|
332 | * @param height Pointer height in pixels.
|
---|
333 | * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
|
---|
334 | * @thread The emulation thread.
|
---|
335 | */
|
---|
336 | DECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
337 | uint32_t xHot, uint32_t yHot,
|
---|
338 | uint32_t width, uint32_t height,
|
---|
339 | void *pShape)
|
---|
340 | {
|
---|
341 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
342 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
343 |
|
---|
344 | /* tell the console about it */
|
---|
345 | size_t cbShapeSize = 0;
|
---|
346 |
|
---|
347 | if (pShape)
|
---|
348 | {
|
---|
349 | cbShapeSize = (width + 7) / 8 * height; /* size of the AND mask */
|
---|
350 | cbShapeSize = ((cbShapeSize + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
|
---|
351 | }
|
---|
352 | com::SafeArray<BYTE> shapeData(cbShapeSize);
|
---|
353 | if (pShape)
|
---|
354 | ::memcpy(shapeData.raw(), pShape, cbShapeSize);
|
---|
355 | pConsole->onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayAsInParam(shapeData));
|
---|
356 | }
|
---|
357 |
|
---|
358 | DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
359 | {
|
---|
360 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
361 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
362 |
|
---|
363 | Display *display = pConsole->getDisplay();
|
---|
364 |
|
---|
365 | if (display)
|
---|
366 | {
|
---|
367 | LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
|
---|
368 | return display->VideoAccelEnable(fEnable, pVbvaMemory);
|
---|
369 | }
|
---|
370 |
|
---|
371 | return VERR_NOT_SUPPORTED;
|
---|
372 | }
|
---|
373 | DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
|
---|
374 | {
|
---|
375 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
376 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
377 |
|
---|
378 | Display *display = pConsole->getDisplay();
|
---|
379 |
|
---|
380 | if (display)
|
---|
381 | {
|
---|
382 | LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n"));
|
---|
383 | display->VideoAccelFlush ();
|
---|
384 | }
|
---|
385 | }
|
---|
386 |
|
---|
387 | DECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
|
---|
388 | uint32_t bpp, bool *fSupported)
|
---|
389 | {
|
---|
390 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
391 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
392 |
|
---|
393 | if (!fSupported)
|
---|
394 | return VERR_INVALID_PARAMETER;
|
---|
395 | #ifdef DEBUG_sunlover
|
---|
396 | Log(("vmmdevVideoModeSupported: [%d]: %dx%dx%d\n", display, width, height, bpp));
|
---|
397 | #endif
|
---|
398 | IFramebuffer *framebuffer = NULL;
|
---|
399 | LONG xOrigin = 0;
|
---|
400 | LONG yOrigin = 0;
|
---|
401 | HRESULT hrc = pConsole->getDisplay()->GetFramebuffer(display, &framebuffer, &xOrigin, &yOrigin);
|
---|
402 | if (SUCCEEDED(hrc) && framebuffer)
|
---|
403 | {
|
---|
404 | framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported);
|
---|
405 | framebuffer->Release();
|
---|
406 | }
|
---|
407 | else
|
---|
408 | {
|
---|
409 | #ifdef DEBUG_sunlover
|
---|
410 | Log(("vmmdevVideoModeSupported: hrc %x, framebuffer %p!!!\n", hrc, framebuffer));
|
---|
411 | #endif
|
---|
412 | *fSupported = true;
|
---|
413 | }
|
---|
414 | return VINF_SUCCESS;
|
---|
415 | }
|
---|
416 |
|
---|
417 | DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
|
---|
418 | {
|
---|
419 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
420 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
421 |
|
---|
422 | if (!heightReduction)
|
---|
423 | return VERR_INVALID_PARAMETER;
|
---|
424 | IFramebuffer *framebuffer = pConsole->getDisplay()->getFramebuffer();
|
---|
425 | if (framebuffer)
|
---|
426 | framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction);
|
---|
427 | else
|
---|
428 | *heightReduction = 0;
|
---|
429 | return VINF_SUCCESS;
|
---|
430 | }
|
---|
431 |
|
---|
432 | DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
|
---|
433 | {
|
---|
434 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
435 |
|
---|
436 | if (pDrv->pVMMDev)
|
---|
437 | return pDrv->pVMMDev->SetCredentialsJudgementResult (u32Flags);
|
---|
438 |
|
---|
439 | return VERR_GENERAL_FAILURE;
|
---|
440 | }
|
---|
441 |
|
---|
442 | DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
|
---|
443 | {
|
---|
444 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
445 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
446 |
|
---|
447 | /* Forward to Display, which calls corresponding framebuffers. */
|
---|
448 | pConsole->getDisplay()->handleSetVisibleRegion(cRect, pRect);
|
---|
449 |
|
---|
450 | return VINF_SUCCESS;
|
---|
451 | }
|
---|
452 |
|
---|
453 | DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
|
---|
454 | {
|
---|
455 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
456 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
457 |
|
---|
458 | /* Forward to Display, which calls corresponding framebuffers. */
|
---|
459 | pConsole->getDisplay()->handleQueryVisibleRegion(pcRect, pRect);
|
---|
460 |
|
---|
461 | return VINF_SUCCESS;
|
---|
462 | }
|
---|
463 |
|
---|
464 | /**
|
---|
465 | * Request the statistics interval
|
---|
466 | *
|
---|
467 | * @returns VBox status code.
|
---|
468 | * @param pInterface Pointer to this interface.
|
---|
469 | * @param pulInterval Pointer to interval in seconds
|
---|
470 | * @thread The emulation thread.
|
---|
471 | */
|
---|
472 | DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
|
---|
473 | {
|
---|
474 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
475 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
476 | ULONG val = 0;
|
---|
477 |
|
---|
478 | if (!pulInterval)
|
---|
479 | return VERR_INVALID_POINTER;
|
---|
480 |
|
---|
481 | /* store that information in IGuest */
|
---|
482 | Guest* guest = pConsole->getGuest();
|
---|
483 | Assert(guest);
|
---|
484 | if (!guest)
|
---|
485 | return VERR_GENERAL_FAILURE;
|
---|
486 |
|
---|
487 | guest->COMGETTER(StatisticsUpdateInterval)(&val);
|
---|
488 | *pulInterval = val;
|
---|
489 | return VINF_SUCCESS;
|
---|
490 | }
|
---|
491 |
|
---|
492 | /**
|
---|
493 | * Query the current balloon size
|
---|
494 | *
|
---|
495 | * @returns VBox status code.
|
---|
496 | * @param pInterface Pointer to this interface.
|
---|
497 | * @param pcbBalloon Balloon size
|
---|
498 | * @thread The emulation thread.
|
---|
499 | */
|
---|
500 | DECLCALLBACK(int) vmmdevQueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon)
|
---|
501 | {
|
---|
502 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
503 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
504 | ULONG val = 0;
|
---|
505 |
|
---|
506 | if (!pcbBalloon)
|
---|
507 | return VERR_INVALID_POINTER;
|
---|
508 |
|
---|
509 | /* store that information in IGuest */
|
---|
510 | Guest* guest = pConsole->getGuest();
|
---|
511 | Assert(guest);
|
---|
512 | if (!guest)
|
---|
513 | return VERR_GENERAL_FAILURE;
|
---|
514 |
|
---|
515 | guest->COMGETTER(MemoryBalloonSize)(&val);
|
---|
516 | *pcbBalloon = val;
|
---|
517 | return VINF_SUCCESS;
|
---|
518 | }
|
---|
519 |
|
---|
520 | /**
|
---|
521 | * Query the current page fusion setting
|
---|
522 | *
|
---|
523 | * @returns VBox status code.
|
---|
524 | * @param pInterface Pointer to this interface.
|
---|
525 | * @param pfPageFusionEnabled Pointer to boolean
|
---|
526 | * @thread The emulation thread.
|
---|
527 | */
|
---|
528 | DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
|
---|
529 | {
|
---|
530 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
531 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
532 | BOOL val = 0;
|
---|
533 |
|
---|
534 | if (!pfPageFusionEnabled)
|
---|
535 | return VERR_INVALID_POINTER;
|
---|
536 |
|
---|
537 | /* store that information in IGuest */
|
---|
538 | Guest* guest = pConsole->getGuest();
|
---|
539 | Assert(guest);
|
---|
540 | if (!guest)
|
---|
541 | return VERR_GENERAL_FAILURE;
|
---|
542 |
|
---|
543 | *pfPageFusionEnabled = !!guest->isPageFusionEnabled();
|
---|
544 | return VINF_SUCCESS;
|
---|
545 | }
|
---|
546 |
|
---|
547 | /**
|
---|
548 | * Report new guest statistics
|
---|
549 | *
|
---|
550 | * @returns VBox status code.
|
---|
551 | * @param pInterface Pointer to this interface.
|
---|
552 | * @param pGuestStats Guest statistics
|
---|
553 | * @thread The emulation thread.
|
---|
554 | */
|
---|
555 | DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
|
---|
556 | {
|
---|
557 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
558 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
559 |
|
---|
560 | Assert(pGuestStats);
|
---|
561 | if (!pGuestStats)
|
---|
562 | return VERR_INVALID_POINTER;
|
---|
563 |
|
---|
564 | /* store that information in IGuest */
|
---|
565 | Guest* guest = pConsole->getGuest();
|
---|
566 | Assert(guest);
|
---|
567 | if (!guest)
|
---|
568 | return VERR_GENERAL_FAILURE;
|
---|
569 |
|
---|
570 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
571 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUIDLE, pGuestStats->u32CpuLoad_Idle);
|
---|
572 |
|
---|
573 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
574 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
|
---|
575 |
|
---|
576 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
577 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUUSER, pGuestStats->u32CpuLoad_User);
|
---|
578 |
|
---|
579 |
|
---|
580 | /** @todo r=bird: Convert from 4KB to 1KB units?
|
---|
581 | * CollectorGuestHAL::getGuestMemLoad says it returns KB units to
|
---|
582 | * preCollect(). I might be wrong ofc, this is convoluted code... */
|
---|
583 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
584 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal);
|
---|
585 |
|
---|
586 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
587 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail);
|
---|
588 |
|
---|
589 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
590 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
|
---|
591 |
|
---|
592 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
593 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache);
|
---|
594 |
|
---|
595 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
596 | guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize);
|
---|
597 |
|
---|
598 | return VINF_SUCCESS;
|
---|
599 | }
|
---|
600 |
|
---|
601 | #ifdef VBOX_WITH_HGCM
|
---|
602 |
|
---|
603 | /* HGCM connector interface */
|
---|
604 |
|
---|
605 | static DECLCALLBACK(int) iface_hgcmConnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
|
---|
606 | {
|
---|
607 | LogSunlover(("Enter\n"));
|
---|
608 |
|
---|
609 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
610 |
|
---|
611 | if ( !pServiceLocation
|
---|
612 | || ( pServiceLocation->type != VMMDevHGCMLoc_LocalHost
|
---|
613 | && pServiceLocation->type != VMMDevHGCMLoc_LocalHost_Existing))
|
---|
614 | {
|
---|
615 | return VERR_INVALID_PARAMETER;
|
---|
616 | }
|
---|
617 |
|
---|
618 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
619 | return VERR_INVALID_STATE;
|
---|
620 |
|
---|
621 | return HGCMGuestConnect(pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
|
---|
622 | }
|
---|
623 |
|
---|
624 | static DECLCALLBACK(int) iface_hgcmDisconnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
|
---|
625 | {
|
---|
626 | LogSunlover(("Enter\n"));
|
---|
627 |
|
---|
628 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
629 |
|
---|
630 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
631 | return VERR_INVALID_STATE;
|
---|
632 |
|
---|
633 | return HGCMGuestDisconnect(pDrv->pHGCMPort, pCmd, u32ClientID);
|
---|
634 | }
|
---|
635 |
|
---|
636 | static DECLCALLBACK(int) iface_hgcmCall (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
|
---|
637 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
638 | {
|
---|
639 | LogSunlover(("Enter\n"));
|
---|
640 |
|
---|
641 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
642 |
|
---|
643 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
644 | return VERR_INVALID_STATE;
|
---|
645 |
|
---|
646 | return HGCMGuestCall(pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms);
|
---|
647 | }
|
---|
648 |
|
---|
649 | /**
|
---|
650 | * Execute state save operation.
|
---|
651 | *
|
---|
652 | * @returns VBox status code.
|
---|
653 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
654 | * @param pSSM SSM operation handle.
|
---|
655 | */
|
---|
656 | static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
|
---|
657 | {
|
---|
658 | LogSunlover(("Enter\n"));
|
---|
659 | return HGCMHostSaveState(pSSM);
|
---|
660 | }
|
---|
661 |
|
---|
662 |
|
---|
663 | /**
|
---|
664 | * Execute state load operation.
|
---|
665 | *
|
---|
666 | * @returns VBox status code.
|
---|
667 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
668 | * @param pSSM SSM operation handle.
|
---|
669 | * @param uVersion Data layout version.
|
---|
670 | * @param uPass The data pass.
|
---|
671 | */
|
---|
672 | static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
673 | {
|
---|
674 | LogFlowFunc(("Enter\n"));
|
---|
675 |
|
---|
676 | if (uVersion != HGCM_SSM_VERSION)
|
---|
677 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
678 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
679 |
|
---|
680 | return HGCMHostLoadState(pSSM);
|
---|
681 | }
|
---|
682 |
|
---|
683 | int VMMDev::hgcmLoadService(const char *pszServiceLibrary, const char *pszServiceName)
|
---|
684 | {
|
---|
685 | if (!hgcmIsActive())
|
---|
686 | return VERR_INVALID_STATE;
|
---|
687 |
|
---|
688 | return HGCMHostLoad(pszServiceLibrary, pszServiceName);
|
---|
689 | }
|
---|
690 |
|
---|
691 | int VMMDev::hgcmHostCall(const char *pszServiceName, uint32_t u32Function,
|
---|
692 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
693 | {
|
---|
694 | if (!hgcmIsActive())
|
---|
695 | return VERR_INVALID_STATE;
|
---|
696 | return HGCMHostCall (pszServiceName, u32Function, cParms, paParms);
|
---|
697 | }
|
---|
698 |
|
---|
699 | void VMMDev::hgcmShutdown(void)
|
---|
700 | {
|
---|
701 | ASMAtomicWriteBool(&m_fHGCMActive, false);
|
---|
702 | HGCMHostShutdown();
|
---|
703 | }
|
---|
704 |
|
---|
705 | # ifdef VBOX_WITH_CRHGSMI
|
---|
706 | int VMMDev::hgcmHostSvcHandleCreate (const char *pszServiceName, HGCMCVSHANDLE * phSvc)
|
---|
707 | {
|
---|
708 | if (!hgcmIsActive())
|
---|
709 | return VERR_INVALID_STATE;
|
---|
710 | return HGCMHostSvcHandleCreate(pszServiceName, phSvc);
|
---|
711 | }
|
---|
712 |
|
---|
713 | int VMMDev::hgcmHostSvcHandleDestroy (HGCMCVSHANDLE hSvc)
|
---|
714 | {
|
---|
715 | if (!hgcmIsActive())
|
---|
716 | return VERR_INVALID_STATE;
|
---|
717 | return HGCMHostSvcHandleDestroy(hSvc);
|
---|
718 | }
|
---|
719 |
|
---|
720 | int VMMDev::hgcmHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)
|
---|
721 | {
|
---|
722 | if (!hgcmIsActive())
|
---|
723 | return VERR_INVALID_STATE;
|
---|
724 | return HGCMHostFastCallAsync(hSvc, function, pParm, pfnCompletion, pvCompletion);
|
---|
725 | }
|
---|
726 | # endif
|
---|
727 |
|
---|
728 | #endif /* HGCM */
|
---|
729 |
|
---|
730 |
|
---|
731 | /**
|
---|
732 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
733 | */
|
---|
734 | DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
735 | {
|
---|
736 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
737 | PDRVMAINVMMDEV pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
738 |
|
---|
739 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
|
---|
740 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVCONNECTOR, &pDrv->Connector);
|
---|
741 | #ifdef VBOX_WITH_HGCM
|
---|
742 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMCONNECTOR, &pDrv->HGCMConnector);
|
---|
743 | #endif
|
---|
744 | return NULL;
|
---|
745 | }
|
---|
746 |
|
---|
747 | /**
|
---|
748 | * @interface_method_impl{PDMDRVREG,pfnReset}
|
---|
749 | */
|
---|
750 | DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
|
---|
751 | {
|
---|
752 | LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
|
---|
753 | #ifdef VBOX_WITH_HGCM
|
---|
754 | HGCMHostReset ();
|
---|
755 | #endif /* VBOX_WITH_HGCM */
|
---|
756 | }
|
---|
757 |
|
---|
758 | /**
|
---|
759 | * @interface_method_impl{PDMDRVREG,pfnDestruct}
|
---|
760 | */
|
---|
761 | DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
|
---|
762 | {
|
---|
763 | PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
|
---|
764 | PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
765 | LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
766 |
|
---|
767 | #ifdef VBOX_WITH_HGCM
|
---|
768 | /* HGCM is shut down on the VMMDev destructor. */
|
---|
769 | #endif /* VBOX_WITH_HGCM */
|
---|
770 | if (pData->pVMMDev)
|
---|
771 | pData->pVMMDev->mpDrv = NULL;
|
---|
772 | }
|
---|
773 |
|
---|
774 | /**
|
---|
775 | * @interface_method_impl{PDMDRVREG,pfnConstruct}
|
---|
776 | */
|
---|
777 | DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
|
---|
778 | {
|
---|
779 | PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
|
---|
780 | PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
781 | LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
782 |
|
---|
783 | /*
|
---|
784 | * Validate configuration.
|
---|
785 | */
|
---|
786 | if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
|
---|
787 | return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
|
---|
788 | AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
|
---|
789 | ("Configuration error: Not possible to attach anything to this driver!\n"),
|
---|
790 | VERR_PDM_DRVINS_NO_ATTACH);
|
---|
791 |
|
---|
792 | /*
|
---|
793 | * IBase.
|
---|
794 | */
|
---|
795 | pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
|
---|
796 |
|
---|
797 | pData->Connector.pfnUpdateGuestStatus = vmmdevUpdateGuestStatus;
|
---|
798 | pData->Connector.pfnUpdateGuestInfo = vmmdevUpdateGuestInfo;
|
---|
799 | pData->Connector.pfnUpdateGuestInfo2 = vmmdevUpdateGuestInfo2;
|
---|
800 | pData->Connector.pfnUpdateGuestCapabilities = vmmdevUpdateGuestCapabilities;
|
---|
801 | pData->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
|
---|
802 | pData->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
|
---|
803 | pData->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
|
---|
804 | pData->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
|
---|
805 | pData->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
|
---|
806 | pData->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
|
---|
807 | pData->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
|
---|
808 | pData->Connector.pfnSetVisibleRegion = vmmdevSetVisibleRegion;
|
---|
809 | pData->Connector.pfnQueryVisibleRegion = vmmdevQueryVisibleRegion;
|
---|
810 | pData->Connector.pfnReportStatistics = vmmdevReportStatistics;
|
---|
811 | pData->Connector.pfnQueryStatisticsInterval = vmmdevQueryStatisticsInterval;
|
---|
812 | pData->Connector.pfnQueryBalloonSize = vmmdevQueryBalloonSize;
|
---|
813 | pData->Connector.pfnIsPageFusionEnabled = vmmdevIsPageFusionEnabled;
|
---|
814 |
|
---|
815 | #ifdef VBOX_WITH_HGCM
|
---|
816 | pData->HGCMConnector.pfnConnect = iface_hgcmConnect;
|
---|
817 | pData->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
|
---|
818 | pData->HGCMConnector.pfnCall = iface_hgcmCall;
|
---|
819 | #endif
|
---|
820 |
|
---|
821 | /*
|
---|
822 | * Get the IVMMDevPort interface of the above driver/device.
|
---|
823 | */
|
---|
824 | pData->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIVMMDEVPORT);
|
---|
825 | AssertMsgReturn(pData->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
826 |
|
---|
827 | #ifdef VBOX_WITH_HGCM
|
---|
828 | pData->pHGCMPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIHGCMPORT);
|
---|
829 | AssertMsgReturn(pData->pHGCMPort, ("Configuration error: No HGCM port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
830 | #endif
|
---|
831 |
|
---|
832 | /*
|
---|
833 | * Get the Console object pointer and update the mpDrv member.
|
---|
834 | */
|
---|
835 | void *pv;
|
---|
836 | int rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
|
---|
837 | if (RT_FAILURE(rc))
|
---|
838 | {
|
---|
839 | AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
|
---|
840 | return rc;
|
---|
841 | }
|
---|
842 |
|
---|
843 | pData->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
|
---|
844 | pData->pVMMDev->mpDrv = pData;
|
---|
845 |
|
---|
846 | #ifdef VBOX_WITH_HGCM
|
---|
847 | rc = pData->pVMMDev->hgcmLoadService(VBOXSHAREDFOLDERS_DLL,
|
---|
848 | "VBoxSharedFolders");
|
---|
849 | pData->pVMMDev->fSharedFolderActive = RT_SUCCESS(rc);
|
---|
850 | if (RT_SUCCESS(rc))
|
---|
851 | {
|
---|
852 | PPDMLED pLed;
|
---|
853 | PPDMILEDPORTS pLedPort;
|
---|
854 |
|
---|
855 | LogRel(("Shared Folders service loaded.\n"));
|
---|
856 | pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);
|
---|
857 | AssertMsgReturn(pLedPort, ("Configuration error: No LED port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
858 | rc = pLedPort->pfnQueryStatusLed(pLedPort, 0, &pLed);
|
---|
859 | if (RT_SUCCESS(rc) && pLed)
|
---|
860 | {
|
---|
861 | VBOXHGCMSVCPARM parm;
|
---|
862 |
|
---|
863 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
864 | parm.u.pointer.addr = pLed;
|
---|
865 | parm.u.pointer.size = sizeof(*pLed);
|
---|
866 |
|
---|
867 | rc = HGCMHostCall("VBoxSharedFolders", SHFL_FN_SET_STATUS_LED, 1, &parm);
|
---|
868 | }
|
---|
869 | else
|
---|
870 | AssertMsgFailed(("pfnQueryStatusLed failed with %Rrc (pLed=%x)\n", rc, pLed));
|
---|
871 | }
|
---|
872 | else
|
---|
873 | LogRel(("Failed to load Shared Folders service %Rrc\n", rc));
|
---|
874 |
|
---|
875 | rc = PDMDrvHlpSSMRegisterEx(pDrvIns, HGCM_SSM_VERSION, 4096 /* bad guess */,
|
---|
876 | NULL, NULL, NULL,
|
---|
877 | NULL, iface_hgcmSave, NULL,
|
---|
878 | NULL, iface_hgcmLoad, NULL);
|
---|
879 | if (RT_FAILURE(rc))
|
---|
880 | return rc;
|
---|
881 |
|
---|
882 | #endif /* VBOX_WITH_HGCM */
|
---|
883 |
|
---|
884 | return VINF_SUCCESS;
|
---|
885 | }
|
---|
886 |
|
---|
887 |
|
---|
888 | /**
|
---|
889 | * VMMDevice driver registration record.
|
---|
890 | */
|
---|
891 | const PDMDRVREG VMMDev::DrvReg =
|
---|
892 | {
|
---|
893 | /* u32Version */
|
---|
894 | PDM_DRVREG_VERSION,
|
---|
895 | /* szName */
|
---|
896 | "HGCM",
|
---|
897 | /* szRCMod */
|
---|
898 | "",
|
---|
899 | /* szR0Mod */
|
---|
900 | "",
|
---|
901 | /* pszDescription */
|
---|
902 | "Main VMMDev driver (Main as in the API).",
|
---|
903 | /* fFlags */
|
---|
904 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
905 | /* fClass. */
|
---|
906 | PDM_DRVREG_CLASS_VMMDEV,
|
---|
907 | /* cMaxInstances */
|
---|
908 | ~0U,
|
---|
909 | /* cbInstance */
|
---|
910 | sizeof(DRVMAINVMMDEV),
|
---|
911 | /* pfnConstruct */
|
---|
912 | VMMDev::drvConstruct,
|
---|
913 | /* pfnDestruct */
|
---|
914 | VMMDev::drvDestruct,
|
---|
915 | /* pfnRelocate */
|
---|
916 | NULL,
|
---|
917 | /* pfnIOCtl */
|
---|
918 | NULL,
|
---|
919 | /* pfnPowerOn */
|
---|
920 | NULL,
|
---|
921 | /* pfnReset */
|
---|
922 | VMMDev::drvReset,
|
---|
923 | /* pfnSuspend */
|
---|
924 | NULL,
|
---|
925 | /* pfnResume */
|
---|
926 | NULL,
|
---|
927 | /* pfnAttach */
|
---|
928 | NULL,
|
---|
929 | /* pfnDetach */
|
---|
930 | NULL,
|
---|
931 | /* pfnPowerOff */
|
---|
932 | NULL,
|
---|
933 | /* pfnSoftReset */
|
---|
934 | NULL,
|
---|
935 | /* u32EndVersion */
|
---|
936 | PDM_DRVREG_VERSION
|
---|
937 | };
|
---|
938 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|