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