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