1 | /* $Id: VMMDev.cpp 33303 2010-10-21 12:11:55Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMMDev - Guest <-> VMM/Host communication 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 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | /* #define LOG_ENABLED */
|
---|
23 | /* Enable dev_vmm Log3 statements to get IRQ-related logging. */
|
---|
24 |
|
---|
25 | #define LOG_GROUP LOG_GROUP_DEV_VMM
|
---|
26 | #include <VBox/VMMDev.h>
|
---|
27 | #include <VBox/mm.h>
|
---|
28 | #include <VBox/log.h>
|
---|
29 | #include <VBox/param.h>
|
---|
30 | #include <iprt/path.h>
|
---|
31 | #include <iprt/dir.h>
|
---|
32 | #include <iprt/file.h>
|
---|
33 | #include <VBox/pgm.h>
|
---|
34 | #include <VBox/err.h>
|
---|
35 | #include <VBox/vm.h> /* for VM_IS_EMT */
|
---|
36 | #include <VBox/dbg.h>
|
---|
37 |
|
---|
38 | #include <iprt/asm.h>
|
---|
39 | #include <iprt/asm-amd64-x86.h>
|
---|
40 | #include <iprt/assert.h>
|
---|
41 | #include <iprt/buildconfig.h>
|
---|
42 | #include <iprt/string.h>
|
---|
43 | #include <iprt/time.h>
|
---|
44 | #ifndef IN_RC
|
---|
45 | # include <iprt/mem.h>
|
---|
46 | #endif
|
---|
47 | #ifdef IN_RING3
|
---|
48 | # include <iprt/uuid.h>
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | #include "VMMDevState.h"
|
---|
52 | #ifdef VBOX_WITH_HGCM
|
---|
53 | # include "VMMDevHGCM.h"
|
---|
54 | #endif
|
---|
55 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
56 | # include "VMMDevTesting.h"
|
---|
57 | #endif
|
---|
58 |
|
---|
59 |
|
---|
60 | /*******************************************************************************
|
---|
61 | * Defined Constants And Macros *
|
---|
62 | *******************************************************************************/
|
---|
63 | #define PCIDEV_2_VMMDEVSTATE(pPciDev) ( (VMMDevState *)(pPciDev) )
|
---|
64 | #define VMMDEVSTATE_2_DEVINS(pVMMDevState) ( (pVMMDevState)->pDevIns )
|
---|
65 |
|
---|
66 | #define VBOX_GUEST_INTERFACE_VERSION_1_03(s) \
|
---|
67 | ( RT_HIWORD((s)->guestInfo.interfaceVersion) == 1 \
|
---|
68 | && RT_LOWORD((s)->guestInfo.interfaceVersion) == 3 )
|
---|
69 |
|
---|
70 | #define VBOX_GUEST_INTERFACE_VERSION_OK(additionsVersion) \
|
---|
71 | ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
72 | && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) )
|
---|
73 |
|
---|
74 | #define VBOX_GUEST_INTERFACE_VERSION_OLD(additionsVersion) \
|
---|
75 | ( (RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) \
|
---|
76 | || ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
77 | && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) ) )
|
---|
78 |
|
---|
79 | #define VBOX_GUEST_INTERFACE_VERSION_TOO_OLD(additionsVersion) \
|
---|
80 | ( RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) )
|
---|
81 |
|
---|
82 | #define VBOX_GUEST_INTERFACE_VERSION_NEW(additionsVersion) \
|
---|
83 | ( RT_HIWORD(additionsVersion) > RT_HIWORD(VMMDEV_VERSION) \
|
---|
84 | || ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
85 | && RT_LOWORD(additionsVersion) > RT_LOWORD(VMMDEV_VERSION) ) )
|
---|
86 |
|
---|
87 | /** The saved state version. */
|
---|
88 | #define VMMDEV_SAVED_STATE_VERSION 13
|
---|
89 | /** The saved state version used by VirtualBox 3.0.
|
---|
90 | * This doesn't have the config part. */
|
---|
91 | #define VMMDEV_SAVED_STATE_VERSION_VBOX_30 11
|
---|
92 |
|
---|
93 |
|
---|
94 | #ifndef VBOX_DEVICE_STRUCT_TESTCASE
|
---|
95 |
|
---|
96 | /* Whenever host wants to inform guest about something
|
---|
97 | * an IRQ notification will be raised.
|
---|
98 | *
|
---|
99 | * VMMDev PDM interface will contain the guest notification method.
|
---|
100 | *
|
---|
101 | * There is a 32 bit event mask which will be read
|
---|
102 | * by guest on an interrupt. A non zero bit in the mask
|
---|
103 | * means that the specific event occurred and requires
|
---|
104 | * processing on guest side.
|
---|
105 | *
|
---|
106 | * After reading the event mask guest must issue a
|
---|
107 | * generic request AcknowlegdeEvents.
|
---|
108 | *
|
---|
109 | * IRQ line is set to 1 (request) if there are unprocessed
|
---|
110 | * events, that is the event mask is not zero.
|
---|
111 | *
|
---|
112 | * After receiving an interrupt and checking event mask,
|
---|
113 | * the guest must process events using the event specific
|
---|
114 | * mechanism.
|
---|
115 | *
|
---|
116 | * That is if mouse capabilities were changed,
|
---|
117 | * guest will use VMMDev_GetMouseStatus generic request.
|
---|
118 | *
|
---|
119 | * Event mask is only a set of flags indicating that guest
|
---|
120 | * must proceed with a procedure.
|
---|
121 | *
|
---|
122 | * Unsupported events are therefore ignored.
|
---|
123 | * The guest additions must inform host which events they
|
---|
124 | * want to receive, to avoid unnecessary IRQ processing.
|
---|
125 | * By default no events are signalled to guest.
|
---|
126 | *
|
---|
127 | * This seems to be fast method. It requires
|
---|
128 | * only one context switch for an event processing.
|
---|
129 | *
|
---|
130 | */
|
---|
131 |
|
---|
132 | static void vmmdevSetIRQ_Legacy_EMT (VMMDevState *pVMMDevState)
|
---|
133 | {
|
---|
134 | if (!pVMMDevState->fu32AdditionsOk)
|
---|
135 | {
|
---|
136 | Log(("vmmdevSetIRQ: IRQ is not generated, guest has not yet reported to us.\n"));
|
---|
137 | return;
|
---|
138 | }
|
---|
139 |
|
---|
140 | uint32_t u32IRQLevel = 0;
|
---|
141 |
|
---|
142 | /* Filter unsupported events */
|
---|
143 | uint32_t u32EventFlags =
|
---|
144 | pVMMDevState->u32HostEventFlags
|
---|
145 | & pVMMDevState->pVMMDevRAMR3->V.V1_03.u32GuestEventMask;
|
---|
146 |
|
---|
147 | Log(("vmmdevSetIRQ: u32EventFlags = 0x%08X, "
|
---|
148 | "pVMMDevState->u32HostEventFlags = 0x%08X, "
|
---|
149 | "pVMMDevState->pVMMDevRAMR3->u32GuestEventMask = 0x%08X\n",
|
---|
150 | u32EventFlags,
|
---|
151 | pVMMDevState->u32HostEventFlags,
|
---|
152 | pVMMDevState->pVMMDevRAMR3->V.V1_03.u32GuestEventMask));
|
---|
153 |
|
---|
154 | /* Move event flags to VMMDev RAM */
|
---|
155 | pVMMDevState->pVMMDevRAMR3->V.V1_03.u32HostEvents = u32EventFlags;
|
---|
156 |
|
---|
157 | if (u32EventFlags)
|
---|
158 | {
|
---|
159 | /* Clear host flags which will be delivered to guest. */
|
---|
160 | pVMMDevState->u32HostEventFlags &= ~u32EventFlags;
|
---|
161 | Log(("vmmdevSetIRQ: pVMMDevState->u32HostEventFlags = 0x%08X\n",
|
---|
162 | pVMMDevState->u32HostEventFlags));
|
---|
163 | u32IRQLevel = 1;
|
---|
164 | }
|
---|
165 |
|
---|
166 | /* Set IRQ level for pin 0 */
|
---|
167 | /** @todo make IRQ pin configurable, at least a symbolic constant */
|
---|
168 | PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS(pVMMDevState);
|
---|
169 | PDMDevHlpPCISetIrqNoWait(pDevIns, 0, u32IRQLevel);
|
---|
170 | Log(("vmmdevSetIRQ: IRQ set %d\n", u32IRQLevel));
|
---|
171 | }
|
---|
172 |
|
---|
173 | static void vmmdevMaybeSetIRQ_EMT (VMMDevState *pVMMDevState)
|
---|
174 | {
|
---|
175 | PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS (pVMMDevState);
|
---|
176 |
|
---|
177 | Log3(("vmmdevMaybeSetIRQ_EMT: u32HostEventFlags = 0x%08X, u32GuestFilterMask = 0x%08X.\n",
|
---|
178 | pVMMDevState->u32HostEventFlags, pVMMDevState->u32GuestFilterMask));
|
---|
179 |
|
---|
180 | if (pVMMDevState->u32HostEventFlags & pVMMDevState->u32GuestFilterMask)
|
---|
181 | {
|
---|
182 | pVMMDevState->pVMMDevRAMR3->V.V1_04.fHaveEvents = true;
|
---|
183 | PDMDevHlpPCISetIrqNoWait (pDevIns, 0, 1);
|
---|
184 | Log3(("vmmdevMaybeSetIRQ_EMT: IRQ set.\n"));
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 | static void vmmdevNotifyGuest_EMT (VMMDevState *pVMMDevState, uint32_t u32EventMask)
|
---|
189 | {
|
---|
190 | Log3(("VMMDevNotifyGuest_EMT: u32EventMask = 0x%08X.\n", u32EventMask));
|
---|
191 |
|
---|
192 | if (VBOX_GUEST_INTERFACE_VERSION_1_03 (pVMMDevState))
|
---|
193 | {
|
---|
194 | Log3(("VMMDevNotifyGuest_EMT: Old additions detected.\n"));
|
---|
195 |
|
---|
196 | pVMMDevState->u32HostEventFlags |= u32EventMask;
|
---|
197 | vmmdevSetIRQ_Legacy_EMT (pVMMDevState);
|
---|
198 | }
|
---|
199 | else
|
---|
200 | {
|
---|
201 | Log3(("VMMDevNotifyGuest_EMT: New additions detected.\n"));
|
---|
202 |
|
---|
203 | if (!pVMMDevState->fu32AdditionsOk)
|
---|
204 | {
|
---|
205 | pVMMDevState->u32HostEventFlags |= u32EventMask;
|
---|
206 | Log(("vmmdevNotifyGuest_EMT: IRQ is not generated, guest has not yet reported to us.\n"));
|
---|
207 | return;
|
---|
208 | }
|
---|
209 |
|
---|
210 | const bool fHadEvents =
|
---|
211 | (pVMMDevState->u32HostEventFlags & pVMMDevState->u32GuestFilterMask) != 0;
|
---|
212 |
|
---|
213 | Log3(("VMMDevNotifyGuest_EMT: fHadEvents = %d, u32HostEventFlags = 0x%08X, u32GuestFilterMask = 0x%08X.\n",
|
---|
214 | fHadEvents, pVMMDevState->u32HostEventFlags, pVMMDevState->u32GuestFilterMask));
|
---|
215 |
|
---|
216 | pVMMDevState->u32HostEventFlags |= u32EventMask;
|
---|
217 |
|
---|
218 | if (!fHadEvents)
|
---|
219 | vmmdevMaybeSetIRQ_EMT (pVMMDevState);
|
---|
220 | }
|
---|
221 | }
|
---|
222 |
|
---|
223 | void VMMDevCtlSetGuestFilterMask (VMMDevState *pVMMDevState,
|
---|
224 | uint32_t u32OrMask,
|
---|
225 | uint32_t u32NotMask)
|
---|
226 | {
|
---|
227 | PDMCritSectEnter(&pVMMDevState->CritSect, VERR_SEM_BUSY);
|
---|
228 |
|
---|
229 | const bool fHadEvents =
|
---|
230 | (pVMMDevState->u32HostEventFlags & pVMMDevState->u32GuestFilterMask) != 0;
|
---|
231 |
|
---|
232 | Log(("VMMDevCtlSetGuestFilterMask: u32OrMask = 0x%08X, u32NotMask = 0x%08X, fHadEvents = %d.\n", u32OrMask, u32NotMask, fHadEvents));
|
---|
233 | if (fHadEvents)
|
---|
234 | {
|
---|
235 | if (!pVMMDevState->fNewGuestFilterMask)
|
---|
236 | pVMMDevState->u32NewGuestFilterMask = pVMMDevState->u32GuestFilterMask;
|
---|
237 |
|
---|
238 | pVMMDevState->u32NewGuestFilterMask |= u32OrMask;
|
---|
239 | pVMMDevState->u32NewGuestFilterMask &= ~u32NotMask;
|
---|
240 | pVMMDevState->fNewGuestFilterMask = true;
|
---|
241 | }
|
---|
242 | else
|
---|
243 | {
|
---|
244 | pVMMDevState->u32GuestFilterMask |= u32OrMask;
|
---|
245 | pVMMDevState->u32GuestFilterMask &= ~u32NotMask;
|
---|
246 | vmmdevMaybeSetIRQ_EMT (pVMMDevState);
|
---|
247 | }
|
---|
248 | PDMCritSectLeave(&pVMMDevState->CritSect);
|
---|
249 | }
|
---|
250 |
|
---|
251 | void VMMDevNotifyGuest (VMMDevState *pVMMDevState, uint32_t u32EventMask)
|
---|
252 | {
|
---|
253 | PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS(pVMMDevState);
|
---|
254 |
|
---|
255 | Log3(("VMMDevNotifyGuest: u32EventMask = 0x%08X.\n", u32EventMask));
|
---|
256 |
|
---|
257 | /*
|
---|
258 | * Drop notifications if the VM is not running yet/anymore.
|
---|
259 | */
|
---|
260 | VMSTATE enmVMState = PDMDevHlpVMState(pDevIns);
|
---|
261 | if ( enmVMState != VMSTATE_RUNNING
|
---|
262 | && enmVMState != VMSTATE_RUNNING_LS)
|
---|
263 | return;
|
---|
264 |
|
---|
265 | PDMCritSectEnter(&pVMMDevState->CritSect, VERR_SEM_BUSY);
|
---|
266 | /* No need to wait for the completion of this request. It is a notification
|
---|
267 | * about something, which has already happened.
|
---|
268 | */
|
---|
269 | vmmdevNotifyGuest_EMT(pVMMDevState, u32EventMask);
|
---|
270 | PDMCritSectLeave(&pVMMDevState->CritSect);
|
---|
271 | }
|
---|
272 |
|
---|
273 | /**
|
---|
274 | * Port I/O Handler for OUT operations.
|
---|
275 | *
|
---|
276 | * @returns VBox status code.
|
---|
277 | *
|
---|
278 | * @param pDevIns The device instance.
|
---|
279 | * @param pvUser User argument - ignored.
|
---|
280 | * @param uPort Port number used for the IN operation.
|
---|
281 | * @param u32 The value to output.
|
---|
282 | * @param cb The value size in bytes.
|
---|
283 | */
|
---|
284 | static DECLCALLBACK(int) vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
285 | {
|
---|
286 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
287 |
|
---|
288 | if (!pThis->fBackdoorLogDisabled && cb == 1 && Port == RTLOG_DEBUG_PORT)
|
---|
289 | {
|
---|
290 |
|
---|
291 | /* The raw version. */
|
---|
292 | switch (u32)
|
---|
293 | {
|
---|
294 | case '\r': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <return>\n")); break;
|
---|
295 | case '\n': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <newline>\n")); break;
|
---|
296 | case '\t': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <tab>\n")); break;
|
---|
297 | default: LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: %c (%02x)\n", u32, u32)); break;
|
---|
298 | }
|
---|
299 |
|
---|
300 | /* The readable, buffered version. */
|
---|
301 | if (u32 == '\n' || u32 == '\r')
|
---|
302 | {
|
---|
303 | pThis->szMsg[pThis->iMsg] = '\0';
|
---|
304 | if (pThis->iMsg)
|
---|
305 | LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("Guest Log: %s\n", pThis->szMsg));
|
---|
306 | pThis->iMsg = 0;
|
---|
307 | }
|
---|
308 | else
|
---|
309 | {
|
---|
310 | if (pThis->iMsg >= sizeof(pThis->szMsg)-1)
|
---|
311 | {
|
---|
312 | pThis->szMsg[pThis->iMsg] = '\0';
|
---|
313 | LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("Guest Log: %s\n", pThis->szMsg));
|
---|
314 | pThis->iMsg = 0;
|
---|
315 | }
|
---|
316 | pThis->szMsg[pThis->iMsg] = (char )u32;
|
---|
317 | pThis->szMsg[++pThis->iMsg] = '\0';
|
---|
318 | }
|
---|
319 | }
|
---|
320 | return VINF_SUCCESS;
|
---|
321 | }
|
---|
322 |
|
---|
323 | #ifdef TIMESYNC_BACKDOOR
|
---|
324 | /**
|
---|
325 | * Port I/O Handler for OUT operations.
|
---|
326 | *
|
---|
327 | * @returns VBox status code.
|
---|
328 | *
|
---|
329 | * @param pDevIns The device instance.
|
---|
330 | * @param pvUser User argument - ignored.
|
---|
331 | * @param uPort Port number used for the IN operation.
|
---|
332 | * @param u32 The value to output.
|
---|
333 | * @param cb The value size in bytes.
|
---|
334 | */
|
---|
335 | static DECLCALLBACK(int) vmmdevTimesyncBackdoorWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
336 | {
|
---|
337 | NOREF(pvUser);
|
---|
338 | if (cb == 4)
|
---|
339 | {
|
---|
340 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
341 | switch (u32)
|
---|
342 | {
|
---|
343 | case 0:
|
---|
344 | pThis->fTimesyncBackdoorLo = false;
|
---|
345 | break;
|
---|
346 | case 1:
|
---|
347 | pThis->fTimesyncBackdoorLo = true;
|
---|
348 | }
|
---|
349 | return VINF_SUCCESS;
|
---|
350 |
|
---|
351 | }
|
---|
352 | return VINF_SUCCESS;
|
---|
353 | }
|
---|
354 |
|
---|
355 | /**
|
---|
356 | * Port I/O Handler for backdoor timesync IN operations.
|
---|
357 | *
|
---|
358 | * @returns VBox status code.
|
---|
359 | *
|
---|
360 | * @param pDevIns The device instance.
|
---|
361 | * @param pvUser User argument - ignored.
|
---|
362 | * @param uPort Port number used for the IN operation.
|
---|
363 | * @param pu32 Where to store the result.
|
---|
364 | * @param cb Number of bytes read.
|
---|
365 | */
|
---|
366 | static DECLCALLBACK(int) vmmdevTimesyncBackdoorRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
|
---|
367 | {
|
---|
368 | int rc;
|
---|
369 | NOREF(pvUser);
|
---|
370 | if (cb == 4)
|
---|
371 | {
|
---|
372 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
373 | RTTIMESPEC now;
|
---|
374 |
|
---|
375 | if (pThis->fTimesyncBackdoorLo)
|
---|
376 | *pu32 = (uint32_t)pThis->hostTime;
|
---|
377 | else
|
---|
378 | {
|
---|
379 | pThis->hostTime = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &now));
|
---|
380 | *pu32 = (uint32_t)(pThis->hostTime >> 32);
|
---|
381 | }
|
---|
382 | rc = VINF_SUCCESS;
|
---|
383 | }
|
---|
384 | else
|
---|
385 | rc = VERR_IOM_IOPORT_UNUSED;
|
---|
386 | return rc;
|
---|
387 | }
|
---|
388 | #endif /* TIMESYNC_BACKDOOR */
|
---|
389 |
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Port I/O Handler for the generic request interface
|
---|
393 | * @see FNIOMIOPORTOUT for details.
|
---|
394 | *
|
---|
395 | * @todo Too long, suggest doing the request copying here and moving the
|
---|
396 | * switch into a different function (or better case -> functions), and
|
---|
397 | * looing the gotos.
|
---|
398 | */
|
---|
399 | static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
400 | {
|
---|
401 | VMMDevState *pThis = (VMMDevState*)pvUser;
|
---|
402 | int rcRet = VINF_SUCCESS;
|
---|
403 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
404 |
|
---|
405 | /*
|
---|
406 | * The caller has passed the guest context physical address
|
---|
407 | * of the request structure. Copy the request packet.
|
---|
408 | */
|
---|
409 | VMMDevRequestHeader *pRequestHeader = NULL;
|
---|
410 | VMMDevRequestHeader requestHeader;
|
---|
411 | RT_ZERO(requestHeader);
|
---|
412 |
|
---|
413 | PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader));
|
---|
414 |
|
---|
415 | /* the structure size must be greater or equal to the header size */
|
---|
416 | if (requestHeader.size < sizeof(VMMDevRequestHeader))
|
---|
417 | {
|
---|
418 | Log(("VMMDev request header size too small! size = %d\n", requestHeader.size));
|
---|
419 | rcRet = VINF_SUCCESS;
|
---|
420 | goto l_end; /** @todo shouldn't (/ no need to) write back.*/
|
---|
421 | }
|
---|
422 |
|
---|
423 | /* check the version of the header structure */
|
---|
424 | if (requestHeader.version != VMMDEV_REQUEST_HEADER_VERSION)
|
---|
425 | {
|
---|
426 | Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader.version, VMMDEV_REQUEST_HEADER_VERSION));
|
---|
427 | rcRet = VINF_SUCCESS;
|
---|
428 | goto l_end; /** @todo shouldn't (/ no need to) write back.*/
|
---|
429 | }
|
---|
430 |
|
---|
431 | Log2(("VMMDev request issued: %d\n", requestHeader.requestType));
|
---|
432 |
|
---|
433 | /* Newer additions starts with VMMDevReq_ReportGuestInfo2, older additions
|
---|
434 | started with VMMDevReq_ReportGuestInfo. */
|
---|
435 | if ( !pThis->fu32AdditionsOk
|
---|
436 | && requestHeader.requestType != VMMDevReq_ReportGuestInfo2
|
---|
437 | && requestHeader.requestType != VMMDevReq_ReportGuestInfo
|
---|
438 | && requestHeader.requestType != VMMDevReq_WriteCoreDump)
|
---|
439 | {
|
---|
440 | Log(("VMMDev: guest has not yet reported to us. Refusing operation.\n"));
|
---|
441 | requestHeader.rc = VERR_NOT_SUPPORTED;
|
---|
442 | rcRet = VINF_SUCCESS;
|
---|
443 | goto l_end;
|
---|
444 | }
|
---|
445 |
|
---|
446 | /* Check upper limit */
|
---|
447 | if (requestHeader.size > VMMDEV_MAX_VMMDEVREQ_SIZE)
|
---|
448 | {
|
---|
449 | LogRel(("VMMDev: request packet too big (%x). Refusing operation.\n", requestHeader.size));
|
---|
450 | requestHeader.rc = VERR_NOT_SUPPORTED;
|
---|
451 | rcRet = VINF_SUCCESS;
|
---|
452 | goto l_end;
|
---|
453 | }
|
---|
454 |
|
---|
455 | /* Read the entire request packet */
|
---|
456 | pRequestHeader = (VMMDevRequestHeader *)RTMemAlloc(requestHeader.size);
|
---|
457 | if (!pRequestHeader)
|
---|
458 | {
|
---|
459 | Log(("VMMDev: RTMemAlloc failed!\n"));
|
---|
460 | rcRet = VINF_SUCCESS;
|
---|
461 | requestHeader.rc = VERR_NO_MEMORY;
|
---|
462 | goto l_end;
|
---|
463 | }
|
---|
464 | PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, pRequestHeader, requestHeader.size);
|
---|
465 |
|
---|
466 | /* which request was sent? */
|
---|
467 | switch (pRequestHeader->requestType)
|
---|
468 | {
|
---|
469 | /*
|
---|
470 | * Guest wants to give up a timeslice
|
---|
471 | */
|
---|
472 | case VMMDevReq_Idle:
|
---|
473 | {
|
---|
474 | /* just return to EMT telling it that we want to halt */
|
---|
475 | rcRet = VINF_EM_HALT;
|
---|
476 | break;
|
---|
477 | }
|
---|
478 |
|
---|
479 | /*
|
---|
480 | * Guest is reporting its information
|
---|
481 | */
|
---|
482 | case VMMDevReq_ReportGuestInfo:
|
---|
483 | {
|
---|
484 | if (pRequestHeader->size != sizeof(VMMDevReportGuestInfo))
|
---|
485 | {
|
---|
486 | AssertMsgFailed(("VMMDev guest information structure has an invalid size!\n"));
|
---|
487 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
488 | }
|
---|
489 | else
|
---|
490 | {
|
---|
491 | VBoxGuestInfo *guestInfo = &((VMMDevReportGuestInfo*)pRequestHeader)->guestInfo;
|
---|
492 |
|
---|
493 | if (memcmp (&pThis->guestInfo, guestInfo, sizeof(*guestInfo)) != 0)
|
---|
494 | {
|
---|
495 | /* make a copy of supplied information */
|
---|
496 | pThis->guestInfo = *guestInfo;
|
---|
497 |
|
---|
498 | /* Check additions version */
|
---|
499 | pThis->fu32AdditionsOk = VBOX_GUEST_INTERFACE_VERSION_OK(pThis->guestInfo.interfaceVersion);
|
---|
500 |
|
---|
501 | LogRel(("Guest Additions information report: Interface = 0x%08X osType = 0x%08X\n",
|
---|
502 | pThis->guestInfo.interfaceVersion,
|
---|
503 | pThis->guestInfo.osType));
|
---|
504 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
505 | }
|
---|
506 |
|
---|
507 | if (pThis->fu32AdditionsOk)
|
---|
508 | {
|
---|
509 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
510 | }
|
---|
511 | else
|
---|
512 | {
|
---|
513 | pRequestHeader->rc = VERR_VERSION_MISMATCH;
|
---|
514 | }
|
---|
515 | }
|
---|
516 | break;
|
---|
517 | }
|
---|
518 |
|
---|
519 | case VMMDevReq_ReportGuestInfo2:
|
---|
520 | {
|
---|
521 | if (pRequestHeader->size != sizeof(VMMDevReportGuestInfo2))
|
---|
522 | {
|
---|
523 | AssertMsgFailed(("VMMDev guest information 2 structure has an invalid size!\n"));
|
---|
524 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
525 | }
|
---|
526 | else
|
---|
527 | {
|
---|
528 | VBoxGuestInfo2 *pGuestInfo2 = &((VMMDevReportGuestInfo2*)pRequestHeader)->guestInfo;
|
---|
529 | AssertPtr(pGuestInfo2);
|
---|
530 | LogRel(("Guest Additions information report: Version %d.%d.%d r%d '%.*s'\n",
|
---|
531 | pGuestInfo2->additionsMajor, pGuestInfo2->additionsMinor, pGuestInfo2->additionsBuild,
|
---|
532 | pGuestInfo2->additionsRevision, sizeof(pGuestInfo2->szName), pGuestInfo2->szName));
|
---|
533 | pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pGuestInfo2);
|
---|
534 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
535 | }
|
---|
536 | break;
|
---|
537 | }
|
---|
538 |
|
---|
539 | case VMMDevReq_WriteCoreDump:
|
---|
540 | {
|
---|
541 | if (pRequestHeader->size != sizeof(VMMDevReqWriteCoreDump))
|
---|
542 | {
|
---|
543 | AssertMsgFailed(("VMMDev WriteCoreDump structure has an invalid size!\n"));
|
---|
544 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
545 | }
|
---|
546 | else
|
---|
547 | {
|
---|
548 | if (pThis->fGuestCoreDumpEnabled)
|
---|
549 | {
|
---|
550 | /*
|
---|
551 | * User makes sure the directory exists.
|
---|
552 | */
|
---|
553 | if (!RTDirExists(pThis->szGuestCoreDumpDir))
|
---|
554 | return VERR_PATH_NOT_FOUND;
|
---|
555 |
|
---|
556 | char szCorePath[RTPATH_MAX];
|
---|
557 | RTStrCopy(szCorePath, sizeof(szCorePath), pThis->szGuestCoreDumpDir);
|
---|
558 | RTPathAppend(szCorePath, sizeof(szCorePath), "VBox.core");
|
---|
559 |
|
---|
560 | /*
|
---|
561 | * Rotate existing cores based on number of additional cores to keep around.
|
---|
562 | */
|
---|
563 | if (pThis->cGuestCoreDumps > 0)
|
---|
564 | for (int64_t i = pThis->cGuestCoreDumps - 1; i >= 0; i--)
|
---|
565 | {
|
---|
566 | char szFilePathOld[RTPATH_MAX];
|
---|
567 | if (i == 0)
|
---|
568 | RTStrCopy(szFilePathOld, sizeof(szFilePathOld), szCorePath);
|
---|
569 | else
|
---|
570 | RTStrPrintf(szFilePathOld, sizeof(szFilePathOld), "%s.%d", szCorePath, i);
|
---|
571 |
|
---|
572 | char szFilePathNew[RTPATH_MAX];
|
---|
573 | RTStrPrintf(szFilePathNew, sizeof(szFilePathNew), "%s.%d", szCorePath, i + 1);
|
---|
574 | int vrc = RTFileMove(szFilePathOld, szFilePathNew, RTFILEMOVE_FLAGS_REPLACE);
|
---|
575 | if (vrc == VERR_FILE_NOT_FOUND)
|
---|
576 | RTFileDelete(szFilePathNew);
|
---|
577 | }
|
---|
578 |
|
---|
579 | /*
|
---|
580 | * Write the core file.
|
---|
581 | */
|
---|
582 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
583 | pRequestHeader->rc = DBGFR3CoreWrite(pVM, szCorePath);
|
---|
584 | }
|
---|
585 | else
|
---|
586 | pRequestHeader->rc = VERR_ACCESS_DENIED;
|
---|
587 | }
|
---|
588 | break;
|
---|
589 | }
|
---|
590 |
|
---|
591 | case VMMDevReq_ReportGuestStatus:
|
---|
592 | {
|
---|
593 | if (pRequestHeader->size != sizeof(VMMDevReportGuestStatus))
|
---|
594 | {
|
---|
595 | AssertMsgFailed(("VMMDev guest status structure has an invalid size!\n"));
|
---|
596 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
597 | }
|
---|
598 | else
|
---|
599 | {
|
---|
600 | VBoxGuestStatus *guestStatus = &((VMMDevReportGuestStatus*)pRequestHeader)->guestStatus;
|
---|
601 | pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv, guestStatus);
|
---|
602 |
|
---|
603 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
604 | }
|
---|
605 | break;
|
---|
606 | }
|
---|
607 |
|
---|
608 | /* Report guest capabilities */
|
---|
609 | case VMMDevReq_ReportGuestCapabilities:
|
---|
610 | {
|
---|
611 | if (pRequestHeader->size != sizeof(VMMDevReqGuestCapabilities))
|
---|
612 | {
|
---|
613 | AssertMsgFailed(("VMMDev guest caps structure has invalid size!\n"));
|
---|
614 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
615 | }
|
---|
616 | else
|
---|
617 | {
|
---|
618 | VMMDevReqGuestCapabilities *guestCaps = (VMMDevReqGuestCapabilities*)pRequestHeader;
|
---|
619 |
|
---|
620 | /* Enable this automatically for guests using the old
|
---|
621 | request to report their capabilities. */
|
---|
622 | /** @todo change this when we next bump the interface version */
|
---|
623 | guestCaps->caps |= VMMDEV_GUEST_SUPPORTS_GRAPHICS;
|
---|
624 | if (pThis->guestCaps != guestCaps->caps)
|
---|
625 | {
|
---|
626 | /* make a copy of supplied information */
|
---|
627 | pThis->guestCaps = guestCaps->caps;
|
---|
628 |
|
---|
629 | LogRel(("Guest Additions capability report: (0x%x) "
|
---|
630 | "seamless: %s, "
|
---|
631 | "hostWindowMapping: %s, "
|
---|
632 | "graphics: %s\n",
|
---|
633 | guestCaps->caps,
|
---|
634 | guestCaps->caps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ? "yes" : "no",
|
---|
635 | guestCaps->caps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no",
|
---|
636 | guestCaps->caps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ? "yes" : "no"));
|
---|
637 |
|
---|
638 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, guestCaps->caps);
|
---|
639 | }
|
---|
640 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
641 | }
|
---|
642 | break;
|
---|
643 | }
|
---|
644 |
|
---|
645 | /* Change guest capabilities */
|
---|
646 | case VMMDevReq_SetGuestCapabilities:
|
---|
647 | {
|
---|
648 | if (pRequestHeader->size != sizeof(VMMDevReqGuestCapabilities2))
|
---|
649 | {
|
---|
650 | AssertMsgFailed(("VMMDev guest caps structure has invalid size!\n"));
|
---|
651 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
652 | }
|
---|
653 | else
|
---|
654 | {
|
---|
655 | VMMDevReqGuestCapabilities2 *guestCaps = (VMMDevReqGuestCapabilities2*)pRequestHeader;
|
---|
656 |
|
---|
657 | pThis->guestCaps |= guestCaps->u32OrMask;
|
---|
658 | pThis->guestCaps &= ~guestCaps->u32NotMask;
|
---|
659 |
|
---|
660 | LogRel(("Guest Additions capability report: (0x%x) "
|
---|
661 | "seamless: %s, "
|
---|
662 | "hostWindowMapping: %s, "
|
---|
663 | "graphics: %s\n",
|
---|
664 | pThis->guestCaps,
|
---|
665 | pThis->guestCaps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ? "yes" : "no",
|
---|
666 | pThis->guestCaps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no",
|
---|
667 | pThis->guestCaps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ? "yes" : "no"));
|
---|
668 |
|
---|
669 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
670 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
671 | }
|
---|
672 | break;
|
---|
673 | }
|
---|
674 |
|
---|
675 | /*
|
---|
676 | * Retrieve mouse information
|
---|
677 | */
|
---|
678 | case VMMDevReq_GetMouseStatus:
|
---|
679 | {
|
---|
680 | if (pRequestHeader->size != sizeof(VMMDevReqMouseStatus))
|
---|
681 | {
|
---|
682 | AssertMsgFailed(("VMMDev mouse status structure has invalid size!\n"));
|
---|
683 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
684 | }
|
---|
685 | else
|
---|
686 | {
|
---|
687 | VMMDevReqMouseStatus *mouseStatus = (VMMDevReqMouseStatus*)pRequestHeader;
|
---|
688 | mouseStatus->mouseFeatures = pThis->mouseCapabilities
|
---|
689 | & VMMDEV_MOUSE_MASK;
|
---|
690 | mouseStatus->pointerXPos = pThis->mouseXAbs;
|
---|
691 | mouseStatus->pointerYPos = pThis->mouseYAbs;
|
---|
692 | LogRel2(("%s: VMMDevReq_GetMouseStatus: features = 0x%x, absX = %d, absY = %d\n",
|
---|
693 | __PRETTY_FUNCTION__,
|
---|
694 | mouseStatus->mouseFeatures,
|
---|
695 | mouseStatus->pointerXPos,
|
---|
696 | mouseStatus->pointerYPos));
|
---|
697 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
698 | }
|
---|
699 | break;
|
---|
700 | }
|
---|
701 |
|
---|
702 | /*
|
---|
703 | * Set mouse information
|
---|
704 | */
|
---|
705 | case VMMDevReq_SetMouseStatus:
|
---|
706 | {
|
---|
707 | if (pRequestHeader->size != sizeof(VMMDevReqMouseStatus))
|
---|
708 | {
|
---|
709 | AssertMsgFailed(("VMMDev mouse status structure has invalid size %d (%#x) version=%d!\n",
|
---|
710 | pRequestHeader->size, pRequestHeader->size, pRequestHeader->size, pRequestHeader->version));
|
---|
711 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
712 | }
|
---|
713 | else
|
---|
714 | {
|
---|
715 | bool fNotify = false;
|
---|
716 |
|
---|
717 | uint32_t fFeatures =
|
---|
718 | ((VMMDevReqMouseStatus*)pRequestHeader)->mouseFeatures;
|
---|
719 |
|
---|
720 | LogRelFlowFunc(("VMMDevReqMouseStatus: mouseFeatures = 0x%x\n",
|
---|
721 | fFeatures));
|
---|
722 |
|
---|
723 | if ( (fFeatures & VMMDEV_MOUSE_NOTIFY_HOST_MASK)
|
---|
724 | != ( pThis->mouseCapabilities
|
---|
725 | & VMMDEV_MOUSE_NOTIFY_HOST_MASK))
|
---|
726 | fNotify = true;
|
---|
727 | pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
|
---|
728 | pThis->mouseCapabilities |=
|
---|
729 | (fFeatures & VMMDEV_MOUSE_GUEST_MASK);
|
---|
730 | LogRelFlowFunc(("VMMDevReq_SetMouseStatus: new host capabilities: 0x%x\n",
|
---|
731 | pThis->mouseCapabilities));
|
---|
732 |
|
---|
733 | /*
|
---|
734 | * Notify connector if something has changed
|
---|
735 | */
|
---|
736 | if (fNotify)
|
---|
737 | {
|
---|
738 | LogRelFlowFunc(("VMMDevReq_SetMouseStatus: notifying connector\n"));
|
---|
739 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
740 | }
|
---|
741 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
742 | }
|
---|
743 |
|
---|
744 | break;
|
---|
745 | }
|
---|
746 |
|
---|
747 | /*
|
---|
748 | * Set a new mouse pointer shape
|
---|
749 | */
|
---|
750 | case VMMDevReq_SetPointerShape:
|
---|
751 | {
|
---|
752 | if (pRequestHeader->size < sizeof(VMMDevReqMousePointer))
|
---|
753 | {
|
---|
754 | AssertMsg(pRequestHeader->size == 0x10028 && pRequestHeader->version == 10000, /* don't complain about legacy!!! */
|
---|
755 | ("VMMDev mouse shape structure has invalid size %d (%#x) version=%d!\n",
|
---|
756 | pRequestHeader->size, pRequestHeader->size, pRequestHeader->size, pRequestHeader->version));
|
---|
757 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
758 | }
|
---|
759 | else
|
---|
760 | {
|
---|
761 | VMMDevReqMousePointer *pointerShape = (VMMDevReqMousePointer*)pRequestHeader;
|
---|
762 |
|
---|
763 | bool fVisible = (pointerShape->fFlags & VBOX_MOUSE_POINTER_VISIBLE) != 0;
|
---|
764 | bool fAlpha = (pointerShape->fFlags & VBOX_MOUSE_POINTER_ALPHA) != 0;
|
---|
765 | bool fShape = (pointerShape->fFlags & VBOX_MOUSE_POINTER_SHAPE) != 0;
|
---|
766 |
|
---|
767 | Log(("VMMDevReq_SetPointerShape: visible: %d, alpha: %d, shape = %d, width: %d, height: %d\n",
|
---|
768 | fVisible, fAlpha, fShape, pointerShape->width, pointerShape->height));
|
---|
769 |
|
---|
770 | if (pRequestHeader->size == sizeof(VMMDevReqMousePointer))
|
---|
771 | {
|
---|
772 | /* The guest did not provide the shape actually. */
|
---|
773 | fShape = false;
|
---|
774 | }
|
---|
775 |
|
---|
776 | /* forward call to driver */
|
---|
777 | if (fShape)
|
---|
778 | {
|
---|
779 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
780 | fVisible,
|
---|
781 | fAlpha,
|
---|
782 | pointerShape->xHot, pointerShape->yHot,
|
---|
783 | pointerShape->width, pointerShape->height,
|
---|
784 | pointerShape->pointerData);
|
---|
785 | }
|
---|
786 | else
|
---|
787 | {
|
---|
788 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
789 | fVisible,
|
---|
790 | 0,
|
---|
791 | 0, 0,
|
---|
792 | 0, 0,
|
---|
793 | NULL);
|
---|
794 | }
|
---|
795 | pThis->fHostCursorRequested = fVisible;
|
---|
796 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
797 | }
|
---|
798 | break;
|
---|
799 | }
|
---|
800 |
|
---|
801 | /*
|
---|
802 | * Query the system time from the host
|
---|
803 | */
|
---|
804 | case VMMDevReq_GetHostTime:
|
---|
805 | {
|
---|
806 | if (pRequestHeader->size != sizeof(VMMDevReqHostTime))
|
---|
807 | {
|
---|
808 | AssertMsgFailed(("VMMDev host time structure has invalid size!\n"));
|
---|
809 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
810 | }
|
---|
811 | else if (RT_UNLIKELY(pThis->fGetHostTimeDisabled))
|
---|
812 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
813 | else
|
---|
814 | {
|
---|
815 | VMMDevReqHostTime *hostTimeReq = (VMMDevReqHostTime*)pRequestHeader;
|
---|
816 | RTTIMESPEC now;
|
---|
817 | hostTimeReq->time = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &now));
|
---|
818 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
819 | }
|
---|
820 | break;
|
---|
821 | }
|
---|
822 |
|
---|
823 | /*
|
---|
824 | * Query information about the hypervisor
|
---|
825 | */
|
---|
826 | case VMMDevReq_GetHypervisorInfo:
|
---|
827 | {
|
---|
828 | if (pRequestHeader->size != sizeof(VMMDevReqHypervisorInfo))
|
---|
829 | {
|
---|
830 | AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n"));
|
---|
831 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
832 | }
|
---|
833 | else
|
---|
834 | {
|
---|
835 | VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*)pRequestHeader;
|
---|
836 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
837 | pRequestHeader->rc = PGMR3MappingsSize(pVM, &hypervisorInfo->hypervisorSize);
|
---|
838 | }
|
---|
839 | break;
|
---|
840 | }
|
---|
841 |
|
---|
842 | /*
|
---|
843 | * Set hypervisor information
|
---|
844 | */
|
---|
845 | case VMMDevReq_SetHypervisorInfo:
|
---|
846 | {
|
---|
847 | if (pRequestHeader->size != sizeof(VMMDevReqHypervisorInfo))
|
---|
848 | {
|
---|
849 | AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n"));
|
---|
850 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
851 | }
|
---|
852 | else
|
---|
853 | {
|
---|
854 | VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*)pRequestHeader;
|
---|
855 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
856 | if (hypervisorInfo->hypervisorStart == 0)
|
---|
857 | pRequestHeader->rc = PGMR3MappingsUnfix(pVM);
|
---|
858 | else
|
---|
859 | {
|
---|
860 | /* only if the client has queried the size before! */
|
---|
861 | uint32_t mappingsSize;
|
---|
862 | pRequestHeader->rc = PGMR3MappingsSize(pVM, &mappingsSize);
|
---|
863 | if (RT_SUCCESS(pRequestHeader->rc) && hypervisorInfo->hypervisorSize == mappingsSize)
|
---|
864 | {
|
---|
865 | /* new reservation */
|
---|
866 | pRequestHeader->rc = PGMR3MappingsFix(pVM, hypervisorInfo->hypervisorStart,
|
---|
867 | hypervisorInfo->hypervisorSize);
|
---|
868 | LogRel(("Guest reported fixed hypervisor window at 0x%p (size = 0x%x, rc = %Rrc)\n",
|
---|
869 | (uintptr_t)hypervisorInfo->hypervisorStart,
|
---|
870 | hypervisorInfo->hypervisorSize,
|
---|
871 | pRequestHeader->rc));
|
---|
872 | }
|
---|
873 | }
|
---|
874 | }
|
---|
875 | break;
|
---|
876 | }
|
---|
877 |
|
---|
878 | case VMMDevReq_RegisterPatchMemory:
|
---|
879 | {
|
---|
880 | if (pRequestHeader->size != sizeof(VMMDevReqPatchMemory))
|
---|
881 | {
|
---|
882 | AssertMsgFailed(("VMMDevReq_RegisterPatchMemory structure has invalid size!\n"));
|
---|
883 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
884 | }
|
---|
885 | else
|
---|
886 | {
|
---|
887 | VMMDevReqPatchMemory *pPatchRequest = (VMMDevReqPatchMemory*)pRequestHeader;
|
---|
888 |
|
---|
889 | pRequestHeader->rc = VMMR3RegisterPatchMemory(PDMDevHlpGetVM(pDevIns), pPatchRequest->pPatchMem, pPatchRequest->cbPatchMem);
|
---|
890 | }
|
---|
891 | break;
|
---|
892 | }
|
---|
893 |
|
---|
894 | case VMMDevReq_DeregisterPatchMemory:
|
---|
895 | {
|
---|
896 | if (pRequestHeader->size != sizeof(VMMDevReqPatchMemory))
|
---|
897 | {
|
---|
898 | AssertMsgFailed(("VMMDevReq_DeregisterPatchMemory structure has invalid size!\n"));
|
---|
899 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
900 | }
|
---|
901 | else
|
---|
902 | {
|
---|
903 | VMMDevReqPatchMemory *pPatchRequest = (VMMDevReqPatchMemory*)pRequestHeader;
|
---|
904 |
|
---|
905 | pRequestHeader->rc = VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(pDevIns), pPatchRequest->pPatchMem, pPatchRequest->cbPatchMem);
|
---|
906 | }
|
---|
907 | break;
|
---|
908 | }
|
---|
909 |
|
---|
910 | /*
|
---|
911 | * Set the system power status
|
---|
912 | */
|
---|
913 | case VMMDevReq_SetPowerStatus:
|
---|
914 | {
|
---|
915 | if (pRequestHeader->size != sizeof(VMMDevPowerStateRequest))
|
---|
916 | {
|
---|
917 | AssertMsgFailed(("VMMDev power state request structure has invalid size!\n"));
|
---|
918 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
919 | }
|
---|
920 | else
|
---|
921 | {
|
---|
922 | VMMDevPowerStateRequest *powerStateRequest = (VMMDevPowerStateRequest*)pRequestHeader;
|
---|
923 | switch(powerStateRequest->powerState)
|
---|
924 | {
|
---|
925 | case VMMDevPowerState_Pause:
|
---|
926 | {
|
---|
927 | LogRel(("Guest requests the VM to be suspended (paused)\n"));
|
---|
928 | pRequestHeader->rc = rcRet = PDMDevHlpVMSuspend(pDevIns);
|
---|
929 | break;
|
---|
930 | }
|
---|
931 |
|
---|
932 | case VMMDevPowerState_PowerOff:
|
---|
933 | {
|
---|
934 | LogRel(("Guest requests the VM to be turned off\n"));
|
---|
935 | pRequestHeader->rc = rcRet = PDMDevHlpVMPowerOff(pDevIns);
|
---|
936 | break;
|
---|
937 | }
|
---|
938 |
|
---|
939 | case VMMDevPowerState_SaveState:
|
---|
940 | {
|
---|
941 | if (true /*pThis->fAllowGuestToSaveState*/)
|
---|
942 | {
|
---|
943 | LogRel(("Guest requests the VM to be saved and powered off\n"));
|
---|
944 | pRequestHeader->rc = rcRet = PDMDevHlpVMSuspendSaveAndPowerOff(pDevIns);
|
---|
945 | }
|
---|
946 | else
|
---|
947 | {
|
---|
948 | LogRel(("Guest requests the VM to be saved and powered off, declined\n"));
|
---|
949 | pRequestHeader->rc = VERR_ACCESS_DENIED;
|
---|
950 | }
|
---|
951 | break;
|
---|
952 | }
|
---|
953 |
|
---|
954 | default:
|
---|
955 | AssertMsgFailed(("VMMDev invalid power state request: %d\n", powerStateRequest->powerState));
|
---|
956 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
957 | break;
|
---|
958 | }
|
---|
959 | }
|
---|
960 | break;
|
---|
961 | }
|
---|
962 |
|
---|
963 | /*
|
---|
964 | * Get display change request
|
---|
965 | */
|
---|
966 | case VMMDevReq_GetDisplayChangeRequest:
|
---|
967 | {
|
---|
968 | if (pRequestHeader->size != sizeof(VMMDevDisplayChangeRequest))
|
---|
969 | {
|
---|
970 | /* Assert only if the size also not equal to a previous version size to prevent
|
---|
971 | * assertion with old additions.
|
---|
972 | */
|
---|
973 | AssertMsg(pRequestHeader->size == sizeof(VMMDevDisplayChangeRequest) - sizeof (uint32_t),
|
---|
974 | ("VMMDev display change request structure has invalid size!\n"));
|
---|
975 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
976 | }
|
---|
977 | else
|
---|
978 | {
|
---|
979 | VMMDevDisplayChangeRequest *displayChangeRequest = (VMMDevDisplayChangeRequest*)pRequestHeader;
|
---|
980 |
|
---|
981 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[0];
|
---|
982 |
|
---|
983 | if (displayChangeRequest->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
984 | {
|
---|
985 | /* Current request has been read at least once. */
|
---|
986 | pRequest->fPending = false;
|
---|
987 |
|
---|
988 | /* Check if there are more pending requests. */
|
---|
989 | for (unsigned i = 1; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
990 | {
|
---|
991 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
992 | {
|
---|
993 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
994 | break;
|
---|
995 | }
|
---|
996 | }
|
---|
997 |
|
---|
998 | /* Remember which resolution the client has queried, subsequent reads
|
---|
999 | * will return the same values. */
|
---|
1000 | pRequest->lastReadDisplayChangeRequest = pRequest->displayChangeRequest;
|
---|
1001 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1002 | }
|
---|
1003 |
|
---|
1004 | if (pThis->displayChangeData.fGuestSentChangeEventAck)
|
---|
1005 | {
|
---|
1006 | displayChangeRequest->xres = pRequest->lastReadDisplayChangeRequest.xres;
|
---|
1007 | displayChangeRequest->yres = pRequest->lastReadDisplayChangeRequest.yres;
|
---|
1008 | displayChangeRequest->bpp = pRequest->lastReadDisplayChangeRequest.bpp;
|
---|
1009 | }
|
---|
1010 | else
|
---|
1011 | {
|
---|
1012 | /* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1013 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1014 | * determines the initial mode. */
|
---|
1015 | displayChangeRequest->xres = pRequest->displayChangeRequest.xres;
|
---|
1016 | displayChangeRequest->yres = pRequest->displayChangeRequest.yres;
|
---|
1017 | displayChangeRequest->bpp = pRequest->displayChangeRequest.bpp;
|
---|
1018 | }
|
---|
1019 | Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d\n",
|
---|
1020 | displayChangeRequest->xres, displayChangeRequest->yres, displayChangeRequest->bpp));
|
---|
1021 |
|
---|
1022 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1023 | }
|
---|
1024 | break;
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | case VMMDevReq_GetDisplayChangeRequest2:
|
---|
1028 | {
|
---|
1029 | if (pRequestHeader->size != sizeof(VMMDevDisplayChangeRequest2))
|
---|
1030 | {
|
---|
1031 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1032 | }
|
---|
1033 | else
|
---|
1034 | {
|
---|
1035 | VMMDevDisplayChangeRequest2 *displayChangeRequest = (VMMDevDisplayChangeRequest2*)pRequestHeader;
|
---|
1036 |
|
---|
1037 | DISPLAYCHANGEREQUEST *pRequest = NULL;
|
---|
1038 |
|
---|
1039 | if (displayChangeRequest->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1040 | {
|
---|
1041 | /* Select a pending request to report. */
|
---|
1042 | unsigned i;
|
---|
1043 | for (i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1044 | {
|
---|
1045 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1046 | {
|
---|
1047 | pRequest = &pThis->displayChangeData.aRequests[i];
|
---|
1048 | /* Remember which request should be reported. */
|
---|
1049 | pThis->displayChangeData.iCurrentMonitor = i;
|
---|
1050 | Log3(("VMMDev: will report pending request for %d\n",
|
---|
1051 | i));
|
---|
1052 | break;
|
---|
1053 | }
|
---|
1054 | }
|
---|
1055 |
|
---|
1056 | /* Check if there are more pending requests. */
|
---|
1057 | i++;
|
---|
1058 | for (; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1059 | {
|
---|
1060 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1061 | {
|
---|
1062 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
1063 | Log3(("VMMDev: another pending at %d\n",
|
---|
1064 | i));
|
---|
1065 | break;
|
---|
1066 | }
|
---|
1067 | }
|
---|
1068 |
|
---|
1069 | if (pRequest)
|
---|
1070 | {
|
---|
1071 | /* Current request has been read at least once. */
|
---|
1072 | pRequest->fPending = false;
|
---|
1073 |
|
---|
1074 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1075 | * will return the same values. */
|
---|
1076 | pRequest->lastReadDisplayChangeRequest = pRequest->displayChangeRequest;
|
---|
1077 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1078 | }
|
---|
1079 | else
|
---|
1080 | {
|
---|
1081 | Log3(("VMMDev: no pending request!!!\n"));
|
---|
1082 | }
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | if (!pRequest)
|
---|
1086 | {
|
---|
1087 | Log3(("VMMDev: default to %d\n",
|
---|
1088 | pThis->displayChangeData.iCurrentMonitor));
|
---|
1089 | pRequest = &pThis->displayChangeData.aRequests[pThis->displayChangeData.iCurrentMonitor];
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | if (pThis->displayChangeData.fGuestSentChangeEventAck)
|
---|
1093 | {
|
---|
1094 | displayChangeRequest->xres = pRequest->lastReadDisplayChangeRequest.xres;
|
---|
1095 | displayChangeRequest->yres = pRequest->lastReadDisplayChangeRequest.yres;
|
---|
1096 | displayChangeRequest->bpp = pRequest->lastReadDisplayChangeRequest.bpp;
|
---|
1097 | displayChangeRequest->display = pRequest->lastReadDisplayChangeRequest.display;
|
---|
1098 | }
|
---|
1099 | else
|
---|
1100 | {
|
---|
1101 | /* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1102 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1103 | * determines the initial video mode. */
|
---|
1104 | displayChangeRequest->xres = pRequest->displayChangeRequest.xres;
|
---|
1105 | displayChangeRequest->yres = pRequest->displayChangeRequest.yres;
|
---|
1106 | displayChangeRequest->bpp = pRequest->displayChangeRequest.bpp;
|
---|
1107 | displayChangeRequest->display = pRequest->displayChangeRequest.display;
|
---|
1108 | }
|
---|
1109 | Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d at %d\n",
|
---|
1110 | displayChangeRequest->xres, displayChangeRequest->yres, displayChangeRequest->bpp, displayChangeRequest->display));
|
---|
1111 |
|
---|
1112 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1113 | }
|
---|
1114 | break;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | /*
|
---|
1118 | * Query whether the given video mode is supported
|
---|
1119 | */
|
---|
1120 | case VMMDevReq_VideoModeSupported:
|
---|
1121 | {
|
---|
1122 | if (pRequestHeader->size != sizeof(VMMDevVideoModeSupportedRequest))
|
---|
1123 | {
|
---|
1124 | AssertMsgFailed(("VMMDev video mode supported request structure has invalid size!\n"));
|
---|
1125 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1126 | }
|
---|
1127 | else
|
---|
1128 | {
|
---|
1129 | VMMDevVideoModeSupportedRequest *videoModeSupportedRequest = (VMMDevVideoModeSupportedRequest*)pRequestHeader;
|
---|
1130 | /* forward the call */
|
---|
1131 | pRequestHeader->rc = pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
|
---|
1132 | 0, /* primary screen. */
|
---|
1133 | videoModeSupportedRequest->width,
|
---|
1134 | videoModeSupportedRequest->height,
|
---|
1135 | videoModeSupportedRequest->bpp,
|
---|
1136 | &videoModeSupportedRequest->fSupported);
|
---|
1137 | }
|
---|
1138 | break;
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 | /*
|
---|
1142 | * Query whether the given video mode is supported for a specific display
|
---|
1143 | */
|
---|
1144 | case VMMDevReq_VideoModeSupported2:
|
---|
1145 | {
|
---|
1146 | if (pRequestHeader->size != sizeof(VMMDevVideoModeSupportedRequest2))
|
---|
1147 | {
|
---|
1148 | AssertMsgFailed(("VMMDev video mode supported request 2 structure has invalid size!\n"));
|
---|
1149 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1150 | }
|
---|
1151 | else
|
---|
1152 | {
|
---|
1153 | VMMDevVideoModeSupportedRequest2 *videoModeSupportedRequest2 = (VMMDevVideoModeSupportedRequest2*)pRequestHeader;
|
---|
1154 | /* forward the call */
|
---|
1155 | pRequestHeader->rc = pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
|
---|
1156 | videoModeSupportedRequest2->display,
|
---|
1157 | videoModeSupportedRequest2->width,
|
---|
1158 | videoModeSupportedRequest2->height,
|
---|
1159 | videoModeSupportedRequest2->bpp,
|
---|
1160 | &videoModeSupportedRequest2->fSupported);
|
---|
1161 | }
|
---|
1162 | break;
|
---|
1163 | }
|
---|
1164 |
|
---|
1165 | /*
|
---|
1166 | * Query the height reduction in pixels
|
---|
1167 | */
|
---|
1168 | case VMMDevReq_GetHeightReduction:
|
---|
1169 | {
|
---|
1170 | if (pRequestHeader->size != sizeof(VMMDevGetHeightReductionRequest))
|
---|
1171 | {
|
---|
1172 | AssertMsgFailed(("VMMDev height reduction request structure has invalid size!\n"));
|
---|
1173 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1174 | }
|
---|
1175 | else
|
---|
1176 | {
|
---|
1177 | VMMDevGetHeightReductionRequest *heightReductionRequest = (VMMDevGetHeightReductionRequest*)pRequestHeader;
|
---|
1178 | /* forward the call */
|
---|
1179 | pRequestHeader->rc = pThis->pDrv->pfnGetHeightReduction(pThis->pDrv,
|
---|
1180 | &heightReductionRequest->heightReduction);
|
---|
1181 | }
|
---|
1182 | break;
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 | /*
|
---|
1186 | * Acknowledge VMMDev events
|
---|
1187 | */
|
---|
1188 | case VMMDevReq_AcknowledgeEvents:
|
---|
1189 | {
|
---|
1190 | if (pRequestHeader->size != sizeof(VMMDevEvents))
|
---|
1191 | {
|
---|
1192 | AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n"));
|
---|
1193 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1194 | }
|
---|
1195 | else
|
---|
1196 | {
|
---|
1197 | if (VBOX_GUEST_INTERFACE_VERSION_1_03 (pThis))
|
---|
1198 | {
|
---|
1199 | vmmdevSetIRQ_Legacy_EMT (pThis);
|
---|
1200 | }
|
---|
1201 | else
|
---|
1202 | {
|
---|
1203 | VMMDevEvents *pAckRequest;
|
---|
1204 |
|
---|
1205 | if (pThis->fNewGuestFilterMask)
|
---|
1206 | {
|
---|
1207 | pThis->fNewGuestFilterMask = false;
|
---|
1208 | pThis->u32GuestFilterMask = pThis->u32NewGuestFilterMask;
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 | pAckRequest = (VMMDevEvents *)pRequestHeader;
|
---|
1212 | pAckRequest->events =
|
---|
1213 | pThis->u32HostEventFlags & pThis->u32GuestFilterMask;
|
---|
1214 |
|
---|
1215 | pThis->u32HostEventFlags &= ~pThis->u32GuestFilterMask;
|
---|
1216 | pThis->pVMMDevRAMR3->V.V1_04.fHaveEvents = false;
|
---|
1217 | PDMDevHlpPCISetIrqNoWait (pThis->pDevIns, 0, 0);
|
---|
1218 | }
|
---|
1219 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1220 | }
|
---|
1221 | break;
|
---|
1222 | }
|
---|
1223 |
|
---|
1224 | /*
|
---|
1225 | * Change guest filter mask
|
---|
1226 | */
|
---|
1227 | case VMMDevReq_CtlGuestFilterMask:
|
---|
1228 | {
|
---|
1229 | if (pRequestHeader->size != sizeof(VMMDevCtlGuestFilterMask))
|
---|
1230 | {
|
---|
1231 | AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n"));
|
---|
1232 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1233 | }
|
---|
1234 | else
|
---|
1235 | {
|
---|
1236 | VMMDevCtlGuestFilterMask *pCtlMaskRequest;
|
---|
1237 |
|
---|
1238 | pCtlMaskRequest = (VMMDevCtlGuestFilterMask *)pRequestHeader;
|
---|
1239 | LogRelFlowFunc(("VMMDevCtlGuestFilterMask: or mask: 0x%x, not mask: 0x%x\n",
|
---|
1240 | pCtlMaskRequest->u32OrMask,
|
---|
1241 | pCtlMaskRequest->u32NotMask));
|
---|
1242 | /* HGCM event notification is enabled by the VMMDev device
|
---|
1243 | * automatically when any HGCM command is issued. The guest
|
---|
1244 | * cannot disable these notifications.
|
---|
1245 | */
|
---|
1246 | VMMDevCtlSetGuestFilterMask (pThis,
|
---|
1247 | pCtlMaskRequest->u32OrMask,
|
---|
1248 | pCtlMaskRequest->u32NotMask & ~VMMDEV_EVENT_HGCM);
|
---|
1249 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1250 |
|
---|
1251 | }
|
---|
1252 | break;
|
---|
1253 | }
|
---|
1254 |
|
---|
1255 | #ifdef VBOX_WITH_HGCM
|
---|
1256 | /*
|
---|
1257 | * Process HGCM request
|
---|
1258 | */
|
---|
1259 | case VMMDevReq_HGCMConnect:
|
---|
1260 | {
|
---|
1261 | if (pRequestHeader->size < sizeof(VMMDevHGCMConnect))
|
---|
1262 | {
|
---|
1263 | AssertMsgFailed(("VMMDevReq_HGCMConnect structure has invalid size!\n"));
|
---|
1264 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1265 | }
|
---|
1266 | else if (!pThis->pHGCMDrv)
|
---|
1267 | {
|
---|
1268 | Log(("VMMDevReq_HGCMConnect HGCM Connector is NULL!\n"));
|
---|
1269 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1270 | }
|
---|
1271 | else
|
---|
1272 | {
|
---|
1273 | VMMDevHGCMConnect *pHGCMConnect = (VMMDevHGCMConnect *)pRequestHeader;
|
---|
1274 |
|
---|
1275 | Log(("VMMDevReq_HGCMConnect\n"));
|
---|
1276 |
|
---|
1277 | pRequestHeader->rc = vmmdevHGCMConnect (pThis, pHGCMConnect, (RTGCPHYS)u32);
|
---|
1278 | }
|
---|
1279 | break;
|
---|
1280 | }
|
---|
1281 |
|
---|
1282 | case VMMDevReq_HGCMDisconnect:
|
---|
1283 | {
|
---|
1284 | if (pRequestHeader->size < sizeof(VMMDevHGCMDisconnect))
|
---|
1285 | {
|
---|
1286 | AssertMsgFailed(("VMMDevReq_HGCMDisconnect structure has invalid size!\n"));
|
---|
1287 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1288 | }
|
---|
1289 | else if (!pThis->pHGCMDrv)
|
---|
1290 | {
|
---|
1291 | Log(("VMMDevReq_HGCMDisconnect HGCM Connector is NULL!\n"));
|
---|
1292 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1293 | }
|
---|
1294 | else
|
---|
1295 | {
|
---|
1296 | VMMDevHGCMDisconnect *pHGCMDisconnect = (VMMDevHGCMDisconnect *)pRequestHeader;
|
---|
1297 |
|
---|
1298 | Log(("VMMDevReq_VMMDevHGCMDisconnect\n"));
|
---|
1299 | pRequestHeader->rc = vmmdevHGCMDisconnect (pThis, pHGCMDisconnect, (RTGCPHYS)u32);
|
---|
1300 | }
|
---|
1301 | break;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
1305 | case VMMDevReq_HGCMCall32:
|
---|
1306 | case VMMDevReq_HGCMCall64:
|
---|
1307 | #else
|
---|
1308 | case VMMDevReq_HGCMCall:
|
---|
1309 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
1310 | {
|
---|
1311 | if (pRequestHeader->size < sizeof(VMMDevHGCMCall))
|
---|
1312 | {
|
---|
1313 | AssertMsgFailed(("VMMDevReq_HGCMCall structure has invalid size!\n"));
|
---|
1314 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1315 | }
|
---|
1316 | else if (!pThis->pHGCMDrv)
|
---|
1317 | {
|
---|
1318 | Log(("VMMDevReq_HGCMCall HGCM Connector is NULL!\n"));
|
---|
1319 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1320 | }
|
---|
1321 | else
|
---|
1322 | {
|
---|
1323 | VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pRequestHeader;
|
---|
1324 |
|
---|
1325 | Log2(("VMMDevReq_HGCMCall: sizeof (VMMDevHGCMRequest) = %04X\n", sizeof (VMMDevHGCMCall)));
|
---|
1326 | Log2(("%.*Rhxd\n", pRequestHeader->size, pRequestHeader));
|
---|
1327 |
|
---|
1328 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
1329 | bool f64Bits = (pRequestHeader->requestType == VMMDevReq_HGCMCall64);
|
---|
1330 | #else
|
---|
1331 | bool f64Bits = false;
|
---|
1332 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
1333 |
|
---|
1334 | pRequestHeader->rc = vmmdevHGCMCall (pThis, pHGCMCall, requestHeader.size, (RTGCPHYS)u32, f64Bits);
|
---|
1335 | }
|
---|
1336 | break;
|
---|
1337 | }
|
---|
1338 | #endif /* VBOX_WITH_HGCM */
|
---|
1339 |
|
---|
1340 | case VMMDevReq_HGCMCancel:
|
---|
1341 | {
|
---|
1342 | if (pRequestHeader->size < sizeof(VMMDevHGCMCancel))
|
---|
1343 | {
|
---|
1344 | AssertMsgFailed(("VMMDevReq_HGCMCancel structure has invalid size!\n"));
|
---|
1345 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1346 | }
|
---|
1347 | else if (!pThis->pHGCMDrv)
|
---|
1348 | {
|
---|
1349 | Log(("VMMDevReq_HGCMCancel HGCM Connector is NULL!\n"));
|
---|
1350 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1351 | }
|
---|
1352 | else
|
---|
1353 | {
|
---|
1354 | VMMDevHGCMCancel *pHGCMCancel = (VMMDevHGCMCancel *)pRequestHeader;
|
---|
1355 |
|
---|
1356 | Log(("VMMDevReq_VMMDevHGCMCancel\n"));
|
---|
1357 | pRequestHeader->rc = vmmdevHGCMCancel (pThis, pHGCMCancel, (RTGCPHYS)u32);
|
---|
1358 | }
|
---|
1359 | break;
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | case VMMDevReq_HGCMCancel2:
|
---|
1363 | {
|
---|
1364 | if (pRequestHeader->size != sizeof(VMMDevHGCMCancel2))
|
---|
1365 | {
|
---|
1366 | AssertMsgFailed(("VMMDevReq_HGCMCancel structure has invalid size!\n"));
|
---|
1367 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1368 | }
|
---|
1369 | else if (!pThis->pHGCMDrv)
|
---|
1370 | {
|
---|
1371 | Log(("VMMDevReq_HGCMCancel HGCM Connector is NULL!\n"));
|
---|
1372 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1373 | }
|
---|
1374 | else
|
---|
1375 | {
|
---|
1376 | VMMDevHGCMCancel2 *pHGCMCancel2 = (VMMDevHGCMCancel2 *)pRequestHeader;
|
---|
1377 |
|
---|
1378 | Log(("VMMDevReq_VMMDevHGCMCancel\n"));
|
---|
1379 | pRequestHeader->rc = vmmdevHGCMCancel2 (pThis, pHGCMCancel2->physReqToCancel);
|
---|
1380 | }
|
---|
1381 | break;
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | case VMMDevReq_VideoAccelEnable:
|
---|
1385 | {
|
---|
1386 | if (pRequestHeader->size < sizeof(VMMDevVideoAccelEnable))
|
---|
1387 | {
|
---|
1388 | Log(("VMMDevReq_VideoAccelEnable request size too small!!!\n"));
|
---|
1389 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1390 | }
|
---|
1391 | else if (!pThis->pDrv)
|
---|
1392 | {
|
---|
1393 | Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!!\n"));
|
---|
1394 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1395 | }
|
---|
1396 | else
|
---|
1397 | {
|
---|
1398 | VMMDevVideoAccelEnable *ptr = (VMMDevVideoAccelEnable *)pRequestHeader;
|
---|
1399 |
|
---|
1400 | if (ptr->cbRingBuffer != VBVA_RING_BUFFER_SIZE)
|
---|
1401 | {
|
---|
1402 | /* The guest driver seems compiled with another headers. */
|
---|
1403 | Log(("VMMDevReq_VideoAccelEnable guest ring buffer size %d, should be %d!!!\n", ptr->cbRingBuffer, VBVA_RING_BUFFER_SIZE));
|
---|
1404 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1405 | }
|
---|
1406 | else
|
---|
1407 | {
|
---|
1408 | /* The request is correct. */
|
---|
1409 | ptr->fu32Status |= VBVA_F_STATUS_ACCEPTED;
|
---|
1410 |
|
---|
1411 | LogFlow(("VMMDevReq_VideoAccelEnable ptr->u32Enable = %d\n", ptr->u32Enable));
|
---|
1412 |
|
---|
1413 | pRequestHeader->rc = ptr->u32Enable?
|
---|
1414 | pThis->pDrv->pfnVideoAccelEnable (pThis->pDrv, true, &pThis->pVMMDevRAMR3->vbvaMemory):
|
---|
1415 | pThis->pDrv->pfnVideoAccelEnable (pThis->pDrv, false, NULL);
|
---|
1416 |
|
---|
1417 | if ( ptr->u32Enable
|
---|
1418 | && RT_SUCCESS (pRequestHeader->rc))
|
---|
1419 | {
|
---|
1420 | ptr->fu32Status |= VBVA_F_STATUS_ENABLED;
|
---|
1421 |
|
---|
1422 | /* Remember that guest successfully enabled acceleration.
|
---|
1423 | * We need to reestablish it on restoring the VM from saved state.
|
---|
1424 | */
|
---|
1425 | pThis->u32VideoAccelEnabled = 1;
|
---|
1426 | }
|
---|
1427 | else
|
---|
1428 | {
|
---|
1429 | /* The acceleration was not enabled. Remember that. */
|
---|
1430 | pThis->u32VideoAccelEnabled = 0;
|
---|
1431 | }
|
---|
1432 | }
|
---|
1433 | }
|
---|
1434 | break;
|
---|
1435 | }
|
---|
1436 |
|
---|
1437 | case VMMDevReq_VideoAccelFlush:
|
---|
1438 | {
|
---|
1439 | if (pRequestHeader->size < sizeof(VMMDevVideoAccelFlush))
|
---|
1440 | {
|
---|
1441 | AssertMsgFailed(("VMMDevReq_VideoAccelFlush request size too small.\n"));
|
---|
1442 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1443 | }
|
---|
1444 | else if (!pThis->pDrv)
|
---|
1445 | {
|
---|
1446 | Log(("VMMDevReq_VideoAccelFlush Connector is NULL!\n"));
|
---|
1447 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1448 | }
|
---|
1449 | else
|
---|
1450 | {
|
---|
1451 | pThis->pDrv->pfnVideoAccelFlush (pThis->pDrv);
|
---|
1452 |
|
---|
1453 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1454 | }
|
---|
1455 | break;
|
---|
1456 | }
|
---|
1457 |
|
---|
1458 | case VMMDevReq_VideoSetVisibleRegion:
|
---|
1459 | {
|
---|
1460 | if (pRequestHeader->size < sizeof(VMMDevVideoSetVisibleRegion))
|
---|
1461 | {
|
---|
1462 | Log(("VMMDevReq_VideoSetVisibleRegion request size too small!!!\n"));
|
---|
1463 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1464 | }
|
---|
1465 | else if (!pThis->pDrv)
|
---|
1466 | {
|
---|
1467 | Log(("VMMDevReq_VideoSetVisibleRegion Connector is NULL!!!\n"));
|
---|
1468 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1469 | }
|
---|
1470 | else
|
---|
1471 | {
|
---|
1472 | VMMDevVideoSetVisibleRegion *ptr = (VMMDevVideoSetVisibleRegion *)pRequestHeader;
|
---|
1473 |
|
---|
1474 | if (!ptr->cRect)
|
---|
1475 | {
|
---|
1476 | Log(("VMMDevReq_VideoSetVisibleRegion no rectangles!!!\n"));
|
---|
1477 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1478 | }
|
---|
1479 | else
|
---|
1480 | if (pRequestHeader->size != sizeof(VMMDevVideoSetVisibleRegion) + (ptr->cRect-1)*sizeof(RTRECT))
|
---|
1481 | {
|
---|
1482 | Log(("VMMDevReq_VideoSetVisibleRegion request size too small!!!\n"));
|
---|
1483 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1484 | }
|
---|
1485 | else
|
---|
1486 | {
|
---|
1487 | Log(("VMMDevReq_VideoSetVisibleRegion %d rectangles\n", ptr->cRect));
|
---|
1488 | /* forward the call */
|
---|
1489 | pRequestHeader->rc = pThis->pDrv->pfnSetVisibleRegion(pThis->pDrv, ptr->cRect, &ptr->Rect);
|
---|
1490 | }
|
---|
1491 | }
|
---|
1492 | break;
|
---|
1493 | }
|
---|
1494 |
|
---|
1495 | case VMMDevReq_GetSeamlessChangeRequest:
|
---|
1496 | {
|
---|
1497 | if (pRequestHeader->size != sizeof(VMMDevSeamlessChangeRequest))
|
---|
1498 | {
|
---|
1499 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1500 | }
|
---|
1501 | else
|
---|
1502 | {
|
---|
1503 | VMMDevSeamlessChangeRequest *seamlessChangeRequest = (VMMDevSeamlessChangeRequest*)pRequestHeader;
|
---|
1504 | /* just pass on the information */
|
---|
1505 | Log(("VMMDev: returning seamless change request mode=%d\n", pThis->fSeamlessEnabled));
|
---|
1506 | if (pThis->fSeamlessEnabled)
|
---|
1507 | seamlessChangeRequest->mode = VMMDev_Seamless_Visible_Region;
|
---|
1508 | else
|
---|
1509 | seamlessChangeRequest->mode = VMMDev_Seamless_Disabled;
|
---|
1510 |
|
---|
1511 | if (seamlessChangeRequest->eventAck == VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
|
---|
1512 | {
|
---|
1513 | /* Remember which mode the client has queried. */
|
---|
1514 | pThis->fLastSeamlessEnabled = pThis->fSeamlessEnabled;
|
---|
1515 | }
|
---|
1516 |
|
---|
1517 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1518 | }
|
---|
1519 | break;
|
---|
1520 | }
|
---|
1521 |
|
---|
1522 | case VMMDevReq_GetVRDPChangeRequest:
|
---|
1523 | {
|
---|
1524 | if (pRequestHeader->size != sizeof(VMMDevVRDPChangeRequest))
|
---|
1525 | {
|
---|
1526 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1527 | }
|
---|
1528 | else
|
---|
1529 | {
|
---|
1530 | VMMDevVRDPChangeRequest *vrdpChangeRequest = (VMMDevVRDPChangeRequest*)pRequestHeader;
|
---|
1531 | /* just pass on the information */
|
---|
1532 | Log(("VMMDev: returning VRDP status %d level %d\n", pThis->fVRDPEnabled, pThis->u32VRDPExperienceLevel));
|
---|
1533 |
|
---|
1534 | vrdpChangeRequest->u8VRDPActive = pThis->fVRDPEnabled;
|
---|
1535 | vrdpChangeRequest->u32VRDPExperienceLevel = pThis->u32VRDPExperienceLevel;
|
---|
1536 |
|
---|
1537 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1538 | }
|
---|
1539 | break;
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | case VMMDevReq_GetMemBalloonChangeRequest:
|
---|
1543 | {
|
---|
1544 | Log(("VMMDevReq_GetMemBalloonChangeRequest\n"));
|
---|
1545 | if (pRequestHeader->size != sizeof(VMMDevGetMemBalloonChangeRequest))
|
---|
1546 | {
|
---|
1547 | AssertFailed();
|
---|
1548 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1549 | }
|
---|
1550 | else
|
---|
1551 | {
|
---|
1552 | VMMDevGetMemBalloonChangeRequest *memBalloonChangeRequest = (VMMDevGetMemBalloonChangeRequest*)pRequestHeader;
|
---|
1553 | /* just pass on the information */
|
---|
1554 | Log(("VMMDev: returning memory balloon size =%d\n", pThis->u32MemoryBalloonSize));
|
---|
1555 | memBalloonChangeRequest->cBalloonChunks = pThis->u32MemoryBalloonSize;
|
---|
1556 | memBalloonChangeRequest->cPhysMemChunks = pThis->cbGuestRAM / (uint64_t)_1M;
|
---|
1557 |
|
---|
1558 | if (memBalloonChangeRequest->eventAck == VMMDEV_EVENT_BALLOON_CHANGE_REQUEST)
|
---|
1559 | {
|
---|
1560 | /* Remember which mode the client has queried. */
|
---|
1561 | pThis->u32LastMemoryBalloonSize = pThis->u32MemoryBalloonSize;
|
---|
1562 | }
|
---|
1563 |
|
---|
1564 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1565 | }
|
---|
1566 | break;
|
---|
1567 | }
|
---|
1568 |
|
---|
1569 | case VMMDevReq_ChangeMemBalloon:
|
---|
1570 | {
|
---|
1571 | VMMDevChangeMemBalloon *memBalloonChange = (VMMDevChangeMemBalloon*)pRequestHeader;
|
---|
1572 |
|
---|
1573 | Log(("VMMDevReq_ChangeMemBalloon\n"));
|
---|
1574 | if ( pRequestHeader->size < sizeof(VMMDevChangeMemBalloon)
|
---|
1575 | || memBalloonChange->cPages != VMMDEV_MEMORY_BALLOON_CHUNK_PAGES
|
---|
1576 | || pRequestHeader->size != (uint32_t)RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[memBalloonChange->cPages]))
|
---|
1577 | {
|
---|
1578 | AssertFailed();
|
---|
1579 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1580 | }
|
---|
1581 | else
|
---|
1582 | {
|
---|
1583 | pRequestHeader->rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(pDevIns), !!memBalloonChange->fInflate, memBalloonChange->cPages, memBalloonChange->aPhysPage);
|
---|
1584 | if (memBalloonChange->fInflate)
|
---|
1585 | STAM_REL_U32_INC(&pThis->StatMemBalloonChunks);
|
---|
1586 | else
|
---|
1587 | STAM_REL_U32_DEC(&pThis->StatMemBalloonChunks);
|
---|
1588 | }
|
---|
1589 | break;
|
---|
1590 | }
|
---|
1591 |
|
---|
1592 | case VMMDevReq_GetStatisticsChangeRequest:
|
---|
1593 | {
|
---|
1594 | Log(("VMMDevReq_GetStatisticsChangeRequest\n"));
|
---|
1595 | if (pRequestHeader->size != sizeof(VMMDevGetStatisticsChangeRequest))
|
---|
1596 | {
|
---|
1597 | AssertFailed();
|
---|
1598 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1599 | }
|
---|
1600 | else
|
---|
1601 | {
|
---|
1602 | VMMDevGetStatisticsChangeRequest *statIntervalChangeRequest = (VMMDevGetStatisticsChangeRequest*)pRequestHeader;
|
---|
1603 | /* just pass on the information */
|
---|
1604 | Log(("VMMDev: returning statistics interval %d seconds\n", pThis->u32StatIntervalSize));
|
---|
1605 | statIntervalChangeRequest->u32StatInterval = pThis->u32StatIntervalSize;
|
---|
1606 |
|
---|
1607 | if (statIntervalChangeRequest->eventAck == VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST)
|
---|
1608 | {
|
---|
1609 | /* Remember which mode the client has queried. */
|
---|
1610 | pThis->u32LastStatIntervalSize= pThis->u32StatIntervalSize;
|
---|
1611 | }
|
---|
1612 |
|
---|
1613 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1614 | }
|
---|
1615 | break;
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 | case VMMDevReq_ReportGuestStats:
|
---|
1619 | {
|
---|
1620 | Log(("VMMDevReq_ReportGuestStats\n"));
|
---|
1621 | if (pRequestHeader->size != sizeof(VMMDevReportGuestStats))
|
---|
1622 | {
|
---|
1623 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1624 | }
|
---|
1625 | else
|
---|
1626 | {
|
---|
1627 | VMMDevReportGuestStats *stats = (VMMDevReportGuestStats*)pRequestHeader;
|
---|
1628 |
|
---|
1629 | #ifdef DEBUG
|
---|
1630 | VBoxGuestStatistics *pGuestStats = &stats->guestStats;
|
---|
1631 |
|
---|
1632 | Log(("Current statistics:\n"));
|
---|
1633 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
1634 | Log(("CPU%d: CPU Load Idle %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_Idle));
|
---|
1635 |
|
---|
1636 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
1637 | Log(("CPU%d: CPU Load Kernel %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_Kernel));
|
---|
1638 |
|
---|
1639 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
1640 | Log(("CPU%d: CPU Load User %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_User));
|
---|
1641 |
|
---|
1642 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_THREADS)
|
---|
1643 | Log(("CPU%d: Thread %d\n", pGuestStats->u32CpuId, pGuestStats->u32Threads));
|
---|
1644 |
|
---|
1645 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PROCESSES)
|
---|
1646 | Log(("CPU%d: Processes %d\n", pGuestStats->u32CpuId, pGuestStats->u32Processes));
|
---|
1647 |
|
---|
1648 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_HANDLES)
|
---|
1649 | Log(("CPU%d: Handles %d\n", pGuestStats->u32CpuId, pGuestStats->u32Handles));
|
---|
1650 |
|
---|
1651 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEMORY_LOAD)
|
---|
1652 | Log(("CPU%d: Memory Load %d%%\n", pGuestStats->u32CpuId, pGuestStats->u32MemoryLoad));
|
---|
1653 |
|
---|
1654 | /* Note that reported values are in pages; upper layers expect them in megabytes */
|
---|
1655 | Log(("CPU%d: Page size %-4d bytes\n", pGuestStats->u32CpuId, pGuestStats->u32PageSize));
|
---|
1656 | Assert(pGuestStats->u32PageSize == 4096);
|
---|
1657 |
|
---|
1658 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
1659 | Log(("CPU%d: Total physical memory %-4d MB\n", pGuestStats->u32CpuId, (pGuestStats->u32PhysMemTotal + (_1M/_4K)-1) / (_1M/_4K)));
|
---|
1660 |
|
---|
1661 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
1662 | Log(("CPU%d: Free physical memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemAvail / (_1M/_4K)));
|
---|
1663 |
|
---|
1664 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
1665 | Log(("CPU%d: Memory balloon size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemBalloon / (_1M/_4K)));
|
---|
1666 |
|
---|
1667 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_COMMIT_TOTAL)
|
---|
1668 | Log(("CPU%d: Committed memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemCommitTotal / (_1M/_4K)));
|
---|
1669 |
|
---|
1670 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_TOTAL)
|
---|
1671 | Log(("CPU%d: Total kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelTotal / (_1M/_4K)));
|
---|
1672 |
|
---|
1673 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_PAGED)
|
---|
1674 | Log(("CPU%d: Paged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelPaged / (_1M/_4K)));
|
---|
1675 |
|
---|
1676 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED)
|
---|
1677 | Log(("CPU%d: Nonpaged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelNonPaged / (_1M/_4K)));
|
---|
1678 |
|
---|
1679 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
1680 | Log(("CPU%d: System cache size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemSystemCache / (_1M/_4K)));
|
---|
1681 |
|
---|
1682 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
1683 | Log(("CPU%d: Page file size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PageFileSize / (_1M/_4K)));
|
---|
1684 | Log(("Statistics end *******************\n"));
|
---|
1685 | #endif
|
---|
1686 |
|
---|
1687 | /* forward the call */
|
---|
1688 | pRequestHeader->rc = pThis->pDrv->pfnReportStatistics(pThis->pDrv, &stats->guestStats);
|
---|
1689 | }
|
---|
1690 | break;
|
---|
1691 | }
|
---|
1692 |
|
---|
1693 | case VMMDevReq_QueryCredentials:
|
---|
1694 | {
|
---|
1695 | if (pRequestHeader->size != sizeof(VMMDevCredentials))
|
---|
1696 | {
|
---|
1697 | AssertMsgFailed(("VMMDevReq_QueryCredentials request size too small.\n"));
|
---|
1698 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1699 | }
|
---|
1700 | else
|
---|
1701 | {
|
---|
1702 | VMMDevCredentials *credentials = (VMMDevCredentials*)pRequestHeader;
|
---|
1703 |
|
---|
1704 | /* let's start by nulling out the data */
|
---|
1705 | memset(credentials->szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1706 | memset(credentials->szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1707 | memset(credentials->szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1708 |
|
---|
1709 | /* should we return whether we got credentials for a logon? */
|
---|
1710 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_QUERYPRESENCE)
|
---|
1711 | {
|
---|
1712 | if ( pThis->pCredentials->Logon.szUserName[0]
|
---|
1713 | || pThis->pCredentials->Logon.szPassword[0]
|
---|
1714 | || pThis->pCredentials->Logon.szDomain[0])
|
---|
1715 | {
|
---|
1716 | credentials->u32Flags |= VMMDEV_CREDENTIALS_PRESENT;
|
---|
1717 | }
|
---|
1718 | else
|
---|
1719 | {
|
---|
1720 | credentials->u32Flags &= ~VMMDEV_CREDENTIALS_PRESENT;
|
---|
1721 | }
|
---|
1722 | }
|
---|
1723 |
|
---|
1724 | /* does the guest want to read logon credentials? */
|
---|
1725 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_READ)
|
---|
1726 | {
|
---|
1727 | if (pThis->pCredentials->Logon.szUserName[0])
|
---|
1728 | strcpy(credentials->szUserName, pThis->pCredentials->Logon.szUserName);
|
---|
1729 | if (pThis->pCredentials->Logon.szPassword[0])
|
---|
1730 | strcpy(credentials->szPassword, pThis->pCredentials->Logon.szPassword);
|
---|
1731 | if (pThis->pCredentials->Logon.szDomain[0])
|
---|
1732 | strcpy(credentials->szDomain, pThis->pCredentials->Logon.szDomain);
|
---|
1733 | if (!pThis->pCredentials->Logon.fAllowInteractiveLogon)
|
---|
1734 | credentials->u32Flags |= VMMDEV_CREDENTIALS_NOLOCALLOGON;
|
---|
1735 | else
|
---|
1736 | credentials->u32Flags &= ~VMMDEV_CREDENTIALS_NOLOCALLOGON;
|
---|
1737 | }
|
---|
1738 |
|
---|
1739 | if (!pThis->fKeepCredentials)
|
---|
1740 | {
|
---|
1741 | /* does the caller want us to destroy the logon credentials? */
|
---|
1742 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_CLEAR)
|
---|
1743 | {
|
---|
1744 | memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1745 | memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1746 | memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1747 | }
|
---|
1748 | }
|
---|
1749 |
|
---|
1750 | /* does the guest want to read credentials for verification? */
|
---|
1751 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_READJUDGE)
|
---|
1752 | {
|
---|
1753 | if (pThis->pCredentials->Judge.szUserName[0])
|
---|
1754 | strcpy(credentials->szUserName, pThis->pCredentials->Judge.szUserName);
|
---|
1755 | if (pThis->pCredentials->Judge.szPassword[0])
|
---|
1756 | strcpy(credentials->szPassword, pThis->pCredentials->Judge.szPassword);
|
---|
1757 | if (pThis->pCredentials->Judge.szDomain[0])
|
---|
1758 | strcpy(credentials->szDomain, pThis->pCredentials->Judge.szDomain);
|
---|
1759 | }
|
---|
1760 |
|
---|
1761 | /* does the caller want us to destroy the judgement credentials? */
|
---|
1762 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_CLEARJUDGE)
|
---|
1763 | {
|
---|
1764 | memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1765 | memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1766 | memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
1767 | }
|
---|
1768 |
|
---|
1769 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1770 | }
|
---|
1771 | break;
|
---|
1772 | }
|
---|
1773 |
|
---|
1774 | case VMMDevReq_ReportCredentialsJudgement:
|
---|
1775 | {
|
---|
1776 | if (pRequestHeader->size != sizeof(VMMDevCredentials))
|
---|
1777 | {
|
---|
1778 | AssertMsgFailed(("VMMDevReq_ReportCredentialsJudgement request size too small.\n"));
|
---|
1779 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1780 | }
|
---|
1781 | else
|
---|
1782 | {
|
---|
1783 | VMMDevCredentials *credentials = (VMMDevCredentials*)pRequestHeader;
|
---|
1784 |
|
---|
1785 | /* what does the guest think about the credentials? (note: the order is important here!) */
|
---|
1786 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_JUDGE_DENY)
|
---|
1787 | {
|
---|
1788 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_DENY);
|
---|
1789 | }
|
---|
1790 | else if (credentials->u32Flags & VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT)
|
---|
1791 | {
|
---|
1792 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT);
|
---|
1793 | }
|
---|
1794 | else if (credentials->u32Flags & VMMDEV_CREDENTIALS_JUDGE_OK)
|
---|
1795 | {
|
---|
1796 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_OK);
|
---|
1797 | }
|
---|
1798 | else
|
---|
1799 | Log(("VMMDevReq_ReportCredentialsJudgement: invalid flags: %d!!!\n", credentials->u32Flags));
|
---|
1800 |
|
---|
1801 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1802 | }
|
---|
1803 | break;
|
---|
1804 | }
|
---|
1805 |
|
---|
1806 | /*
|
---|
1807 | * Implemented in 3.1.0.
|
---|
1808 | *
|
---|
1809 | * Note! The ring-0 VBoxGuestLib uses this to check whether
|
---|
1810 | * VMMDevHGCMParmType_PageList is supported.
|
---|
1811 | */
|
---|
1812 | case VMMDevReq_GetHostVersion:
|
---|
1813 | {
|
---|
1814 | AssertMsgBreakStmt(pRequestHeader->size == sizeof(VMMDevReqHostVersion),
|
---|
1815 | ("%#x < %#x\n", pRequestHeader->size, sizeof(VMMDevReqLogString)),
|
---|
1816 | pRequestHeader->rc = VERR_INVALID_PARAMETER);
|
---|
1817 | VMMDevReqHostVersion *pReqHostVer = (VMMDevReqHostVersion*)pRequestHeader;
|
---|
1818 | pReqHostVer->major = RTBldCfgVersionMajor();
|
---|
1819 | pReqHostVer->minor = RTBldCfgVersionMinor();
|
---|
1820 | pReqHostVer->build = RTBldCfgVersionBuild();
|
---|
1821 | pReqHostVer->revision = RTBldCfgRevision();
|
---|
1822 | pReqHostVer->features = VMMDEV_HVF_HGCM_PHYS_PAGE_LIST;
|
---|
1823 | pReqHostVer->header.rc = VINF_SUCCESS;
|
---|
1824 | break;
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 | case VMMDevReq_GetCpuHotPlugRequest:
|
---|
1828 | {
|
---|
1829 | VMMDevGetCpuHotPlugRequest *pReqCpuHotPlug = (VMMDevGetCpuHotPlugRequest *)pRequestHeader;
|
---|
1830 |
|
---|
1831 | if (pRequestHeader->size != sizeof(VMMDevGetCpuHotPlugRequest))
|
---|
1832 | {
|
---|
1833 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1834 | }
|
---|
1835 | else
|
---|
1836 | {
|
---|
1837 | pReqCpuHotPlug->enmEventType = pThis->enmCpuHotPlugEvent;
|
---|
1838 | pReqCpuHotPlug->idCpuCore = pThis->idCpuCore;
|
---|
1839 | pReqCpuHotPlug->idCpuPackage = pThis->idCpuPackage;
|
---|
1840 | pReqCpuHotPlug->header.rc = VINF_SUCCESS;
|
---|
1841 |
|
---|
1842 | /* Clear the event */
|
---|
1843 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_None;
|
---|
1844 | pThis->idCpuCore = UINT32_MAX;
|
---|
1845 | pThis->idCpuPackage = UINT32_MAX;
|
---|
1846 | }
|
---|
1847 | break;
|
---|
1848 | }
|
---|
1849 |
|
---|
1850 | case VMMDevReq_SetCpuHotPlugStatus:
|
---|
1851 | {
|
---|
1852 | VMMDevCpuHotPlugStatusRequest *pReqCpuHotPlugStatus = (VMMDevCpuHotPlugStatusRequest *)pRequestHeader;
|
---|
1853 |
|
---|
1854 | if (pRequestHeader->size != sizeof(VMMDevCpuHotPlugStatusRequest))
|
---|
1855 | {
|
---|
1856 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1857 | }
|
---|
1858 | else
|
---|
1859 | {
|
---|
1860 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1861 |
|
---|
1862 | if (pReqCpuHotPlugStatus->enmStatusType == VMMDevCpuStatusType_Disable)
|
---|
1863 | pThis->fCpuHotPlugEventsEnabled = false;
|
---|
1864 | else if (pReqCpuHotPlugStatus->enmStatusType == VMMDevCpuStatusType_Enable)
|
---|
1865 | pThis->fCpuHotPlugEventsEnabled = true;
|
---|
1866 | else
|
---|
1867 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1868 | }
|
---|
1869 | break;
|
---|
1870 | }
|
---|
1871 |
|
---|
1872 | #ifdef VBOX_WITH_PAGE_SHARING
|
---|
1873 | case VMMDevReq_RegisterSharedModule:
|
---|
1874 | {
|
---|
1875 | VMMDevSharedModuleRegistrationRequest *pReqModule = (VMMDevSharedModuleRegistrationRequest *)pRequestHeader;
|
---|
1876 |
|
---|
1877 | if ( pRequestHeader->size < sizeof(VMMDevSharedModuleRegistrationRequest)
|
---|
1878 | || pRequestHeader->size != RT_UOFFSETOF(VMMDevSharedModuleRegistrationRequest, aRegions[pReqModule->cRegions]))
|
---|
1879 | {
|
---|
1880 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1881 | }
|
---|
1882 | else
|
---|
1883 | {
|
---|
1884 | pRequestHeader->rc = PGMR3SharedModuleRegister(PDMDevHlpGetVM(pDevIns), pReqModule->enmGuestOS, pReqModule->szName, pReqModule->szVersion,
|
---|
1885 | pReqModule->GCBaseAddr, pReqModule->cbModule,
|
---|
1886 | pReqModule->cRegions, pReqModule->aRegions);
|
---|
1887 | }
|
---|
1888 | break;
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | case VMMDevReq_UnregisterSharedModule:
|
---|
1892 | {
|
---|
1893 | VMMDevSharedModuleUnregistrationRequest *pReqModule = (VMMDevSharedModuleUnregistrationRequest *)pRequestHeader;
|
---|
1894 |
|
---|
1895 | if (pRequestHeader->size != sizeof(VMMDevSharedModuleUnregistrationRequest))
|
---|
1896 | {
|
---|
1897 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1898 | }
|
---|
1899 | else
|
---|
1900 | {
|
---|
1901 | pRequestHeader->rc = PGMR3SharedModuleUnregister(PDMDevHlpGetVM(pDevIns), pReqModule->szName, pReqModule->szVersion,
|
---|
1902 | pReqModule->GCBaseAddr, pReqModule->cbModule);
|
---|
1903 | }
|
---|
1904 | break;
|
---|
1905 | }
|
---|
1906 |
|
---|
1907 | case VMMDevReq_CheckSharedModules:
|
---|
1908 | {
|
---|
1909 | VMMDevSharedModuleCheckRequest *pReqModule = (VMMDevSharedModuleCheckRequest *)pRequestHeader;
|
---|
1910 |
|
---|
1911 | if (pRequestHeader->size != sizeof(VMMDevSharedModuleCheckRequest))
|
---|
1912 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1913 | else
|
---|
1914 | pRequestHeader->rc = PGMR3SharedModuleCheckAll(PDMDevHlpGetVM(pDevIns));
|
---|
1915 | break;
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 | case VMMDevReq_GetPageSharingStatus:
|
---|
1919 | {
|
---|
1920 | VMMDevPageSharingStatusRequest *pReqStatus = (VMMDevPageSharingStatusRequest *)pRequestHeader;
|
---|
1921 |
|
---|
1922 | if (pRequestHeader->size != sizeof(VMMDevPageSharingStatusRequest))
|
---|
1923 | {
|
---|
1924 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1925 | }
|
---|
1926 | else
|
---|
1927 | {
|
---|
1928 | pReqStatus->fEnabled = false;
|
---|
1929 | pThis->pDrv->pfnIsPageFusionEnabled(pThis->pDrv, &pReqStatus->fEnabled);
|
---|
1930 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1931 | }
|
---|
1932 | break;
|
---|
1933 | }
|
---|
1934 |
|
---|
1935 | case VMMDevReq_DebugIsPageShared:
|
---|
1936 | {
|
---|
1937 | # ifdef DEBUG
|
---|
1938 | VMMDevPageIsSharedRequest *pReq = (VMMDevPageIsSharedRequest *)pRequestHeader;
|
---|
1939 |
|
---|
1940 | if (pRequestHeader->size != sizeof(VMMDevPageIsSharedRequest))
|
---|
1941 | {
|
---|
1942 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1943 | }
|
---|
1944 | else
|
---|
1945 | {
|
---|
1946 | pRequestHeader->rc = PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(pDevIns), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags);
|
---|
1947 | }
|
---|
1948 | # else
|
---|
1949 | pRequestHeader->rc = VERR_NOT_IMPLEMENTED;
|
---|
1950 | # endif
|
---|
1951 | break;
|
---|
1952 | }
|
---|
1953 |
|
---|
1954 | #endif
|
---|
1955 |
|
---|
1956 | #ifdef DEBUG
|
---|
1957 | case VMMDevReq_LogString:
|
---|
1958 | {
|
---|
1959 | if (pRequestHeader->size < sizeof(VMMDevReqLogString))
|
---|
1960 | {
|
---|
1961 | AssertMsgFailed(("VMMDevReq_LogString request size too small.\n"));
|
---|
1962 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1963 | }
|
---|
1964 | else
|
---|
1965 | {
|
---|
1966 | VMMDevReqLogString *pReqLogString = (VMMDevReqLogString *)pRequestHeader;
|
---|
1967 | LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR,
|
---|
1968 | ("DEBUG LOG: %s", pReqLogString->szString));
|
---|
1969 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1970 | }
|
---|
1971 | break;
|
---|
1972 | }
|
---|
1973 | #endif
|
---|
1974 |
|
---|
1975 | /*
|
---|
1976 | * Get a unique session id for this VM; the id will be different after each start, reset or restore of the VM
|
---|
1977 | * This can be used for restore detection inside the guest.
|
---|
1978 | */
|
---|
1979 | case VMMDevReq_GetSessionId:
|
---|
1980 | {
|
---|
1981 | if (pRequestHeader->size != sizeof(VMMDevReqSessionId))
|
---|
1982 | {
|
---|
1983 | AssertMsgFailed(("VMMDevReq_GetSessionId request size too small.\n"));
|
---|
1984 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1985 | }
|
---|
1986 | else
|
---|
1987 | {
|
---|
1988 | VMMDevReqSessionId *pReq = (VMMDevReqSessionId *)pRequestHeader;
|
---|
1989 | pReq->idSession = pThis->idSession;
|
---|
1990 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1991 | }
|
---|
1992 | break;
|
---|
1993 | }
|
---|
1994 |
|
---|
1995 | default:
|
---|
1996 | {
|
---|
1997 | pRequestHeader->rc = VERR_NOT_IMPLEMENTED;
|
---|
1998 | Log(("VMMDev unknown request type %d\n", pRequestHeader->requestType));
|
---|
1999 | break;
|
---|
2000 | }
|
---|
2001 | }
|
---|
2002 |
|
---|
2003 | l_end:
|
---|
2004 | /* Write the result back to guest memory */
|
---|
2005 | if (pRequestHeader)
|
---|
2006 | {
|
---|
2007 | PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)u32, pRequestHeader, pRequestHeader->size);
|
---|
2008 | RTMemFree(pRequestHeader);
|
---|
2009 | }
|
---|
2010 | else
|
---|
2011 | {
|
---|
2012 | /* early error case; write back header only */
|
---|
2013 | PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader));
|
---|
2014 | }
|
---|
2015 |
|
---|
2016 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2017 | return rcRet;
|
---|
2018 | }
|
---|
2019 |
|
---|
2020 | /**
|
---|
2021 | * Callback function for mapping an PCI I/O region.
|
---|
2022 | *
|
---|
2023 | * @return VBox status code.
|
---|
2024 | * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
|
---|
2025 | * @param iRegion The region number.
|
---|
2026 | * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
|
---|
2027 | * I/O port, else it's a physical address.
|
---|
2028 | * This address is *NOT* relative to pci_mem_base like earlier!
|
---|
2029 | * @param enmType One of the PCI_ADDRESS_SPACE_* values.
|
---|
2030 | */
|
---|
2031 | static DECLCALLBACK(int) vmmdevIORAMRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
|
---|
2032 | {
|
---|
2033 | LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
|
---|
2034 | VMMDevState *pThis = PCIDEV_2_VMMDEVSTATE(pPciDev);
|
---|
2035 | int rc;
|
---|
2036 |
|
---|
2037 | if (iRegion == 1)
|
---|
2038 | {
|
---|
2039 | AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM, VERR_INTERNAL_ERROR);
|
---|
2040 | Assert(pThis->pVMMDevRAMR3 != NULL);
|
---|
2041 | if (GCPhysAddress != NIL_RTGCPHYS)
|
---|
2042 | {
|
---|
2043 | /*
|
---|
2044 | * Map the MMIO2 memory.
|
---|
2045 | */
|
---|
2046 | pThis->GCPhysVMMDevRAM = GCPhysAddress;
|
---|
2047 | Assert(pThis->GCPhysVMMDevRAM == GCPhysAddress);
|
---|
2048 | rc = PDMDevHlpMMIO2Map(pPciDev->pDevIns, iRegion, GCPhysAddress);
|
---|
2049 | }
|
---|
2050 | else
|
---|
2051 | {
|
---|
2052 | /*
|
---|
2053 | * It is about to be unmapped, just clean up.
|
---|
2054 | */
|
---|
2055 | pThis->GCPhysVMMDevRAM = NIL_RTGCPHYS32;
|
---|
2056 | rc = VINF_SUCCESS;
|
---|
2057 | }
|
---|
2058 | }
|
---|
2059 | else if (iRegion == 2)
|
---|
2060 | {
|
---|
2061 | AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR);
|
---|
2062 | Assert(pThis->pVMMDevHeapR3 != NULL);
|
---|
2063 | if (GCPhysAddress != NIL_RTGCPHYS)
|
---|
2064 | {
|
---|
2065 | /*
|
---|
2066 | * Map the MMIO2 memory.
|
---|
2067 | */
|
---|
2068 | pThis->GCPhysVMMDevHeap = GCPhysAddress;
|
---|
2069 | Assert(pThis->GCPhysVMMDevHeap == GCPhysAddress);
|
---|
2070 | rc = PDMDevHlpMMIO2Map(pPciDev->pDevIns, iRegion, GCPhysAddress);
|
---|
2071 | if (RT_SUCCESS(rc))
|
---|
2072 | rc = PDMDevHlpRegisterVMMDevHeap(pPciDev->pDevIns, GCPhysAddress, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
|
---|
2073 | }
|
---|
2074 | else
|
---|
2075 | {
|
---|
2076 | /*
|
---|
2077 | * It is about to be unmapped, just clean up.
|
---|
2078 | */
|
---|
2079 | PDMDevHlpUnregisterVMMDevHeap(pPciDev->pDevIns, pThis->GCPhysVMMDevHeap);
|
---|
2080 | pThis->GCPhysVMMDevHeap = NIL_RTGCPHYS32;
|
---|
2081 | rc = VINF_SUCCESS;
|
---|
2082 | }
|
---|
2083 | }
|
---|
2084 | else
|
---|
2085 | {
|
---|
2086 | AssertMsgFailed(("%d\n", iRegion));
|
---|
2087 | rc = VERR_INVALID_PARAMETER;
|
---|
2088 | }
|
---|
2089 |
|
---|
2090 | return rc;
|
---|
2091 | }
|
---|
2092 |
|
---|
2093 |
|
---|
2094 | /**
|
---|
2095 | * Callback function for mapping a PCI I/O region.
|
---|
2096 | *
|
---|
2097 | * @return VBox status code.
|
---|
2098 | * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
|
---|
2099 | * @param iRegion The region number.
|
---|
2100 | * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
|
---|
2101 | * I/O port, else it's a physical address.
|
---|
2102 | * This address is *NOT* relative to pci_mem_base like earlier!
|
---|
2103 | * @param enmType One of the PCI_ADDRESS_SPACE_* values.
|
---|
2104 | */
|
---|
2105 | static DECLCALLBACK(int) vmmdevIOPortRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
|
---|
2106 | {
|
---|
2107 | VMMDevState *pThis = PCIDEV_2_VMMDEVSTATE(pPciDev);
|
---|
2108 | int rc = VINF_SUCCESS;
|
---|
2109 |
|
---|
2110 | Assert(enmType == PCI_ADDRESS_SPACE_IO);
|
---|
2111 | Assert(iRegion == 0);
|
---|
2112 | AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress));
|
---|
2113 |
|
---|
2114 | /*
|
---|
2115 | * Save the base port address to simplify Port offset calculations.
|
---|
2116 | */
|
---|
2117 | pThis->PortBase = (RTIOPORT)GCPhysAddress;
|
---|
2118 |
|
---|
2119 | /*
|
---|
2120 | * Register our port IO handlers.
|
---|
2121 | */
|
---|
2122 | rc = PDMDevHlpIOPortRegister(pPciDev->pDevIns,
|
---|
2123 | (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1,
|
---|
2124 | (void*)pThis, vmmdevRequestHandler,
|
---|
2125 | NULL, NULL, NULL, "VMMDev Request Handler");
|
---|
2126 | AssertRC(rc);
|
---|
2127 | return rc;
|
---|
2128 | }
|
---|
2129 |
|
---|
2130 | /**
|
---|
2131 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
2132 | */
|
---|
2133 | static DECLCALLBACK(void *) vmmdevPortQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
2134 | {
|
---|
2135 | VMMDevState *pThis = RT_FROM_MEMBER(pInterface, VMMDevState, IBase);
|
---|
2136 |
|
---|
2137 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
|
---|
2138 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVPORT, &pThis->IPort);
|
---|
2139 | #ifdef VBOX_WITH_HGCM
|
---|
2140 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMPORT, &pThis->IHGCMPort);
|
---|
2141 | #endif
|
---|
2142 | /* Currently only for shared folders. */
|
---|
2143 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->SharedFolders.ILeds);
|
---|
2144 | return NULL;
|
---|
2145 | }
|
---|
2146 |
|
---|
2147 | /**
|
---|
2148 | * Gets the pointer to the status LED of a unit.
|
---|
2149 | *
|
---|
2150 | * @returns VBox status code.
|
---|
2151 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
2152 | * @param iLUN The unit which status LED we desire.
|
---|
2153 | * @param ppLed Where to store the LED pointer.
|
---|
2154 | */
|
---|
2155 | static DECLCALLBACK(int) vmmdevQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
|
---|
2156 | {
|
---|
2157 | VMMDevState *pThis = (VMMDevState *)( (uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, SharedFolders.ILeds) );
|
---|
2158 | if (iLUN == 0) /* LUN 0 is shared folders */
|
---|
2159 | {
|
---|
2160 | *ppLed = &pThis->SharedFolders.Led;
|
---|
2161 | return VINF_SUCCESS;
|
---|
2162 | }
|
---|
2163 | return VERR_PDM_LUN_NOT_FOUND;
|
---|
2164 | }
|
---|
2165 |
|
---|
2166 | /* -=-=-=-=-=- IVMMDevPort -=-=-=-=-=- */
|
---|
2167 |
|
---|
2168 | /** Converts a VMMDev port interface pointer to a VMMDev state pointer. */
|
---|
2169 | #define IVMMDEVPORT_2_VMMDEVSTATE(pInterface) ( (VMMDevState*)((uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, IPort)) )
|
---|
2170 |
|
---|
2171 |
|
---|
2172 | /**
|
---|
2173 | * Return the current absolute mouse position in pixels
|
---|
2174 | *
|
---|
2175 | * @returns VBox status code
|
---|
2176 | * @param pAbsX Pointer of result value, can be NULL
|
---|
2177 | * @param pAbsY Pointer of result value, can be NULL
|
---|
2178 | */
|
---|
2179 | static DECLCALLBACK(int) vmmdevQueryAbsoluteMouse(PPDMIVMMDEVPORT pInterface, uint32_t *pAbsX, uint32_t *pAbsY)
|
---|
2180 | {
|
---|
2181 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2182 | AssertCompile(sizeof(pThis->mouseXAbs) == sizeof(*pAbsX));
|
---|
2183 | AssertCompile(sizeof(pThis->mouseYAbs) == sizeof(*pAbsY));
|
---|
2184 | if (pAbsX)
|
---|
2185 | ASMAtomicReadSize(&pThis->mouseXAbs, pAbsX);
|
---|
2186 | if (pAbsY)
|
---|
2187 | ASMAtomicReadSize(&pThis->mouseYAbs, pAbsY);
|
---|
2188 | return VINF_SUCCESS;
|
---|
2189 | }
|
---|
2190 |
|
---|
2191 | /**
|
---|
2192 | * Set the new absolute mouse position in pixels
|
---|
2193 | *
|
---|
2194 | * @returns VBox status code
|
---|
2195 | * @param absX New absolute X position
|
---|
2196 | * @param absY New absolute Y position
|
---|
2197 | */
|
---|
2198 | static DECLCALLBACK(int) vmmdevSetAbsoluteMouse(PPDMIVMMDEVPORT pInterface, uint32_t absX, uint32_t absY)
|
---|
2199 | {
|
---|
2200 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2201 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2202 |
|
---|
2203 | if ((pThis->mouseXAbs == absX) && (pThis->mouseYAbs == absY))
|
---|
2204 | {
|
---|
2205 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2206 | return VINF_SUCCESS;
|
---|
2207 | }
|
---|
2208 | Log2(("vmmdevSetAbsoluteMouse: settings absolute position to x = %d, y = %d\n", absX, absY));
|
---|
2209 | pThis->mouseXAbs = absX;
|
---|
2210 | pThis->mouseYAbs = absY;
|
---|
2211 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
|
---|
2212 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2213 | return VINF_SUCCESS;
|
---|
2214 | }
|
---|
2215 |
|
---|
2216 | /**
|
---|
2217 | * Return the current mouse capability flags
|
---|
2218 | *
|
---|
2219 | * @returns VBox status code
|
---|
2220 | * @param pCapabilities Pointer of result value
|
---|
2221 | */
|
---|
2222 | static DECLCALLBACK(int) vmmdevQueryMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t *pfCaps)
|
---|
2223 | {
|
---|
2224 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2225 | if (!pfCaps)
|
---|
2226 | return VERR_INVALID_PARAMETER;
|
---|
2227 | *pfCaps = pThis->mouseCapabilities;
|
---|
2228 | return VINF_SUCCESS;
|
---|
2229 | }
|
---|
2230 |
|
---|
2231 | /**
|
---|
2232 | * Set the current mouse capability flag (host side)
|
---|
2233 | *
|
---|
2234 | * @returns VBox status code
|
---|
2235 | * @param capabilities Capability mask
|
---|
2236 | */
|
---|
2237 | static DECLCALLBACK(int) vmmdevSetMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCaps)
|
---|
2238 | {
|
---|
2239 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2240 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2241 |
|
---|
2242 | bool fNotify = ( (fCaps & VMMDEV_MOUSE_NOTIFY_GUEST_MASK)
|
---|
2243 | != (pThis->mouseCapabilities & VMMDEV_MOUSE_NOTIFY_GUEST_MASK));
|
---|
2244 |
|
---|
2245 | LogRelFlowFunc(("fCaps=0x%x, fNotify %s\n", fCaps,
|
---|
2246 | fNotify ? "TRUE" : "FALSE"));
|
---|
2247 |
|
---|
2248 | pThis->mouseCapabilities &= ~VMMDEV_MOUSE_HOST_MASK
|
---|
2249 | | VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
|
---|
2250 | pThis->mouseCapabilities |= (fCaps & VMMDEV_MOUSE_HOST_MASK);
|
---|
2251 | if (fNotify)
|
---|
2252 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);
|
---|
2253 |
|
---|
2254 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2255 | return VINF_SUCCESS;
|
---|
2256 | }
|
---|
2257 |
|
---|
2258 |
|
---|
2259 | static DECLCALLBACK(int) vmmdevRequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t xres, uint32_t yres, uint32_t bpp, uint32_t display)
|
---|
2260 | {
|
---|
2261 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2262 |
|
---|
2263 | if (display >= RT_ELEMENTS(pThis->displayChangeData.aRequests))
|
---|
2264 | {
|
---|
2265 | return VERR_INVALID_PARAMETER;
|
---|
2266 | }
|
---|
2267 |
|
---|
2268 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2269 |
|
---|
2270 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[display];
|
---|
2271 |
|
---|
2272 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2273 | bool fSameResolution = (!xres || (pRequest->lastReadDisplayChangeRequest.xres == xres)) &&
|
---|
2274 | (!yres || (pRequest->lastReadDisplayChangeRequest.yres == yres)) &&
|
---|
2275 | (!bpp || (pRequest->lastReadDisplayChangeRequest.bpp == bpp)) &&
|
---|
2276 | pRequest->lastReadDisplayChangeRequest.display == display;
|
---|
2277 |
|
---|
2278 | if (!xres && !yres && !bpp)
|
---|
2279 | {
|
---|
2280 | /* Special case of reset video mode. */
|
---|
2281 | fSameResolution = false;
|
---|
2282 | }
|
---|
2283 |
|
---|
2284 | Log3(("vmmdevRequestDisplayChange: same=%d. new: xres=%d, yres=%d, bpp=%d, display=%d. old: xres=%d, yres=%d, bpp=%d, display=%d.\n",
|
---|
2285 | fSameResolution, xres, yres, bpp, display, pRequest->lastReadDisplayChangeRequest.xres, pRequest->lastReadDisplayChangeRequest.yres, pRequest->lastReadDisplayChangeRequest.bpp, pRequest->lastReadDisplayChangeRequest.display));
|
---|
2286 |
|
---|
2287 | if (!fSameResolution)
|
---|
2288 | {
|
---|
2289 | LogRel(("VMMDev::SetVideoModeHint: got a video mode hint (%dx%dx%d) at %d\n",
|
---|
2290 | xres, yres, bpp, display));
|
---|
2291 |
|
---|
2292 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2293 | pRequest->displayChangeRequest.xres = xres;
|
---|
2294 | pRequest->displayChangeRequest.yres = yres;
|
---|
2295 | pRequest->displayChangeRequest.bpp = bpp;
|
---|
2296 | pRequest->displayChangeRequest.display = display;
|
---|
2297 | pRequest->fPending = true;
|
---|
2298 |
|
---|
2299 | /* IRQ so the guest knows what's going on */
|
---|
2300 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
2301 | }
|
---|
2302 |
|
---|
2303 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2304 | return VINF_SUCCESS;
|
---|
2305 | }
|
---|
2306 |
|
---|
2307 | static DECLCALLBACK(int) vmmdevRequestSeamlessChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
|
---|
2308 | {
|
---|
2309 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2310 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2311 |
|
---|
2312 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2313 | bool fSameMode = (pThis->fLastSeamlessEnabled == fEnabled);
|
---|
2314 |
|
---|
2315 | Log(("vmmdevRequestSeamlessChange: same=%d. new=%d\n", fSameMode, fEnabled));
|
---|
2316 |
|
---|
2317 | if (!fSameMode)
|
---|
2318 | {
|
---|
2319 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2320 | pThis->fSeamlessEnabled = fEnabled;
|
---|
2321 |
|
---|
2322 | /* IRQ so the guest knows what's going on */
|
---|
2323 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST);
|
---|
2324 | }
|
---|
2325 |
|
---|
2326 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2327 | return VINF_SUCCESS;
|
---|
2328 | }
|
---|
2329 |
|
---|
2330 | static DECLCALLBACK(int) vmmdevSetMemoryBalloon(PPDMIVMMDEVPORT pInterface, uint32_t ulBalloonSize)
|
---|
2331 | {
|
---|
2332 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2333 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2334 |
|
---|
2335 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2336 | bool fSame = (pThis->u32LastMemoryBalloonSize == ulBalloonSize);
|
---|
2337 |
|
---|
2338 | Log(("vmmdevSetMemoryBalloon: old=%d. new=%d\n", pThis->u32LastMemoryBalloonSize, ulBalloonSize));
|
---|
2339 |
|
---|
2340 | if (!fSame)
|
---|
2341 | {
|
---|
2342 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2343 | pThis->u32MemoryBalloonSize = ulBalloonSize;
|
---|
2344 |
|
---|
2345 | /* IRQ so the guest knows what's going on */
|
---|
2346 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST);
|
---|
2347 | }
|
---|
2348 |
|
---|
2349 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2350 | return VINF_SUCCESS;
|
---|
2351 | }
|
---|
2352 |
|
---|
2353 | static DECLCALLBACK(int) vmmdevVRDPChange(PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t u32VRDPExperienceLevel)
|
---|
2354 | {
|
---|
2355 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2356 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2357 |
|
---|
2358 | bool fSame = (pThis->fVRDPEnabled == fVRDPEnabled);
|
---|
2359 |
|
---|
2360 | Log(("vmmdevVRDPChange: old=%d. new=%d\n", pThis->fVRDPEnabled, fVRDPEnabled));
|
---|
2361 |
|
---|
2362 | if (!fSame)
|
---|
2363 | {
|
---|
2364 | pThis->fVRDPEnabled = fVRDPEnabled;
|
---|
2365 | pThis->u32VRDPExperienceLevel = u32VRDPExperienceLevel;
|
---|
2366 |
|
---|
2367 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_VRDP);
|
---|
2368 | }
|
---|
2369 |
|
---|
2370 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2371 | return VINF_SUCCESS;
|
---|
2372 | }
|
---|
2373 |
|
---|
2374 | static DECLCALLBACK(int) vmmdevSetStatisticsInterval(PPDMIVMMDEVPORT pInterface, uint32_t ulStatInterval)
|
---|
2375 | {
|
---|
2376 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2377 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2378 |
|
---|
2379 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2380 | bool fSame = (pThis->u32LastStatIntervalSize == ulStatInterval);
|
---|
2381 |
|
---|
2382 | Log(("vmmdevSetStatisticsInterval: old=%d. new=%d\n", pThis->u32LastStatIntervalSize, ulStatInterval));
|
---|
2383 |
|
---|
2384 | if (!fSame)
|
---|
2385 | {
|
---|
2386 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2387 | pThis->u32StatIntervalSize = ulStatInterval;
|
---|
2388 |
|
---|
2389 | /* IRQ so the guest knows what's going on */
|
---|
2390 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST);
|
---|
2391 | }
|
---|
2392 |
|
---|
2393 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2394 | return VINF_SUCCESS;
|
---|
2395 | }
|
---|
2396 |
|
---|
2397 |
|
---|
2398 | static DECLCALLBACK(int) vmmdevSetCredentials(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
|
---|
2399 | const char *pszPassword, const char *pszDomain,
|
---|
2400 | uint32_t u32Flags)
|
---|
2401 | {
|
---|
2402 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2403 | int rc = VINF_SUCCESS;
|
---|
2404 |
|
---|
2405 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2406 |
|
---|
2407 | /* logon mode? */
|
---|
2408 | if (u32Flags & VMMDEV_SETCREDENTIALS_GUESTLOGON)
|
---|
2409 | {
|
---|
2410 | /* memorize the data */
|
---|
2411 | strcpy(pThis->pCredentials->Logon.szUserName, pszUsername);
|
---|
2412 | strcpy(pThis->pCredentials->Logon.szPassword, pszPassword);
|
---|
2413 | strcpy(pThis->pCredentials->Logon.szDomain, pszDomain);
|
---|
2414 | pThis->pCredentials->Logon.fAllowInteractiveLogon = !(u32Flags & VMMDEV_SETCREDENTIALS_NOLOCALLOGON);
|
---|
2415 | }
|
---|
2416 | /* credentials verification mode? */
|
---|
2417 | else if (u32Flags & VMMDEV_SETCREDENTIALS_JUDGE)
|
---|
2418 | {
|
---|
2419 | /* memorize the data */
|
---|
2420 | strcpy(pThis->pCredentials->Judge.szUserName, pszUsername);
|
---|
2421 | strcpy(pThis->pCredentials->Judge.szPassword, pszPassword);
|
---|
2422 | strcpy(pThis->pCredentials->Judge.szDomain, pszDomain);
|
---|
2423 |
|
---|
2424 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_JUDGE_CREDENTIALS);
|
---|
2425 | }
|
---|
2426 | else
|
---|
2427 | rc = VERR_INVALID_PARAMETER;
|
---|
2428 |
|
---|
2429 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2430 | return rc;
|
---|
2431 | }
|
---|
2432 |
|
---|
2433 | /**
|
---|
2434 | * Notification from the Display. Especially useful when
|
---|
2435 | * acceleration is disabled after a video mode change.
|
---|
2436 | *
|
---|
2437 | * @param fEnable Current acceleration status.
|
---|
2438 | */
|
---|
2439 | static DECLCALLBACK(void) vmmdevVBVAChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
|
---|
2440 | {
|
---|
2441 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2442 |
|
---|
2443 | Log(("vmmdevVBVAChange: fEnabled = %d\n", fEnabled));
|
---|
2444 |
|
---|
2445 | if (pThis)
|
---|
2446 | {
|
---|
2447 | pThis->u32VideoAccelEnabled = fEnabled;
|
---|
2448 | }
|
---|
2449 | return;
|
---|
2450 | }
|
---|
2451 |
|
---|
2452 | /**
|
---|
2453 | * Notification that a CPU is about to be unplugged from the VM.
|
---|
2454 | * The guest has to eject the CPU.
|
---|
2455 | *
|
---|
2456 | * @returns VBox status code.
|
---|
2457 | * @param idCpu The id of the CPU.
|
---|
2458 | * @param idCpuCore The core id of the CPU to remove.
|
---|
2459 | * @param idCpuPackage The package id of the CPU to remove.
|
---|
2460 | */
|
---|
2461 | static DECLCALLBACK(int) vmmdevCpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
|
---|
2462 | {
|
---|
2463 | int rc = VINF_SUCCESS;
|
---|
2464 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2465 |
|
---|
2466 | Log(("vmmdevCpuHotUnplug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
|
---|
2467 |
|
---|
2468 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2469 |
|
---|
2470 | if (pThis->fCpuHotPlugEventsEnabled)
|
---|
2471 | {
|
---|
2472 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Unplug;
|
---|
2473 | pThis->idCpuCore = idCpuCore;
|
---|
2474 | pThis->idCpuPackage = idCpuPackage;
|
---|
2475 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_CPU_HOTPLUG);
|
---|
2476 | }
|
---|
2477 | else
|
---|
2478 | rc = VERR_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
|
---|
2479 |
|
---|
2480 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2481 | return rc;
|
---|
2482 | }
|
---|
2483 |
|
---|
2484 | /**
|
---|
2485 | * Notification that a CPU was attached to the VM
|
---|
2486 | * The guest may use it now.
|
---|
2487 | *
|
---|
2488 | * @returns VBox status code.
|
---|
2489 | * @param idCpuCore The core id of the CPU to add.
|
---|
2490 | * @param idCpuPackage The package id of the CPU to add.
|
---|
2491 | */
|
---|
2492 | static DECLCALLBACK(int) vmmdevCpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
|
---|
2493 | {
|
---|
2494 | int rc = VINF_SUCCESS;
|
---|
2495 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2496 |
|
---|
2497 | Log(("vmmdevCpuPlug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
|
---|
2498 |
|
---|
2499 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2500 |
|
---|
2501 | if (pThis->fCpuHotPlugEventsEnabled)
|
---|
2502 | {
|
---|
2503 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Plug;
|
---|
2504 | pThis->idCpuCore = idCpuCore;
|
---|
2505 | pThis->idCpuPackage = idCpuPackage;
|
---|
2506 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_CPU_HOTPLUG);
|
---|
2507 | }
|
---|
2508 | else
|
---|
2509 | rc = VERR_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
|
---|
2510 |
|
---|
2511 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2512 | return rc;
|
---|
2513 | }
|
---|
2514 |
|
---|
2515 | /* -=-=-=-=-=- Saved State -=-=-=-=-=- */
|
---|
2516 |
|
---|
2517 | /**
|
---|
2518 | * @copydoc FNSSMDEVLIVEEXEC
|
---|
2519 | */
|
---|
2520 | static DECLCALLBACK(int) vmmdevLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
|
---|
2521 | {
|
---|
2522 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
2523 |
|
---|
2524 | SSMR3PutBool(pSSM, pThis->fGetHostTimeDisabled);
|
---|
2525 | SSMR3PutBool(pSSM, pThis->fBackdoorLogDisabled);
|
---|
2526 | SSMR3PutBool(pSSM, pThis->fKeepCredentials);
|
---|
2527 | SSMR3PutBool(pSSM, pThis->fHeapEnabled);
|
---|
2528 |
|
---|
2529 | return VINF_SSM_DONT_CALL_AGAIN;
|
---|
2530 | }
|
---|
2531 |
|
---|
2532 |
|
---|
2533 | /**
|
---|
2534 | * @copydoc FNSSMDEVSAVEEXEC
|
---|
2535 | *
|
---|
2536 | */
|
---|
2537 | static DECLCALLBACK(int) vmmdevSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
2538 | {
|
---|
2539 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
2540 |
|
---|
2541 | vmmdevLiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
|
---|
2542 |
|
---|
2543 | SSMR3PutU32(pSSM, pThis->hypervisorSize);
|
---|
2544 | SSMR3PutU32(pSSM, pThis->mouseCapabilities);
|
---|
2545 | SSMR3PutU32(pSSM, pThis->mouseXAbs);
|
---|
2546 | SSMR3PutU32(pSSM, pThis->mouseYAbs);
|
---|
2547 |
|
---|
2548 | SSMR3PutBool(pSSM, pThis->fNewGuestFilterMask);
|
---|
2549 | SSMR3PutU32(pSSM, pThis->u32NewGuestFilterMask);
|
---|
2550 | SSMR3PutU32(pSSM, pThis->u32GuestFilterMask);
|
---|
2551 | SSMR3PutU32(pSSM, pThis->u32HostEventFlags);
|
---|
2552 | /* The following is not strictly necessary as PGM restors MMIO2, keeping it for historical reasons. */
|
---|
2553 | SSMR3PutMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof(pThis->pVMMDevRAMR3->V));
|
---|
2554 |
|
---|
2555 | SSMR3PutMem(pSSM, &pThis->guestInfo, sizeof (pThis->guestInfo));
|
---|
2556 | SSMR3PutU32(pSSM, pThis->fu32AdditionsOk);
|
---|
2557 | SSMR3PutU32(pSSM, pThis->u32VideoAccelEnabled);
|
---|
2558 | SSMR3PutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck);
|
---|
2559 |
|
---|
2560 | SSMR3PutU32(pSSM, pThis->guestCaps);
|
---|
2561 |
|
---|
2562 | #ifdef VBOX_WITH_HGCM
|
---|
2563 | vmmdevHGCMSaveState(pThis, pSSM);
|
---|
2564 | #endif /* VBOX_WITH_HGCM */
|
---|
2565 |
|
---|
2566 | SSMR3PutU32(pSSM, pThis->fHostCursorRequested);
|
---|
2567 |
|
---|
2568 | return VINF_SUCCESS;
|
---|
2569 | }
|
---|
2570 |
|
---|
2571 | /**
|
---|
2572 | * @copydoc FNSSMDEVLOADEXEC
|
---|
2573 | */
|
---|
2574 | static DECLCALLBACK(int) vmmdevLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
2575 | {
|
---|
2576 | /** @todo The code load code is assuming we're always loaded into a freshly
|
---|
2577 | * constructed VM. */
|
---|
2578 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
2579 | int rc;
|
---|
2580 |
|
---|
2581 | if ( uVersion > VMMDEV_SAVED_STATE_VERSION
|
---|
2582 | || uVersion < 6)
|
---|
2583 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
2584 |
|
---|
2585 | /* config */
|
---|
2586 | if (uVersion > VMMDEV_SAVED_STATE_VERSION_VBOX_30)
|
---|
2587 | {
|
---|
2588 | bool f;
|
---|
2589 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
2590 | if (pThis->fGetHostTimeDisabled != f)
|
---|
2591 | LogRel(("VMMDev: Config mismatch - fGetHostTimeDisabled: config=%RTbool saved=%RTbool\n", pThis->fGetHostTimeDisabled, f));
|
---|
2592 |
|
---|
2593 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
2594 | if (pThis->fBackdoorLogDisabled != f)
|
---|
2595 | LogRel(("VMMDev: Config mismatch - fBackdoorLogDisabled: config=%RTbool saved=%RTbool\n", pThis->fBackdoorLogDisabled, f));
|
---|
2596 |
|
---|
2597 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
2598 | if (pThis->fKeepCredentials != f)
|
---|
2599 | return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"),
|
---|
2600 | pThis->fKeepCredentials, f);
|
---|
2601 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
2602 | if (pThis->fHeapEnabled != f)
|
---|
2603 | return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"),
|
---|
2604 | pThis->fHeapEnabled, f);
|
---|
2605 | }
|
---|
2606 |
|
---|
2607 | if (uPass != SSM_PASS_FINAL)
|
---|
2608 | return VINF_SUCCESS;
|
---|
2609 |
|
---|
2610 | /* state */
|
---|
2611 | SSMR3GetU32(pSSM, &pThis->hypervisorSize);
|
---|
2612 | SSMR3GetU32(pSSM, &pThis->mouseCapabilities);
|
---|
2613 | SSMR3GetU32(pSSM, &pThis->mouseXAbs);
|
---|
2614 | SSMR3GetU32(pSSM, &pThis->mouseYAbs);
|
---|
2615 |
|
---|
2616 | SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMask);
|
---|
2617 | SSMR3GetU32(pSSM, &pThis->u32NewGuestFilterMask);
|
---|
2618 | SSMR3GetU32(pSSM, &pThis->u32GuestFilterMask);
|
---|
2619 | SSMR3GetU32(pSSM, &pThis->u32HostEventFlags);
|
---|
2620 |
|
---|
2621 | // SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
|
---|
2622 | // here be dragons (probably)
|
---|
2623 | SSMR3GetMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));
|
---|
2624 |
|
---|
2625 | SSMR3GetMem(pSSM, &pThis->guestInfo, sizeof (pThis->guestInfo));
|
---|
2626 | SSMR3GetU32(pSSM, &pThis->fu32AdditionsOk);
|
---|
2627 | SSMR3GetU32(pSSM, &pThis->u32VideoAccelEnabled);
|
---|
2628 | if (uVersion > 10)
|
---|
2629 | SSMR3GetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck);
|
---|
2630 |
|
---|
2631 | rc = SSMR3GetU32(pSSM, &pThis->guestCaps);
|
---|
2632 |
|
---|
2633 | /* Attributes which were temporarily introduced in r30072 */
|
---|
2634 | if (uVersion == 7)
|
---|
2635 | {
|
---|
2636 | uint32_t temp;
|
---|
2637 | SSMR3GetU32(pSSM, &temp);
|
---|
2638 | rc = SSMR3GetU32(pSSM, &temp);
|
---|
2639 | }
|
---|
2640 | AssertRCReturn(rc, rc);
|
---|
2641 |
|
---|
2642 | #ifdef VBOX_WITH_HGCM
|
---|
2643 | rc = vmmdevHGCMLoadState(pThis, pSSM, uVersion);
|
---|
2644 | AssertRCReturn(rc, rc);
|
---|
2645 | #endif /* VBOX_WITH_HGCM */
|
---|
2646 |
|
---|
2647 | if (uVersion >= 10)
|
---|
2648 | rc = SSMR3GetU32(pSSM, &pThis->fHostCursorRequested);
|
---|
2649 | AssertRCReturn(rc, rc);
|
---|
2650 |
|
---|
2651 | /*
|
---|
2652 | * On a resume, we send the capabilities changed message so
|
---|
2653 | * that listeners can sync their state again
|
---|
2654 | */
|
---|
2655 | Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
|
---|
2656 | if (pThis->pDrv)
|
---|
2657 | {
|
---|
2658 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
2659 | if (uVersion >= 10)
|
---|
2660 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
2661 | /*fVisible=*/!!pThis->fHostCursorRequested,
|
---|
2662 | /*fAlpha=*/false,
|
---|
2663 | /*xHot=*/0, /*yHot=*/0,
|
---|
2664 | /*cx=*/0, /*cy=*/0,
|
---|
2665 | /*pvShape=*/NULL);
|
---|
2666 | }
|
---|
2667 |
|
---|
2668 | /* Reestablish the acceleration status. */
|
---|
2669 | if ( pThis->u32VideoAccelEnabled
|
---|
2670 | && pThis->pDrv)
|
---|
2671 | {
|
---|
2672 | pThis->pDrv->pfnVideoAccelEnable (pThis->pDrv, !!pThis->u32VideoAccelEnabled, &pThis->pVMMDevRAMR3->vbvaMemory);
|
---|
2673 | }
|
---|
2674 |
|
---|
2675 | if (pThis->fu32AdditionsOk)
|
---|
2676 | {
|
---|
2677 | LogRel(("Guest Additions information report: additionsVersion = 0x%08X, osType = 0x%08X\n",
|
---|
2678 | pThis->guestInfo.interfaceVersion,
|
---|
2679 | pThis->guestInfo.osType));
|
---|
2680 | if (pThis->pDrv)
|
---|
2681 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
2682 | }
|
---|
2683 | if (pThis->pDrv)
|
---|
2684 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
2685 |
|
---|
2686 | return VINF_SUCCESS;
|
---|
2687 | }
|
---|
2688 |
|
---|
2689 | /**
|
---|
2690 | * Load state done callback. Notify guest of restore event.
|
---|
2691 | *
|
---|
2692 | * @returns VBox status code.
|
---|
2693 | * @param pDevIns The device instance.
|
---|
2694 | * @param pSSM The handle to the saved state.
|
---|
2695 | */
|
---|
2696 | static DECLCALLBACK(int) vmmdevLoadStateDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
2697 | {
|
---|
2698 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
2699 |
|
---|
2700 | #ifdef VBOX_WITH_HGCM
|
---|
2701 | int rc = vmmdevHGCMLoadStateDone(pThis, pSSM);
|
---|
2702 | AssertLogRelRCReturn(rc, rc);
|
---|
2703 | #endif /* VBOX_WITH_HGCM */
|
---|
2704 |
|
---|
2705 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_RESTORED);
|
---|
2706 |
|
---|
2707 | return VINF_SUCCESS;
|
---|
2708 | }
|
---|
2709 |
|
---|
2710 | /* -=-=-=-=- PDMDEVREG -=-=-=-=- */
|
---|
2711 |
|
---|
2712 | /**
|
---|
2713 | * (Re-)initializes the MMIO2 data.
|
---|
2714 | *
|
---|
2715 | * @param pThis Pointer to the VMMDev instance data.
|
---|
2716 | */
|
---|
2717 | static void vmmdevInitRam(VMMDevState *pThis)
|
---|
2718 | {
|
---|
2719 | memset(pThis->pVMMDevRAMR3, 0, sizeof(VMMDevMemory));
|
---|
2720 | pThis->pVMMDevRAMR3->u32Size = sizeof(VMMDevMemory);
|
---|
2721 | pThis->pVMMDevRAMR3->u32Version = VMMDEV_MEMORY_VERSION;
|
---|
2722 | }
|
---|
2723 |
|
---|
2724 | /**
|
---|
2725 | * Reset notification.
|
---|
2726 | *
|
---|
2727 | * @returns VBox status.
|
---|
2728 | * @param pDrvIns The driver instance data.
|
---|
2729 | */
|
---|
2730 | static DECLCALLBACK(void) vmmdevReset(PPDMDEVINS pDevIns)
|
---|
2731 | {
|
---|
2732 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
2733 |
|
---|
2734 | /*
|
---|
2735 | * Reset the mouse integration feature bits
|
---|
2736 | */
|
---|
2737 | if (pThis->mouseCapabilities & VMMDEV_MOUSE_GUEST_MASK)
|
---|
2738 | {
|
---|
2739 | pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
|
---|
2740 | /* notify the connector */
|
---|
2741 | Log(("vmmdevReset: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
|
---|
2742 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
2743 | }
|
---|
2744 | pThis->fHostCursorRequested = false;
|
---|
2745 |
|
---|
2746 | pThis->hypervisorSize = 0;
|
---|
2747 |
|
---|
2748 | pThis->u32HostEventFlags = 0;
|
---|
2749 |
|
---|
2750 | /* re-initialize the VMMDev memory */
|
---|
2751 | if (pThis->pVMMDevRAMR3)
|
---|
2752 | vmmdevInitRam(pThis);
|
---|
2753 |
|
---|
2754 | /* credentials have to go away (by default) */
|
---|
2755 | if (!pThis->fKeepCredentials)
|
---|
2756 | {
|
---|
2757 | memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2758 | memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2759 | memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2760 | }
|
---|
2761 | memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2762 | memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2763 | memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2764 |
|
---|
2765 | /* Reset means that additions will report again. */
|
---|
2766 | const bool fVersionChanged = pThis->fu32AdditionsOk
|
---|
2767 | || pThis->guestInfo.interfaceVersion
|
---|
2768 | || pThis->guestInfo.osType != VBOXOSTYPE_Unknown;
|
---|
2769 | if (fVersionChanged)
|
---|
2770 | Log(("vmmdevReset: fu32AdditionsOk=%d additionsVersion=%x osType=%#x\n",
|
---|
2771 | pThis->fu32AdditionsOk, pThis->guestInfo.interfaceVersion, pThis->guestInfo.osType));
|
---|
2772 | pThis->fu32AdditionsOk = false;
|
---|
2773 | memset (&pThis->guestInfo, 0, sizeof (pThis->guestInfo));
|
---|
2774 |
|
---|
2775 | /* clear pending display change request. */
|
---|
2776 | for (unsigned i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
2777 | {
|
---|
2778 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[i];
|
---|
2779 | memset (&pRequest->lastReadDisplayChangeRequest, 0, sizeof (pRequest->lastReadDisplayChangeRequest));
|
---|
2780 | }
|
---|
2781 | pThis->displayChangeData.iCurrentMonitor = 0;
|
---|
2782 | pThis->displayChangeData.fGuestSentChangeEventAck = false;
|
---|
2783 |
|
---|
2784 | /* disable seamless mode */
|
---|
2785 | pThis->fLastSeamlessEnabled = false;
|
---|
2786 |
|
---|
2787 | /* disabled memory ballooning */
|
---|
2788 | pThis->u32LastMemoryBalloonSize = 0;
|
---|
2789 |
|
---|
2790 | /* disabled statistics updating */
|
---|
2791 | pThis->u32LastStatIntervalSize = 0;
|
---|
2792 |
|
---|
2793 | /* Clear the "HGCM event enabled" flag so the event can be automatically reenabled. */
|
---|
2794 | pThis->u32HGCMEnabled = 0;
|
---|
2795 |
|
---|
2796 | /*
|
---|
2797 | * Clear the event variables.
|
---|
2798 | *
|
---|
2799 | * Note: The pThis->u32HostEventFlags is not cleared.
|
---|
2800 | * It is designed that way so host events do not
|
---|
2801 | * depend on guest resets.
|
---|
2802 | */
|
---|
2803 | pThis->u32GuestFilterMask = 0;
|
---|
2804 | pThis->u32NewGuestFilterMask = 0;
|
---|
2805 | pThis->fNewGuestFilterMask = 0;
|
---|
2806 |
|
---|
2807 | /* This is the default, as Windows and OS/2 guests take this for granted. (Actually, neither does...) */
|
---|
2808 | /** @todo change this when we next bump the interface version */
|
---|
2809 | const bool fCapsChanged = pThis->guestCaps != VMMDEV_GUEST_SUPPORTS_GRAPHICS;
|
---|
2810 | if (fCapsChanged)
|
---|
2811 | Log(("vmmdevReset: fCapsChanged=%#x -> %#x\n", pThis->guestCaps, VMMDEV_GUEST_SUPPORTS_GRAPHICS));
|
---|
2812 | pThis->guestCaps = VMMDEV_GUEST_SUPPORTS_GRAPHICS; /** @todo r=bird: why? I cannot see this being done at construction?*/
|
---|
2813 |
|
---|
2814 | /*
|
---|
2815 | * Call the update functions as required.
|
---|
2816 | */
|
---|
2817 | if (fVersionChanged)
|
---|
2818 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
2819 | if (fCapsChanged)
|
---|
2820 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
2821 |
|
---|
2822 | /* Generate a unique session id for this VM; it will be changed for each start, reset or restore.
|
---|
2823 | * This can be used for restore detection inside the guest.
|
---|
2824 | */
|
---|
2825 | pThis->idSession = ASMReadTSC();
|
---|
2826 | }
|
---|
2827 |
|
---|
2828 |
|
---|
2829 | /**
|
---|
2830 | * @interface_method_impl{PDMDEVREG,pfnRelocate}
|
---|
2831 | */
|
---|
2832 | static DECLCALLBACK(void) vmmdevRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
|
---|
2833 | {
|
---|
2834 | NOREF(pDevIns);
|
---|
2835 | NOREF(offDelta);
|
---|
2836 | }
|
---|
2837 |
|
---|
2838 |
|
---|
2839 | /**
|
---|
2840 | * @interface_method_impl{PDMDEVREG,pfnDestruct}
|
---|
2841 | */
|
---|
2842 | static DECLCALLBACK(int) vmmdevDestroy(PPDMDEVINS pDevIns)
|
---|
2843 | {
|
---|
2844 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
2845 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
2846 |
|
---|
2847 | /*
|
---|
2848 | * Wipe and free the credentials.
|
---|
2849 | */
|
---|
2850 | if (pThis->pCredentials)
|
---|
2851 | {
|
---|
2852 | RTMemWipeThoroughly(pThis->pCredentials, sizeof(*pThis->pCredentials), 10);
|
---|
2853 | RTMemFree(pThis->pCredentials);
|
---|
2854 | pThis->pCredentials = NULL;
|
---|
2855 | }
|
---|
2856 |
|
---|
2857 | return VINF_SUCCESS;
|
---|
2858 | }
|
---|
2859 |
|
---|
2860 |
|
---|
2861 | /**
|
---|
2862 | * @interface_method_impl{PDMDEVREG,pfnConstruct}
|
---|
2863 | */
|
---|
2864 | static DECLCALLBACK(int) vmmdevConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
|
---|
2865 | {
|
---|
2866 | int rc;
|
---|
2867 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
2868 |
|
---|
2869 | Assert(iInstance == 0);
|
---|
2870 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
2871 |
|
---|
2872 | /*
|
---|
2873 | * Initialize data (most of it anyway).
|
---|
2874 | */
|
---|
2875 | /* Save PDM device instance data for future reference. */
|
---|
2876 | pThis->pDevIns = pDevIns;
|
---|
2877 |
|
---|
2878 | /* PCI vendor, just a free bogus value */
|
---|
2879 | pThis->dev.config[0x00] = 0xee;
|
---|
2880 | pThis->dev.config[0x01] = 0x80;
|
---|
2881 | /* device ID */
|
---|
2882 | pThis->dev.config[0x02] = 0xfe;
|
---|
2883 | pThis->dev.config[0x03] = 0xca;
|
---|
2884 | /* class sub code (other type of system peripheral) */
|
---|
2885 | pThis->dev.config[0x0a] = 0x80;
|
---|
2886 | /* class base code (base system peripheral) */
|
---|
2887 | pThis->dev.config[0x0b] = 0x08;
|
---|
2888 | /* header type */
|
---|
2889 | pThis->dev.config[0x0e] = 0x00;
|
---|
2890 | /* interrupt on pin 0 */
|
---|
2891 | pThis->dev.config[0x3d] = 0x01;
|
---|
2892 |
|
---|
2893 | /*
|
---|
2894 | * Interfaces
|
---|
2895 | */
|
---|
2896 | /* IBase */
|
---|
2897 | pThis->IBase.pfnQueryInterface = vmmdevPortQueryInterface;
|
---|
2898 |
|
---|
2899 | /* VMMDev port */
|
---|
2900 | pThis->IPort.pfnQueryAbsoluteMouse = vmmdevQueryAbsoluteMouse;
|
---|
2901 | pThis->IPort.pfnSetAbsoluteMouse = vmmdevSetAbsoluteMouse;
|
---|
2902 | pThis->IPort.pfnQueryMouseCapabilities = vmmdevQueryMouseCapabilities;
|
---|
2903 | pThis->IPort.pfnSetMouseCapabilities = vmmdevSetMouseCapabilities;
|
---|
2904 | pThis->IPort.pfnRequestDisplayChange = vmmdevRequestDisplayChange;
|
---|
2905 | pThis->IPort.pfnSetCredentials = vmmdevSetCredentials;
|
---|
2906 | pThis->IPort.pfnVBVAChange = vmmdevVBVAChange;
|
---|
2907 | pThis->IPort.pfnRequestSeamlessChange = vmmdevRequestSeamlessChange;
|
---|
2908 | pThis->IPort.pfnSetMemoryBalloon = vmmdevSetMemoryBalloon;
|
---|
2909 | pThis->IPort.pfnSetStatisticsInterval = vmmdevSetStatisticsInterval;
|
---|
2910 | pThis->IPort.pfnVRDPChange = vmmdevVRDPChange;
|
---|
2911 | pThis->IPort.pfnCpuHotUnplug = vmmdevCpuHotUnplug;
|
---|
2912 | pThis->IPort.pfnCpuHotPlug = vmmdevCpuHotPlug;
|
---|
2913 |
|
---|
2914 | /* Shared folder LED */
|
---|
2915 | pThis->SharedFolders.Led.u32Magic = PDMLED_MAGIC;
|
---|
2916 | pThis->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed;
|
---|
2917 |
|
---|
2918 | #ifdef VBOX_WITH_HGCM
|
---|
2919 | /* HGCM port */
|
---|
2920 | pThis->IHGCMPort.pfnCompleted = hgcmCompleted;
|
---|
2921 | #endif
|
---|
2922 |
|
---|
2923 | pThis->pCredentials = (VMMDEVCREDS *)RTMemAllocZ(sizeof(*pThis->pCredentials));
|
---|
2924 | if (!pThis->pCredentials)
|
---|
2925 | return VERR_NO_MEMORY;
|
---|
2926 |
|
---|
2927 |
|
---|
2928 | /*
|
---|
2929 | * Validate and read the configuration.
|
---|
2930 | */
|
---|
2931 | PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns,
|
---|
2932 | "GetHostTimeDisabled|"
|
---|
2933 | "BackdoorLogDisabled|"
|
---|
2934 | "KeepCredentials|"
|
---|
2935 | "HeapEnabled|"
|
---|
2936 | "RamSize|"
|
---|
2937 | "RZEnabled|"
|
---|
2938 | "GuestCoreDumpEnabled|"
|
---|
2939 | "GuestCoreDumpDir|"
|
---|
2940 | "GuestCoreDumpCount|"
|
---|
2941 | "TestingEnabled"
|
---|
2942 | ,
|
---|
2943 | "");
|
---|
2944 |
|
---|
2945 | rc = CFGMR3QueryU64(pCfg, "RamSize", &pThis->cbGuestRAM);
|
---|
2946 | if (RT_FAILURE(rc))
|
---|
2947 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2948 | N_("Configuration error: Failed querying \"RamSize\" as a 64-bit unsigned integer"));
|
---|
2949 |
|
---|
2950 | rc = CFGMR3QueryBoolDef(pCfg, "GetHostTimeDisabled", &pThis->fGetHostTimeDisabled, false);
|
---|
2951 | if (RT_FAILURE(rc))
|
---|
2952 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2953 | N_("Configuration error: Failed querying \"GetHostTimeDisabled\" as a boolean"));
|
---|
2954 |
|
---|
2955 | rc = CFGMR3QueryBoolDef(pCfg, "BackdoorLogDisabled", &pThis->fBackdoorLogDisabled, false);
|
---|
2956 | if (RT_FAILURE(rc))
|
---|
2957 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2958 | N_("Configuration error: Failed querying \"BackdoorLogDisabled\" as a boolean"));
|
---|
2959 |
|
---|
2960 | rc = CFGMR3QueryBoolDef(pCfg, "KeepCredentials", &pThis->fKeepCredentials, false);
|
---|
2961 | if (RT_FAILURE(rc))
|
---|
2962 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2963 | N_("Configuration error: Failed querying \"KeepCredentials\" as a boolean"));
|
---|
2964 |
|
---|
2965 | rc = CFGMR3QueryBoolDef(pCfg, "HeapEnabled", &pThis->fHeapEnabled, true);
|
---|
2966 | if (RT_FAILURE(rc))
|
---|
2967 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2968 | N_("Configuration error: Failed querying \"HeapEnabled\" as a boolean"));
|
---|
2969 |
|
---|
2970 | rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true);
|
---|
2971 | if (RT_FAILURE(rc))
|
---|
2972 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2973 | N_("Configuration error: Failed querying \"RZEnabled\" as a boolean"));
|
---|
2974 |
|
---|
2975 | rc = CFGMR3QueryBoolDef(pCfg, "GuestCoreDumpEnabled", &pThis->fGuestCoreDumpEnabled, false);
|
---|
2976 | if (RT_FAILURE(rc))
|
---|
2977 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2978 | N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean"));
|
---|
2979 |
|
---|
2980 | char *pszGuestCoreDumpDir = NULL;
|
---|
2981 | rc = CFGMR3QueryStringAlloc(pCfg, "GuestCoreDumpDir", &pszGuestCoreDumpDir);
|
---|
2982 | if (RT_FAILURE(rc))
|
---|
2983 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2984 | N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string"));
|
---|
2985 |
|
---|
2986 | RTStrCopy(pThis->szGuestCoreDumpDir, sizeof(pThis->szGuestCoreDumpDir), pszGuestCoreDumpDir);
|
---|
2987 | MMR3HeapFree(pszGuestCoreDumpDir);
|
---|
2988 |
|
---|
2989 | rc = CFGMR3QueryU32Def(pCfg, "GuestCoreDumpCount", &pThis->cGuestCoreDumps, 3);
|
---|
2990 | if (RT_FAILURE(rc))
|
---|
2991 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2992 | N_("Configuration error: Failed querying \"GuestCoreDumpCount\" as a 32-bit unsigned integer"));
|
---|
2993 |
|
---|
2994 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
2995 | rc = CFGMR3QueryBoolDef(pCfg, "TestingEnabled", &pThis->fTestingEnabled, false);
|
---|
2996 | if (RT_FAILURE(rc))
|
---|
2997 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
2998 | N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean"));
|
---|
2999 | /** @todo image-to-load-filename? */
|
---|
3000 | #endif
|
---|
3001 |
|
---|
3002 | /*
|
---|
3003 | * Create the critical section for the device.
|
---|
3004 | */
|
---|
3005 | rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "VMMDev");
|
---|
3006 | AssertRCReturn(rc, rc);
|
---|
3007 | /* Later: pDevIns->pCritSectR3 = &pThis->CritSect; */
|
---|
3008 |
|
---|
3009 | /*
|
---|
3010 | * Register the backdoor logging port
|
---|
3011 | */
|
---|
3012 | rc = PDMDevHlpIOPortRegister(pDevIns, RTLOG_DEBUG_PORT, 1, NULL, vmmdevBackdoorLog, NULL, NULL, NULL, "VMMDev backdoor logging");
|
---|
3013 | AssertRCReturn(rc, rc);
|
---|
3014 |
|
---|
3015 | #ifdef TIMESYNC_BACKDOOR
|
---|
3016 | /*
|
---|
3017 | * Alternative timesync source (temporary!)
|
---|
3018 | */
|
---|
3019 | rc = PDMDevHlpIOPortRegister(pDevIns, 0x505, 1, NULL, vmmdevTimesyncBackdoorWrite, vmmdevTimesyncBackdoorRead, NULL, NULL, "VMMDev timesync backdoor");
|
---|
3020 | AssertRCReturn(rc, rc);
|
---|
3021 | #endif
|
---|
3022 |
|
---|
3023 | /*
|
---|
3024 | * Allocate and initialize the MMIO2 memory.
|
---|
3025 | */
|
---|
3026 | rc = PDMDevHlpMMIO2Register(pDevIns, 1 /*iRegion*/, VMMDEV_RAM_SIZE, 0 /*fFlags*/, (void **)&pThis->pVMMDevRAMR3, "VMMDev");
|
---|
3027 | if (RT_FAILURE(rc))
|
---|
3028 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
|
---|
3029 | N_("Failed to allocate %u bytes of memory for the VMM device"), VMMDEV_RAM_SIZE);
|
---|
3030 | vmmdevInitRam(pThis);
|
---|
3031 |
|
---|
3032 | if (pThis->fHeapEnabled)
|
---|
3033 | {
|
---|
3034 | rc = PDMDevHlpMMIO2Register(pDevIns, 2 /*iRegion*/, VMMDEV_HEAP_SIZE, 0 /*fFlags*/, (void **)&pThis->pVMMDevHeapR3, "VMMDev Heap");
|
---|
3035 | if (RT_FAILURE(rc))
|
---|
3036 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
|
---|
3037 | N_("Failed to allocate %u bytes of memory for the VMM device heap"), PAGE_SIZE);
|
---|
3038 | }
|
---|
3039 |
|
---|
3040 | /*
|
---|
3041 | * Register the PCI device.
|
---|
3042 | */
|
---|
3043 | rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev);
|
---|
3044 | if (RT_FAILURE(rc))
|
---|
3045 | return rc;
|
---|
3046 | if (pThis->dev.devfn == 32 || iInstance != 0)
|
---|
3047 | Log(("!!WARNING!!: pThis->dev.devfn=%d (ignore if testcase or no started by Main)\n", pThis->dev.devfn));
|
---|
3048 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x20, PCI_ADDRESS_SPACE_IO, vmmdevIOPortRegionMap);
|
---|
3049 | if (RT_FAILURE(rc))
|
---|
3050 | return rc;
|
---|
3051 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, vmmdevIORAMRegionMap);
|
---|
3052 | if (RT_FAILURE(rc))
|
---|
3053 | return rc;
|
---|
3054 | if (pThis->fHeapEnabled)
|
---|
3055 | {
|
---|
3056 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, vmmdevIORAMRegionMap);
|
---|
3057 | if (RT_FAILURE(rc))
|
---|
3058 | return rc;
|
---|
3059 | }
|
---|
3060 |
|
---|
3061 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
3062 | /*
|
---|
3063 | * Initialize testing.
|
---|
3064 | */
|
---|
3065 | rc = vmmdevTestingInitialize(pDevIns);
|
---|
3066 | if (RT_FAILURE(rc))
|
---|
3067 | return rc;
|
---|
3068 | #endif
|
---|
3069 |
|
---|
3070 | /*
|
---|
3071 | * Get the corresponding connector interface
|
---|
3072 | */
|
---|
3073 | rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "VMM Driver Port");
|
---|
3074 | if (RT_SUCCESS(rc))
|
---|
3075 | {
|
---|
3076 | pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIVMMDEVCONNECTOR);
|
---|
3077 | AssertMsgReturn(pThis->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE);
|
---|
3078 | #ifdef VBOX_WITH_HGCM
|
---|
3079 | pThis->pHGCMDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIHGCMCONNECTOR);
|
---|
3080 | if (!pThis->pHGCMDrv)
|
---|
3081 | {
|
---|
3082 | Log(("LUN #0 doesn't have a HGCM connector interface, HGCM is not supported. rc=%Rrc\n", rc));
|
---|
3083 | /* this is not actually an error, just means that there is no support for HGCM */
|
---|
3084 | }
|
---|
3085 | #endif
|
---|
3086 | /* Query the initial balloon size. */
|
---|
3087 | AssertPtr(pThis->pDrv->pfnQueryBalloonSize);
|
---|
3088 | rc = pThis->pDrv->pfnQueryBalloonSize(pThis->pDrv, &pThis->u32MemoryBalloonSize);
|
---|
3089 | AssertRC(rc);
|
---|
3090 |
|
---|
3091 | Log(("Initial balloon size %x\n", pThis->u32MemoryBalloonSize));
|
---|
3092 | }
|
---|
3093 | else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
3094 | {
|
---|
3095 | Log(("%s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
3096 | rc = VINF_SUCCESS;
|
---|
3097 | }
|
---|
3098 | else
|
---|
3099 | AssertMsgFailedReturn(("Failed to attach LUN #0! rc=%Rrc\n", rc), rc);
|
---|
3100 |
|
---|
3101 | /*
|
---|
3102 | * Attach status driver for shared folders (optional).
|
---|
3103 | */
|
---|
3104 | PPDMIBASE pBase;
|
---|
3105 | rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
|
---|
3106 | if (RT_SUCCESS(rc))
|
---|
3107 | pThis->SharedFolders.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
|
---|
3108 | else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
3109 | {
|
---|
3110 | AssertMsgFailed(("Failed to attach to status driver. rc=%Rrc\n", rc));
|
---|
3111 | return rc;
|
---|
3112 | }
|
---|
3113 |
|
---|
3114 | /*
|
---|
3115 | * Register saved state and init the HGCM CmdList critsect.
|
---|
3116 | */
|
---|
3117 | rc = PDMDevHlpSSMRegisterEx(pDevIns, VMMDEV_SAVED_STATE_VERSION, sizeof(*pThis), NULL,
|
---|
3118 | NULL, vmmdevLiveExec, NULL,
|
---|
3119 | NULL, vmmdevSaveExec, NULL,
|
---|
3120 | NULL, vmmdevLoadExec, vmmdevLoadStateDone);
|
---|
3121 | AssertRCReturn(rc, rc);
|
---|
3122 |
|
---|
3123 | #ifdef VBOX_WITH_HGCM
|
---|
3124 | pThis->pHGCMCmdList = NULL;
|
---|
3125 | rc = RTCritSectInit(&pThis->critsectHGCMCmdList);
|
---|
3126 | AssertRCReturn(rc, rc);
|
---|
3127 | pThis->u32HGCMEnabled = 0;
|
---|
3128 | #endif /* VBOX_WITH_HGCM */
|
---|
3129 |
|
---|
3130 | /* In this version of VirtualBox the GUI checks whether "needs host cursor"
|
---|
3131 | * changes. */
|
---|
3132 | pThis->mouseCapabilities |= VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
|
---|
3133 |
|
---|
3134 | PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Memory balloon size", "/Devices/VMMDev/BalloonChunks");
|
---|
3135 |
|
---|
3136 | /* Generate a unique session id for this VM; it will be changed for each start, reset or restore.
|
---|
3137 | * This can be used for restore detection inside the guest.
|
---|
3138 | */
|
---|
3139 | pThis->idSession = ASMReadTSC();
|
---|
3140 | return rc;
|
---|
3141 | }
|
---|
3142 |
|
---|
3143 | /**
|
---|
3144 | * The device registration structure.
|
---|
3145 | */
|
---|
3146 | extern "C" const PDMDEVREG g_DeviceVMMDev =
|
---|
3147 | {
|
---|
3148 | /* u32Version */
|
---|
3149 | PDM_DEVREG_VERSION,
|
---|
3150 | /* szName */
|
---|
3151 | "VMMDev",
|
---|
3152 | /* szRCMod */
|
---|
3153 | "VBoxDDGC.gc",
|
---|
3154 | /* szR0Mod */
|
---|
3155 | "VBoxDDR0.r0",
|
---|
3156 | /* pszDescription */
|
---|
3157 | "VirtualBox VMM Device\n",
|
---|
3158 | /* fFlags */
|
---|
3159 | PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
|
---|
3160 | /* fClass */
|
---|
3161 | PDM_DEVREG_CLASS_VMM_DEV,
|
---|
3162 | /* cMaxInstances */
|
---|
3163 | 1,
|
---|
3164 | /* cbInstance */
|
---|
3165 | sizeof(VMMDevState),
|
---|
3166 | /* pfnConstruct */
|
---|
3167 | vmmdevConstruct,
|
---|
3168 | /* pfnDestruct */
|
---|
3169 | NULL,
|
---|
3170 | /* pfnRelocate */
|
---|
3171 | vmmdevRelocate,
|
---|
3172 | /* pfnIOCtl */
|
---|
3173 | NULL,
|
---|
3174 | /* pfnPowerOn */
|
---|
3175 | NULL,
|
---|
3176 | /* pfnReset */
|
---|
3177 | vmmdevReset,
|
---|
3178 | /* pfnSuspend */
|
---|
3179 | NULL,
|
---|
3180 | /* pfnResume */
|
---|
3181 | NULL,
|
---|
3182 | /* pfnAttach */
|
---|
3183 | NULL,
|
---|
3184 | /* pfnDetach */
|
---|
3185 | NULL,
|
---|
3186 | /* pfnQueryInterface. */
|
---|
3187 | NULL,
|
---|
3188 | /* pfnInitComplete */
|
---|
3189 | NULL,
|
---|
3190 | /* pfnPowerOff */
|
---|
3191 | NULL,
|
---|
3192 | /* pfnSoftReset */
|
---|
3193 | NULL,
|
---|
3194 | /* u32VersionEnd */
|
---|
3195 | PDM_DEVREG_VERSION
|
---|
3196 | };
|
---|
3197 | #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
|
---|