VirtualBox

source: vbox/trunk/include/VBox/VMMDev.h@ 39917

Last change on this file since 39917 was 39825, checked in by vboxsync, 13 years ago

VBoxGuestInfo2::szName updated documenation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 61.7 KB
Line 
1/** @file
2 * Virtual Device for Guest <-> VMM/Host communication (ADD,DEV).
3 */
4
5/*
6 * Copyright (C) 2006-2011 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_VMMDev_h
27#define ___VBox_VMMDev_h
28
29#include <VBox/cdefs.h>
30#include <VBox/param.h> /* for the PCI IDs. */
31#include <VBox/types.h>
32#include <VBox/err.h>
33#include <VBox/ostypes.h>
34#include <VBox/VMMDev2.h>
35#include <iprt/assert.h>
36
37
38RT_C_DECLS_BEGIN
39
40/** @defgroup grp_vmmdev VMM Device
41 *
42 * Note! This interface cannot be changed, it can only be extended!
43 *
44 * @{
45 */
46
47
48/** Size of VMMDev RAM region accessible by guest.
49 * Must be big enough to contain VMMDevMemory structure (see further down).
50 * For now: 4 megabyte.
51 */
52#define VMMDEV_RAM_SIZE (4 * 256 * PAGE_SIZE)
53
54/** Size of VMMDev heap region accessible by guest.
55 * (Must be a power of two (pci range).)
56 */
57#define VMMDEV_HEAP_SIZE (4 * PAGE_SIZE)
58
59/** Port for generic request interface (relative offset). */
60#define VMMDEV_PORT_OFF_REQUEST 0
61
62
63/** @name VMMDev events.
64 *
65 * Used mainly by VMMDevReq_AcknowledgeEvents/VMMDevEvents and version 1.3 of
66 * VMMDevMemory.
67 *
68 * @{
69 */
70/** Host mouse capabilities has been changed. */
71#define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED RT_BIT(0)
72/** HGCM event. */
73#define VMMDEV_EVENT_HGCM RT_BIT(1)
74/** A display change request has been issued. */
75#define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST RT_BIT(2)
76/** Credentials are available for judgement. */
77#define VMMDEV_EVENT_JUDGE_CREDENTIALS RT_BIT(3)
78/** The guest has been restored. */
79#define VMMDEV_EVENT_RESTORED RT_BIT(4)
80/** Seamless mode state changed. */
81#define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST RT_BIT(5)
82/** Memory balloon size changed. */
83#define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST RT_BIT(6)
84/** Statistics interval changed. */
85#define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST RT_BIT(7)
86/** VRDP status changed. */
87#define VMMDEV_EVENT_VRDP RT_BIT(8)
88/** New mouse position data available. */
89#define VMMDEV_EVENT_MOUSE_POSITION_CHANGED RT_BIT(9)
90/** CPU hotplug event occurred. */
91#define VMMDEV_EVENT_CPU_HOTPLUG RT_BIT(10)
92/** The mask of valid events, for sanity checking. */
93#define VMMDEV_EVENT_VALID_EVENT_MASK UINT32_C(0x000007ff)
94/** @} */
95
96
97/** @defgroup grp_vmmdev_req VMMDev Generic Request Interface
98 * @{
99 */
100
101/** @name Current version of the VMMDev interface.
102 *
103 * Additions are allowed to work only if
104 * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
105 * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
106 *
107 * @remarks These defines also live in the 16-bit and assembly versions of this
108 * header.
109 */
110#define VMMDEV_VERSION 0x00010004
111#define VMMDEV_VERSION_MAJOR (VMMDEV_VERSION >> 16)
112#define VMMDEV_VERSION_MINOR (VMMDEV_VERSION & 0xffff)
113/** @} */
114
115/** Maximum request packet size. */
116#define VMMDEV_MAX_VMMDEVREQ_SIZE _1M
117
118/**
119 * VMMDev request types.
120 * @note when updating this, adjust vmmdevGetRequestSize() as well
121 */
122typedef enum
123{
124 VMMDevReq_InvalidRequest = 0,
125 VMMDevReq_GetMouseStatus = 1,
126 VMMDevReq_SetMouseStatus = 2,
127 VMMDevReq_SetPointerShape = 3,
128 VMMDevReq_GetHostVersion = 4,
129 VMMDevReq_Idle = 5,
130 VMMDevReq_GetHostTime = 10,
131 VMMDevReq_GetHypervisorInfo = 20,
132 VMMDevReq_SetHypervisorInfo = 21,
133 VMMDevReq_RegisterPatchMemory = 22, /* since version 3.0.6 */
134 VMMDevReq_DeregisterPatchMemory = 23, /* since version 3.0.6 */
135 VMMDevReq_SetPowerStatus = 30,
136 VMMDevReq_AcknowledgeEvents = 41,
137 VMMDevReq_CtlGuestFilterMask = 42,
138 VMMDevReq_ReportGuestInfo = 50,
139 VMMDevReq_ReportGuestInfo2 = 58, /* since version 3.2.0 */
140 VMMDevReq_ReportGuestStatus = 59, /* since version 3.2.8 */
141 /**
142 * Retrieve a display resize request sent by the host using
143 * @a IDisplay:setVideoModeHint. Deprecated.
144 *
145 * Similar to @a VMMDevReq_GetDisplayChangeRequest2, except that it only
146 * considers host requests sent for the first virtual display. This guest
147 * request should not be used in new guest code, and the results are
148 * undefined if a guest mixes calls to this and
149 * @a VMMDevReq_GetDisplayChangeRequest2.
150 */
151 VMMDevReq_GetDisplayChangeRequest = 51,
152 VMMDevReq_VideoModeSupported = 52,
153 VMMDevReq_GetHeightReduction = 53,
154 /**
155 * Retrieve a display resize request sent by the host using
156 * @a IDisplay:setVideoModeHint.
157 *
158 * Queries a display resize request sent from the host. If the
159 * @a eventAck member is sent to true and there is an unqueried
160 * request available for one of the virtual display then that request will
161 * be returned. If several displays have unqueried requests the lowest
162 * numbered display will be chosen first. Only the most recent unseen
163 * request for each display is remembered.
164 * If @a eventAck is set to false, the last host request queried with
165 * @a eventAck set is resent, or failing that the most recent received from
166 * the host. If no host request was ever received then all zeros are
167 * returned.
168 */
169 VMMDevReq_GetDisplayChangeRequest2 = 54,
170 VMMDevReq_ReportGuestCapabilities = 55,
171 VMMDevReq_SetGuestCapabilities = 56,
172 VMMDevReq_VideoModeSupported2 = 57, /* since version 3.2.0 */
173#ifdef VBOX_WITH_HGCM
174 VMMDevReq_HGCMConnect = 60,
175 VMMDevReq_HGCMDisconnect = 61,
176#ifdef VBOX_WITH_64_BITS_GUESTS
177 VMMDevReq_HGCMCall32 = 62,
178 VMMDevReq_HGCMCall64 = 63,
179#else
180 VMMDevReq_HGCMCall = 62,
181#endif /* VBOX_WITH_64_BITS_GUESTS */
182 VMMDevReq_HGCMCancel = 64,
183 VMMDevReq_HGCMCancel2 = 65,
184#endif
185 VMMDevReq_VideoAccelEnable = 70,
186 VMMDevReq_VideoAccelFlush = 71,
187 VMMDevReq_VideoSetVisibleRegion = 72,
188 VMMDevReq_GetSeamlessChangeRequest = 73,
189 VMMDevReq_QueryCredentials = 100,
190 VMMDevReq_ReportCredentialsJudgement = 101,
191 VMMDevReq_ReportGuestStats = 110,
192 VMMDevReq_GetMemBalloonChangeRequest = 111,
193 VMMDevReq_GetStatisticsChangeRequest = 112,
194 VMMDevReq_ChangeMemBalloon = 113,
195 VMMDevReq_GetVRDPChangeRequest = 150,
196 VMMDevReq_LogString = 200,
197 VMMDevReq_GetCpuHotPlugRequest = 210,
198 VMMDevReq_SetCpuHotPlugStatus = 211,
199 VMMDevReq_RegisterSharedModule = 212,
200 VMMDevReq_UnregisterSharedModule = 213,
201 VMMDevReq_CheckSharedModules = 214,
202 VMMDevReq_GetPageSharingStatus = 215,
203 VMMDevReq_DebugIsPageShared = 216,
204 VMMDevReq_GetSessionId = 217, /* since version 3.2.8 */
205 VMMDevReq_WriteCoreDump = 218,
206 VMMDevReq_SizeHack = 0x7fffffff
207} VMMDevRequestType;
208
209#ifdef VBOX_WITH_64_BITS_GUESTS
210/*
211 * Constants and structures are redefined for the guest.
212 *
213 * Host code MUST always use either *32 or *64 variant explicitely.
214 * Host source code will use VBOX_HGCM_HOST_CODE define to catch undefined
215 * data types and constants.
216 *
217 * This redefinition means that the new additions builds will use
218 * the *64 or *32 variants depending on the current architecture bit count (ARCH_BITS).
219 */
220# ifndef VBOX_HGCM_HOST_CODE
221# if ARCH_BITS == 64
222# define VMMDevReq_HGCMCall VMMDevReq_HGCMCall64
223# elif ARCH_BITS == 32
224# define VMMDevReq_HGCMCall VMMDevReq_HGCMCall32
225# else
226# error "Unsupported ARCH_BITS"
227# endif
228# endif /* !VBOX_HGCM_HOST_CODE */
229#endif /* VBOX_WITH_64_BITS_GUESTS */
230
231/** Version of VMMDevRequestHeader structure. */
232#define VMMDEV_REQUEST_HEADER_VERSION (0x10001)
233
234#pragma pack(4) /* force structure dword packing here. */
235
236/**
237 * Generic VMMDev request header.
238 */
239typedef struct
240{
241 /** IN: Size of the structure in bytes (including body). */
242 uint32_t size;
243 /** IN: Version of the structure. */
244 uint32_t version;
245 /** IN: Type of the request. */
246 VMMDevRequestType requestType;
247 /** OUT: Return code. */
248 int32_t rc;
249 /** Reserved field no.1. MBZ. */
250 uint32_t reserved1;
251 /** Reserved field no.2. MBZ. */
252 uint32_t reserved2;
253} VMMDevRequestHeader;
254AssertCompileSize(VMMDevRequestHeader, 24);
255
256
257/**
258 * Mouse status request structure.
259 *
260 * Used by VMMDevReq_GetMouseStatus and VMMDevReq_SetMouseStatus.
261 */
262typedef struct
263{
264 /** header */
265 VMMDevRequestHeader header;
266 /** Mouse feature mask. See VMMDEV_MOUSE_*. */
267 uint32_t mouseFeatures;
268 /** Mouse x position. */
269 int32_t pointerXPos;
270 /** Mouse y position. */
271 int32_t pointerYPos;
272} VMMDevReqMouseStatus;
273AssertCompileSize(VMMDevReqMouseStatus, 24+12);
274
275/** @name Mouse capability bits (VMMDevReqMouseStatus::mouseFeatures).
276 * @{ */
277/** The guest can (== wants to) handle absolute coordinates. */
278#define VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE RT_BIT(0)
279/** The host can (== wants to) send absolute coordinates.
280 * (Input not captured.) */
281#define VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE RT_BIT(1)
282/** The guest can *NOT* switch to software cursor and therefore depends on the
283 * host cursor.
284 *
285 * When guest additions are installed and the host has promised to display the
286 * cursor itself, the guest installs a hardware mouse driver. Don't ask the
287 * guest to switch to a software cursor then. */
288#define VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR RT_BIT(2)
289/** The host does NOT provide support for drawing the cursor itself.
290 * This is for instance the case for the L4 console. */
291#define VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER RT_BIT(3)
292/** The guest can read VMMDev events to find out about pointer movement */
293#define VMMDEV_MOUSE_NEW_PROTOCOL RT_BIT(4)
294/** If the guest changes the status of the
295 * VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR bit, the host will honour this */
296#define VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR RT_BIT(5)
297/** The host supplies an absolute pointing device. The Guest Additions may
298 * wish to use this to decide whether to install their own driver */
299#define VMMDEV_MOUSE_HOST_HAS_ABS_DEV RT_BIT(6)
300/** The mask of all VMMDEV_MOUSE_* flags */
301#define VMMDEV_MOUSE_MASK UINT32_C(0x0000007f)
302/** The mask of guest capability changes for which notification events should
303 * be sent */
304#define VMMDEV_MOUSE_NOTIFY_HOST_MASK \
305 (VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR)
306/** The mask of all capabilities which the guest can legitimately change */
307#define VMMDEV_MOUSE_GUEST_MASK \
308 (VMMDEV_MOUSE_NOTIFY_HOST_MASK | VMMDEV_MOUSE_NEW_PROTOCOL)
309/** The mask of host capability changes for which notification events should
310 * be sent */
311#define VMMDEV_MOUSE_NOTIFY_GUEST_MASK \
312 VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE
313/** The mask of all capabilities which the host can legitimately change */
314#define VMMDEV_MOUSE_HOST_MASK \
315 ( VMMDEV_MOUSE_NOTIFY_GUEST_MASK \
316 | VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER \
317 | VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR \
318 | VMMDEV_MOUSE_HOST_HAS_ABS_DEV)
319/** @} */
320
321
322/**
323 * Mouse pointer shape/visibility change request.
324 *
325 * Used by VMMDevReq_SetPointerShape. The size is variable.
326 */
327typedef struct VMMDevReqMousePointer
328{
329 /** Header. */
330 VMMDevRequestHeader header;
331 /** VBOX_MOUSE_POINTER_* bit flags. */
332 uint32_t fFlags;
333 /** x coordinate of hot spot. */
334 uint32_t xHot;
335 /** y coordinate of hot spot. */
336 uint32_t yHot;
337 /** Width of the pointer in pixels. */
338 uint32_t width;
339 /** Height of the pointer in scanlines. */
340 uint32_t height;
341 /** Pointer data.
342 *
343 ****
344 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
345 *
346 * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
347 * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
348 *
349 * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
350 * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
351 * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
352 *
353 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
354 * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
355 * end of any scanline are undefined.
356 *
357 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
358 * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
359 * Bytes in the gap between the AND and the XOR mask are undefined.
360 * XOR mask scanlines have no gap between them and size of XOR mask is:
361 * cXor = width * 4 * height.
362 ****
363 *
364 * Preallocate 4 bytes for accessing actual data as p->pointerData.
365 */
366 char pointerData[4];
367} VMMDevReqMousePointer;
368AssertCompileSize(VMMDevReqMousePointer, 24+24);
369
370/**
371 * Get the size that a VMMDevReqMousePointer request should have for a given
372 * size of cursor, including the trailing cursor image and mask data.
373 * @note an "empty" request still has the four preallocated bytes of data
374 *
375 * @returns the size
376 * @param width the cursor width
377 * @param height the cursor height
378 */
379DECLINLINE(size_t) vmmdevGetMousePointerReqSize(uint32_t width, uint32_t height)
380{
381 size_t cbBase = RT_OFFSETOF(VMMDevReqMousePointer, pointerData);
382 size_t cbMask = (width + 7) / 8 * height;
383 size_t cbArgb = width * height * 4;
384 return RT_MAX(cbBase + ((cbMask + 3) & ~3) + cbArgb,
385 sizeof(VMMDevReqMousePointer));
386}
387
388/** @name VMMDevReqMousePointer::fFlags
389 * @note The VBOX_MOUSE_POINTER_* flags are used in the guest video driver,
390 * values must be <= 0x8000 and must not be changed. (try make more sense
391 * of this, please).
392 * @{
393 */
394/** pointer is visible */
395#define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
396/** pointer has alpha channel */
397#define VBOX_MOUSE_POINTER_ALPHA (0x0002)
398/** pointerData contains new pointer shape */
399#define VBOX_MOUSE_POINTER_SHAPE (0x0004)
400/** @} */
401
402
403/**
404 * String log request structure.
405 *
406 * Used by VMMDevReq_LogString.
407 * @deprecated Use the IPRT logger or VbglR3WriteLog instead.
408 */
409typedef struct
410{
411 /** header */
412 VMMDevRequestHeader header;
413 /** variable length string data */
414 char szString[1];
415} VMMDevReqLogString;
416AssertCompileSize(VMMDevReqLogString, 24+4);
417
418
419/**
420 * VirtualBox host version request structure.
421 *
422 * Used by VMMDevReq_GetHostVersion.
423 *
424 * @remarks VBGL uses this to detect the precense of new features in the
425 * interface.
426 */
427typedef struct
428{
429 /** Header. */
430 VMMDevRequestHeader header;
431 /** Major version. */
432 uint16_t major;
433 /** Minor version. */
434 uint16_t minor;
435 /** Build number. */
436 uint32_t build;
437 /** SVN revision. */
438 uint32_t revision;
439 /** Feature mask. */
440 uint32_t features;
441} VMMDevReqHostVersion;
442AssertCompileSize(VMMDevReqHostVersion, 24+16);
443
444/** @name VMMDevReqHostVersion::features
445 * @{ */
446/** Physical page lists are supported by HGCM. */
447#define VMMDEV_HVF_HGCM_PHYS_PAGE_LIST RT_BIT(0)
448/** @} */
449
450
451/**
452 * Guest capabilities structure.
453 *
454 * Used by VMMDevReq_ReportGuestCapabilities.
455 */
456typedef struct
457{
458 /** Header. */
459 VMMDevRequestHeader header;
460 /** Capabilities (VMMDEV_GUEST_*). */
461 uint32_t caps;
462} VMMDevReqGuestCapabilities;
463AssertCompileSize(VMMDevReqGuestCapabilities, 24+4);
464
465/**
466 * Guest capabilities structure, version 2.
467 *
468 * Used by VMMDevReq_SetGuestCapabilities.
469 */
470typedef struct
471{
472 /** Header. */
473 VMMDevRequestHeader header;
474 /** Mask of capabilities to be added. */
475 uint32_t u32OrMask;
476 /** Mask of capabilities to be removed. */
477 uint32_t u32NotMask;
478} VMMDevReqGuestCapabilities2;
479AssertCompileSize(VMMDevReqGuestCapabilities2, 24+8);
480
481/** @name Guest capability bits.
482 * Used by VMMDevReq_ReportGuestCapabilities and VMMDevReq_SetGuestCapabilities.
483 * @{ */
484/** The guest supports seamless display rendering. */
485#define VMMDEV_GUEST_SUPPORTS_SEAMLESS RT_BIT_32(0)
486/** The guest supports mapping guest to host windows. */
487#define VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING RT_BIT_32(1)
488/** The guest graphical additions are active.
489 * Used for fast activation and deactivation of certain graphical operations
490 * (e.g. resizing & seamless). The legacy VMMDevReq_ReportGuestCapabilities
491 * request sets this automatically, but VMMDevReq_SetGuestCapabilities does
492 * not. */
493#define VMMDEV_GUEST_SUPPORTS_GRAPHICS RT_BIT_32(2)
494/** @} */
495
496
497/**
498 * Idle request structure.
499 *
500 * Used by VMMDevReq_Idle.
501 */
502typedef struct
503{
504 /** Header. */
505 VMMDevRequestHeader header;
506} VMMDevReqIdle;
507AssertCompileSize(VMMDevReqIdle, 24);
508
509
510/**
511 * Host time request structure.
512 *
513 * Used by VMMDevReq_GetHostTime.
514 */
515typedef struct
516{
517 /** Header */
518 VMMDevRequestHeader header;
519 /** OUT: Time in milliseconds since unix epoch. */
520 uint64_t time;
521} VMMDevReqHostTime;
522AssertCompileSize(VMMDevReqHostTime, 24+8);
523
524
525/**
526 * Hypervisor info structure.
527 *
528 * Used by VMMDevReq_GetHypervisorInfo and VMMDevReq_SetHypervisorInfo.
529 */
530typedef struct
531{
532 /** Header. */
533 VMMDevRequestHeader header;
534 /** Guest virtual address of proposed hypervisor start.
535 * Not used by VMMDevReq_GetHypervisorInfo.
536 * @todo Make this 64-bit compatible? */
537 RTGCPTR32 hypervisorStart;
538 /** Hypervisor size in bytes. */
539 uint32_t hypervisorSize;
540} VMMDevReqHypervisorInfo;
541AssertCompileSize(VMMDevReqHypervisorInfo, 24+8);
542
543/** @name Default patch memory size .
544 * Used by VMMDevReq_RegisterPatchMemory and VMMDevReq_DeregisterPatchMemory.
545 * @{ */
546#define VMMDEV_GUEST_DEFAULT_PATCHMEM_SIZE 8192
547/** @} */
548
549/**
550 * Patching memory structure. (locked executable & read-only page from the guest's perspective)
551 *
552 * Used by VMMDevReq_RegisterPatchMemory and VMMDevReq_DeregisterPatchMemory
553 */
554typedef struct
555{
556 /** Header. */
557 VMMDevRequestHeader header;
558 /** Guest virtual address of the patching page(s). */
559 RTGCPTR64 pPatchMem;
560 /** Patch page size in bytes. */
561 uint32_t cbPatchMem;
562} VMMDevReqPatchMemory;
563AssertCompileSize(VMMDevReqPatchMemory, 24+12);
564
565
566/**
567 * Guest power requests.
568 *
569 * See VMMDevReq_SetPowerStatus and VMMDevPowerStateRequest.
570 */
571typedef enum
572{
573 VMMDevPowerState_Invalid = 0,
574 VMMDevPowerState_Pause = 1,
575 VMMDevPowerState_PowerOff = 2,
576 VMMDevPowerState_SaveState = 3,
577 VMMDevPowerState_SizeHack = 0x7fffffff
578} VMMDevPowerState;
579AssertCompileSize(VMMDevPowerState, 4);
580
581/**
582 * VM power status structure.
583 *
584 * Used by VMMDevReq_SetPowerStatus.
585 */
586typedef struct
587{
588 /** Header. */
589 VMMDevRequestHeader header;
590 /** Power state request. */
591 VMMDevPowerState powerState;
592} VMMDevPowerStateRequest;
593AssertCompileSize(VMMDevPowerStateRequest, 24+4);
594
595
596/**
597 * Pending events structure.
598 *
599 * Used by VMMDevReq_AcknowledgeEvents.
600 */
601typedef struct
602{
603 /** Header. */
604 VMMDevRequestHeader header;
605 /** OUT: Pending event mask. */
606 uint32_t events;
607} VMMDevEvents;
608AssertCompileSize(VMMDevEvents, 24+4);
609
610
611/**
612 * Guest event filter mask control.
613 *
614 * Used by VMMDevReq_CtlGuestFilterMask.
615 */
616typedef struct
617{
618 /** Header. */
619 VMMDevRequestHeader header;
620 /** Mask of events to be added to the filter. */
621 uint32_t u32OrMask;
622 /** Mask of events to be removed from the filter. */
623 uint32_t u32NotMask;
624} VMMDevCtlGuestFilterMask;
625AssertCompileSize(VMMDevCtlGuestFilterMask, 24+8);
626
627
628/**
629 * Guest information structure.
630 *
631 * Used by VMMDevReportGuestInfo and PDMIVMMDEVCONNECTOR::pfnUpdateGuestVersion.
632 */
633typedef struct VBoxGuestInfo
634{
635 /** The VMMDev interface version expected by additions.
636 * *Deprecated*, do not use anymore! Will be removed. */
637 uint32_t interfaceVersion;
638 /** Guest OS type. */
639 VBOXOSTYPE osType;
640} VBoxGuestInfo;
641AssertCompileSize(VBoxGuestInfo, 8);
642
643/**
644 * Guest information report.
645 *
646 * Used by VMMDevReq_ReportGuestInfo.
647 */
648typedef struct
649{
650 /** Header. */
651 VMMDevRequestHeader header;
652 /** Guest information. */
653 VBoxGuestInfo guestInfo;
654} VMMDevReportGuestInfo;
655AssertCompileSize(VMMDevReportGuestInfo, 24+8);
656
657
658/**
659 * Guest information structure, version 2.
660 *
661 * Used by VMMDevReportGuestInfo2 and PDMIVMMDEVCONNECTOR::pfnUpdateGuestVersion2.
662 */
663typedef struct VBoxGuestInfo2
664{
665 /** Major version. */
666 uint16_t additionsMajor;
667 /** Minor version. */
668 uint16_t additionsMinor;
669 /** Build number. */
670 uint32_t additionsBuild;
671 /** SVN revision. */
672 uint32_t additionsRevision;
673 /** Feature mask, currently unused. */
674 uint32_t additionsFeatures;
675 /** The intentional meaning of this field was:
676 * Some additional information, for example 'Beta 1' or something like that.
677 *
678 * The way it was implemented was implemented: VBOX_VERSION_STRING.
679 *
680 * This means the first three members are duplicated in this field (if the guest
681 * build config is sane). So, the user must check this and chop it off before
682 * usage. There is, because of the Main code's blind trust in the field's
683 * content, no way back. */
684 char szName[128];
685} VBoxGuestInfo2;
686AssertCompileSize(VBoxGuestInfo2, 144);
687
688/**
689 * Guest information report, version 2.
690 *
691 * Used by VMMDevReq_ReportGuestInfo2.
692 */
693typedef struct
694{
695 /** Header. */
696 VMMDevRequestHeader header;
697 /** Guest information. */
698 VBoxGuestInfo2 guestInfo;
699} VMMDevReportGuestInfo2;
700AssertCompileSize(VMMDevReportGuestInfo2, 24+144);
701
702
703/**
704 * The guest facility.
705 * This needs to be kept in sync with AdditionsFacilityType of the Main API!
706 */
707typedef enum
708{
709 VBoxGuestFacilityType_Unknown = 0,
710 VBoxGuestFacilityType_VBoxGuestDriver = 20,
711 VBoxGuestFacilityType_VBoxService = 100,
712 VBoxGuestFacilityType_VBoxTrayClient = 101, /* VBoxTray (Windows), VBoxClient (Linux, Unix). */
713 VBoxGuestFacilityType_Seamless = 1000,
714 VBoxGuestFacilityType_Graphics = 1100,
715 VBoxGuestFacilityType_All = 0x7ffffffe,
716 VBoxGuestFacilityType_SizeHack = 0x7fffffff
717} VBoxGuestFacilityType;
718AssertCompileSize(VBoxGuestFacilityType, 4);
719
720
721/**
722 * The current guest status of a facility.
723 * This needs to be kept in sync with AdditionsFacilityStatus of the Main API!
724 */
725typedef enum
726{
727 VBoxGuestFacilityStatus_Inactive = 0,
728 VBoxGuestFacilityStatus_Paused = 1,
729 VBoxGuestFacilityStatus_PreInit = 20,
730 VBoxGuestFacilityStatus_Init = 30,
731 VBoxGuestFacilityStatus_Active = 50,
732 VBoxGuestFacilityStatus_Terminating = 100,
733 VBoxGuestFacilityStatus_Terminated = 101,
734 VBoxGuestFacilityStatus_Failed = 800,
735 VBoxGuestFacilityStatus_Unknown = 999,
736 VBoxGuestFacilityStatus_SizeHack = 0x7fffffff
737} VBoxGuestFacilityStatus;
738AssertCompileSize(VBoxGuestFacilityStatus, 4);
739
740
741/**
742 * The facility class.
743 * This needs to be kept in sync with AdditionsFacilityClass of the Main API!
744 */
745typedef enum
746{
747 VBoxGuestFacilityClass_None = 0,
748 VBoxGuestFacilityClass_Driver = 10,
749 VBoxGuestFacilityClass_Service = 30,
750 VBoxGuestFacilityClass_Program = 50,
751 VBoxGuestFacilityClass_Feature = 100,
752 VBoxGuestFacilityClass_ThirdParty = 999,
753 VBoxGuestFacilityClass_All = 0x7ffffffe,
754 VBoxGuestFacilityClass_SizeHack = 0x7fffffff
755} VBoxGuestFacilityClass;
756AssertCompileSize(VBoxGuestFacilityClass, 4);
757
758
759/**
760 * Guest status structure.
761 *
762 * Used by VMMDevReqGuestStatus.
763 */
764typedef struct VBoxGuestStatus
765{
766 /** Facility the status is indicated for. */
767 VBoxGuestFacilityType facility;
768 /** Current guest status. */
769 VBoxGuestFacilityStatus status;
770 /** Flags, not used at the moment. */
771 uint32_t flags;
772} VBoxGuestStatus;
773AssertCompileSize(VBoxGuestStatus, 12);
774
775/**
776 * Guest Additions status structure.
777 *
778 * Used by VMMDevReq_ReportGuestStatus.
779 */
780typedef struct
781{
782 /** Header. */
783 VMMDevRequestHeader header;
784 /** Guest information. */
785 VBoxGuestStatus guestStatus;
786} VMMDevReportGuestStatus;
787AssertCompileSize(VMMDevReportGuestStatus, 24+12);
788
789
790/**
791 * Guest statistics structure.
792 *
793 * Used by VMMDevReportGuestStats and PDMIVMMDEVCONNECTOR::pfnReportStatistics.
794 */
795typedef struct VBoxGuestStatistics
796{
797 /** Virtual CPU ID. */
798 uint32_t u32CpuId;
799 /** Reported statistics. */
800 uint32_t u32StatCaps;
801 /** Idle CPU load (0-100) for last interval. */
802 uint32_t u32CpuLoad_Idle;
803 /** Kernel CPU load (0-100) for last interval. */
804 uint32_t u32CpuLoad_Kernel;
805 /** User CPU load (0-100) for last interval. */
806 uint32_t u32CpuLoad_User;
807 /** Nr of threads. */
808 uint32_t u32Threads;
809 /** Nr of processes. */
810 uint32_t u32Processes;
811 /** Nr of handles. */
812 uint32_t u32Handles;
813 /** Memory load (0-100). */
814 uint32_t u32MemoryLoad;
815 /** Page size of guest system. */
816 uint32_t u32PageSize;
817 /** Total physical memory (in 4KB pages). */
818 uint32_t u32PhysMemTotal;
819 /** Available physical memory (in 4KB pages). */
820 uint32_t u32PhysMemAvail;
821 /** Ballooned physical memory (in 4KB pages). */
822 uint32_t u32PhysMemBalloon;
823 /** Total number of committed memory (which is not necessarily in-use) (in 4KB pages). */
824 uint32_t u32MemCommitTotal;
825 /** Total amount of memory used by the kernel (in 4KB pages). */
826 uint32_t u32MemKernelTotal;
827 /** Total amount of paged memory used by the kernel (in 4KB pages). */
828 uint32_t u32MemKernelPaged;
829 /** Total amount of nonpaged memory used by the kernel (in 4KB pages). */
830 uint32_t u32MemKernelNonPaged;
831 /** Total amount of memory used for the system cache (in 4KB pages). */
832 uint32_t u32MemSystemCache;
833 /** Pagefile size (in 4KB pages). */
834 uint32_t u32PageFileSize;
835} VBoxGuestStatistics;
836AssertCompileSize(VBoxGuestStatistics, 19*4);
837
838/** @name Guest statistics values (VBoxGuestStatistics::u32StatCaps).
839 * @{ */
840#define VBOX_GUEST_STAT_CPU_LOAD_IDLE RT_BIT(0)
841#define VBOX_GUEST_STAT_CPU_LOAD_KERNEL RT_BIT(1)
842#define VBOX_GUEST_STAT_CPU_LOAD_USER RT_BIT(2)
843#define VBOX_GUEST_STAT_THREADS RT_BIT(3)
844#define VBOX_GUEST_STAT_PROCESSES RT_BIT(4)
845#define VBOX_GUEST_STAT_HANDLES RT_BIT(5)
846#define VBOX_GUEST_STAT_MEMORY_LOAD RT_BIT(6)
847#define VBOX_GUEST_STAT_PHYS_MEM_TOTAL RT_BIT(7)
848#define VBOX_GUEST_STAT_PHYS_MEM_AVAIL RT_BIT(8)
849#define VBOX_GUEST_STAT_PHYS_MEM_BALLOON RT_BIT(9)
850#define VBOX_GUEST_STAT_MEM_COMMIT_TOTAL RT_BIT(10)
851#define VBOX_GUEST_STAT_MEM_KERNEL_TOTAL RT_BIT(11)
852#define VBOX_GUEST_STAT_MEM_KERNEL_PAGED RT_BIT(12)
853#define VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED RT_BIT(13)
854#define VBOX_GUEST_STAT_MEM_SYSTEM_CACHE RT_BIT(14)
855#define VBOX_GUEST_STAT_PAGE_FILE_SIZE RT_BIT(15)
856/** @} */
857
858/**
859 * Guest statistics command structure.
860 *
861 * Used by VMMDevReq_ReportGuestStats.
862 */
863typedef struct
864{
865 /** Header. */
866 VMMDevRequestHeader header;
867 /** Guest information. */
868 VBoxGuestStatistics guestStats;
869} VMMDevReportGuestStats;
870AssertCompileSize(VMMDevReportGuestStats, 24+19*4);
871
872
873/** Memory balloon change request structure. */
874#define VMMDEV_MAX_MEMORY_BALLOON(PhysMemTotal) ( (9 * (PhysMemTotal)) / 10 )
875
876/**
877 * Poll for ballooning change request.
878 *
879 * Used by VMMDevReq_GetMemBalloonChangeRequest.
880 */
881typedef struct
882{
883 /** Header. */
884 VMMDevRequestHeader header;
885 /** Balloon size in megabytes. */
886 uint32_t cBalloonChunks;
887 /** Guest ram size in megabytes. */
888 uint32_t cPhysMemChunks;
889 /** Setting this to VMMDEV_EVENT_BALLOON_CHANGE_REQUEST indicates that the
890 * request is a response to that event.
891 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
892 uint32_t eventAck;
893} VMMDevGetMemBalloonChangeRequest;
894AssertCompileSize(VMMDevGetMemBalloonChangeRequest, 24+12);
895
896
897/**
898 * Change the size of the balloon.
899 *
900 * Used by VMMDevReq_ChangeMemBalloon.
901 */
902typedef struct
903{
904 /** Header. */
905 VMMDevRequestHeader header;
906 /** The number of pages in the array. */
907 uint32_t cPages;
908 /** true = inflate, false = deflate. */
909 uint32_t fInflate;
910 /** Physical address (RTGCPHYS) of each page, variable size. */
911 RTGCPHYS aPhysPage[1];
912} VMMDevChangeMemBalloon;
913AssertCompileSize(VMMDevChangeMemBalloon, 24+16);
914
915/** @name The ballooning chunk size which VMMDev works at.
916 * @{ */
917#define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (_1M/4096)
918#define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE (VMMDEV_MEMORY_BALLOON_CHUNK_PAGES*4096)
919/** @} */
920
921
922/**
923 * Guest statistics interval change request structure.
924 *
925 * Used by VMMDevReq_GetStatisticsChangeRequest.
926 */
927typedef struct
928{
929 /** Header. */
930 VMMDevRequestHeader header;
931 /** The interval in seconds. */
932 uint32_t u32StatInterval;
933 /** Setting this to VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST indicates
934 * that the request is a response to that event.
935 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
936 uint32_t eventAck;
937} VMMDevGetStatisticsChangeRequest;
938AssertCompileSize(VMMDevGetStatisticsChangeRequest, 24+8);
939
940
941/** The size of a string field in the credentials request (including '\\0').
942 * @see VMMDevCredentials */
943#define VMMDEV_CREDENTIALS_SZ_SIZE 128
944
945/**
946 * Credentials request structure.
947 *
948 * Used by VMMDevReq_QueryCredentials.
949 */
950#pragma pack(4)
951typedef struct
952{
953 /** Header. */
954 VMMDevRequestHeader header;
955 /** IN/OUT: Request flags. */
956 uint32_t u32Flags;
957 /** OUT: User name (UTF-8). */
958 char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
959 /** OUT: Password (UTF-8). */
960 char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
961 /** OUT: Domain name (UTF-8). */
962 char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
963} VMMDevCredentials;
964AssertCompileSize(VMMDevCredentials, 24+4+3*128);
965#pragma pack()
966
967/** @name Credentials request flag (VMMDevCredentials::u32Flags)
968 * @{ */
969/** query from host whether credentials are present */
970#define VMMDEV_CREDENTIALS_QUERYPRESENCE RT_BIT(1)
971/** read credentials from host (can be combined with clear) */
972#define VMMDEV_CREDENTIALS_READ RT_BIT(2)
973/** clear credentials on host (can be combined with read) */
974#define VMMDEV_CREDENTIALS_CLEAR RT_BIT(3)
975/** read credentials for judgement in the guest */
976#define VMMDEV_CREDENTIALS_READJUDGE RT_BIT(8)
977/** clear credentials for judegement on the host */
978#define VMMDEV_CREDENTIALS_CLEARJUDGE RT_BIT(9)
979/** report credentials acceptance by guest */
980#define VMMDEV_CREDENTIALS_JUDGE_OK RT_BIT(10)
981/** report credentials denial by guest */
982#define VMMDEV_CREDENTIALS_JUDGE_DENY RT_BIT(11)
983/** report that no judgement could be made by guest */
984#define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT RT_BIT(12)
985
986/** flag telling the guest that credentials are present */
987#define VMMDEV_CREDENTIALS_PRESENT RT_BIT(16)
988/** flag telling guest that local logons should be prohibited */
989#define VMMDEV_CREDENTIALS_NOLOCALLOGON RT_BIT(17)
990/** @} */
991
992
993/**
994 * Seamless mode change request structure.
995 *
996 * Used by VMMDevReq_GetSeamlessChangeRequest.
997 */
998typedef struct
999{
1000 /** Header. */
1001 VMMDevRequestHeader header;
1002
1003 /** New seamless mode. */
1004 VMMDevSeamlessMode mode;
1005 /** Setting this to VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST indicates
1006 * that the request is a response to that event.
1007 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
1008 uint32_t eventAck;
1009} VMMDevSeamlessChangeRequest;
1010AssertCompileSize(VMMDevSeamlessChangeRequest, 24+8);
1011AssertCompileMemberOffset(VMMDevSeamlessChangeRequest, eventAck, 24+4);
1012
1013
1014/**
1015 * Display change request structure.
1016 *
1017 * Used by VMMDevReq_GetDisplayChangeRequest.
1018 */
1019typedef struct
1020{
1021 /** Header. */
1022 VMMDevRequestHeader header;
1023 /** Horizontal pixel resolution (0 = do not change). */
1024 uint32_t xres;
1025 /** Vertical pixel resolution (0 = do not change). */
1026 uint32_t yres;
1027 /** Bits per pixel (0 = do not change). */
1028 uint32_t bpp;
1029 /** Setting this to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST indicates
1030 * that the request is a response to that event.
1031 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
1032 uint32_t eventAck;
1033} VMMDevDisplayChangeRequest;
1034AssertCompileSize(VMMDevDisplayChangeRequest, 24+16);
1035
1036
1037/**
1038 * Display change request structure, version 2.
1039 *
1040 * Used by VMMDevReq_GetDisplayChangeRequest2.
1041 */
1042typedef struct
1043{
1044 /** Header. */
1045 VMMDevRequestHeader header;
1046 /** Horizontal pixel resolution (0 = do not change). */
1047 uint32_t xres;
1048 /** Vertical pixel resolution (0 = do not change). */
1049 uint32_t yres;
1050 /** Bits per pixel (0 = do not change). */
1051 uint32_t bpp;
1052 /** Setting this to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST indicates
1053 * that the request is a response to that event.
1054 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
1055 uint32_t eventAck;
1056 /** 0 for primary display, 1 for the first secondary, etc. */
1057 uint32_t display;
1058} VMMDevDisplayChangeRequest2;
1059AssertCompileSize(VMMDevDisplayChangeRequest2, 24+20);
1060
1061
1062/**
1063 * Video mode supported request structure.
1064 *
1065 * Used by VMMDevReq_VideoModeSupported.
1066 */
1067typedef struct
1068{
1069 /** Header. */
1070 VMMDevRequestHeader header;
1071 /** IN: Horizontal pixel resolution. */
1072 uint32_t width;
1073 /** IN: Vertical pixel resolution. */
1074 uint32_t height;
1075 /** IN: Bits per pixel. */
1076 uint32_t bpp;
1077 /** OUT: Support indicator. */
1078 bool fSupported;
1079} VMMDevVideoModeSupportedRequest;
1080AssertCompileSize(VMMDevVideoModeSupportedRequest, 24+16);
1081
1082/**
1083 * Video mode supported request structure for a specific display.
1084 *
1085 * Used by VMMDevReq_VideoModeSupported2.
1086 */
1087typedef struct
1088{
1089 /** Header. */
1090 VMMDevRequestHeader header;
1091 /** IN: The guest display number. */
1092 uint32_t display;
1093 /** IN: Horizontal pixel resolution. */
1094 uint32_t width;
1095 /** IN: Vertical pixel resolution. */
1096 uint32_t height;
1097 /** IN: Bits per pixel. */
1098 uint32_t bpp;
1099 /** OUT: Support indicator. */
1100 bool fSupported;
1101} VMMDevVideoModeSupportedRequest2;
1102AssertCompileSize(VMMDevVideoModeSupportedRequest2, 24+20);
1103
1104/**
1105 * Video modes height reduction request structure.
1106 *
1107 * Used by VMMDevReq_GetHeightReduction.
1108 */
1109typedef struct
1110{
1111 /** Header. */
1112 VMMDevRequestHeader header;
1113 /** OUT: Height reduction in pixels. */
1114 uint32_t heightReduction;
1115} VMMDevGetHeightReductionRequest;
1116AssertCompileSize(VMMDevGetHeightReductionRequest, 24+4);
1117
1118
1119/**
1120 * VRDP change request structure.
1121 *
1122 * Used by VMMDevReq_GetVRDPChangeRequest.
1123 */
1124typedef struct
1125{
1126 /** Header */
1127 VMMDevRequestHeader header;
1128 /** Whether VRDP is active or not. */
1129 uint8_t u8VRDPActive;
1130 /** The configured experience level for active VRDP. */
1131 uint32_t u32VRDPExperienceLevel;
1132} VMMDevVRDPChangeRequest;
1133AssertCompileSize(VMMDevVRDPChangeRequest, 24+8);
1134AssertCompileMemberOffset(VMMDevVRDPChangeRequest, u8VRDPActive, 24);
1135AssertCompileMemberOffset(VMMDevVRDPChangeRequest, u32VRDPExperienceLevel, 24+4);
1136
1137/** @name VRDP Experience level (VMMDevVRDPChangeRequest::u32VRDPExperienceLevel)
1138 * @{ */
1139#define VRDP_EXPERIENCE_LEVEL_ZERO 0 /**< Theming disabled. */
1140#define VRDP_EXPERIENCE_LEVEL_LOW 1 /**< Full window dragging and desktop wallpaper disabled. */
1141#define VRDP_EXPERIENCE_LEVEL_MEDIUM 2 /**< Font smoothing, gradients. */
1142#define VRDP_EXPERIENCE_LEVEL_HIGH 3 /**< Animation effects disabled. */
1143#define VRDP_EXPERIENCE_LEVEL_FULL 4 /**< Everything enabled. */
1144/** @} */
1145
1146
1147/**
1148 * VBVA enable request structure.
1149 *
1150 * Used by VMMDevReq_VideoAccelEnable.
1151 */
1152typedef struct
1153{
1154 /** Header. */
1155 VMMDevRequestHeader header;
1156 /** 0 - disable, !0 - enable. */
1157 uint32_t u32Enable;
1158 /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
1159 * The host will refuse to enable VBVA if the size is not equal to
1160 * VBVA_RING_BUFFER_SIZE.
1161 */
1162 uint32_t cbRingBuffer;
1163 /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
1164 uint32_t fu32Status;
1165} VMMDevVideoAccelEnable;
1166AssertCompileSize(VMMDevVideoAccelEnable, 24+12);
1167
1168/** @name VMMDevVideoAccelEnable::fu32Status.
1169 * @{ */
1170#define VBVA_F_STATUS_ACCEPTED (0x01)
1171#define VBVA_F_STATUS_ENABLED (0x02)
1172/** @} */
1173
1174
1175/**
1176 * VBVA flush request structure.
1177 *
1178 * Used by VMMDevReq_VideoAccelFlush.
1179 */
1180typedef struct
1181{
1182 /** Header. */
1183 VMMDevRequestHeader header;
1184} VMMDevVideoAccelFlush;
1185AssertCompileSize(VMMDevVideoAccelFlush, 24);
1186
1187
1188/**
1189 * VBVA set visible region request structure.
1190 *
1191 * Used by VMMDevReq_VideoSetVisibleRegion.
1192 */
1193typedef struct
1194{
1195 /** Header. */
1196 VMMDevRequestHeader header;
1197 /** Number of rectangles */
1198 uint32_t cRect;
1199 /** Rectangle array.
1200 * @todo array is spelled aRects[1]. */
1201 RTRECT Rect;
1202} VMMDevVideoSetVisibleRegion;
1203AssertCompileSize(RTRECT, 16);
1204AssertCompileSize(VMMDevVideoSetVisibleRegion, 24+4+16);
1205
1206/**
1207 * CPU event types.
1208 */
1209typedef enum
1210{
1211 VMMDevCpuStatusType_Invalid = 0,
1212 VMMDevCpuStatusType_Disable = 1,
1213 VMMDevCpuStatusType_Enable = 2,
1214 VMMDevCpuStatusType_SizeHack = 0x7fffffff
1215} VMMDevCpuStatusType;
1216
1217/**
1218 * CPU hotplug event status request.
1219 */
1220typedef struct
1221{
1222 /** Header. */
1223 VMMDevRequestHeader header;
1224 /** Status type */
1225 VMMDevCpuStatusType enmStatusType;
1226} VMMDevCpuHotPlugStatusRequest;
1227AssertCompileSize(VMMDevCpuHotPlugStatusRequest, 24+4);
1228
1229/**
1230 * Get the ID of the changed CPU and event type.
1231 */
1232typedef struct
1233{
1234 /** Header. */
1235 VMMDevRequestHeader header;
1236 /** Event type */
1237 VMMDevCpuEventType enmEventType;
1238 /** core id of the CPU changed */
1239 uint32_t idCpuCore;
1240 /** package id of the CPU changed */
1241 uint32_t idCpuPackage;
1242} VMMDevGetCpuHotPlugRequest;
1243AssertCompileSize(VMMDevGetCpuHotPlugRequest, 24+4+4+4);
1244
1245
1246/**
1247 * Shared region description
1248 */
1249typedef struct
1250{
1251 RTGCPTR64 GCRegionAddr;
1252 uint32_t cbRegion;
1253 uint32_t u32Alignment;
1254} VMMDEVSHAREDREGIONDESC;
1255AssertCompileSize(VMMDEVSHAREDREGIONDESC, 16);
1256
1257#define VMMDEVSHAREDREGIONDESC_MAX 32
1258
1259/**
1260 * Shared module registration
1261 */
1262typedef struct
1263{
1264 /** Header. */
1265 VMMDevRequestHeader header;
1266 /** Shared module size. */
1267 uint32_t cbModule;
1268 /** Number of included region descriptors */
1269 uint32_t cRegions;
1270 /** Base address of the shared module. */
1271 RTGCPTR64 GCBaseAddr;
1272 /** Guest OS type. */
1273 VBOXOSFAMILY enmGuestOS;
1274 /** Alignment. */
1275 uint32_t u32Align;
1276 /** Module name */
1277 char szName[128];
1278 /** Module version */
1279 char szVersion[16];
1280 /** Shared region descriptor(s). */
1281 VMMDEVSHAREDREGIONDESC aRegions[1];
1282} VMMDevSharedModuleRegistrationRequest;
1283AssertCompileSize(VMMDevSharedModuleRegistrationRequest, 24+4+4+8+4+4+128+16+16);
1284
1285
1286/**
1287 * Shared module unregistration
1288 */
1289typedef struct
1290{
1291 /** Header. */
1292 VMMDevRequestHeader header;
1293 /** Shared module size. */
1294 uint32_t cbModule;
1295 /** Align at 8 byte boundary. */
1296 uint32_t u32Alignment;
1297 /** Base address of the shared module. */
1298 RTGCPTR64 GCBaseAddr;
1299 /** Module name */
1300 char szName[128];
1301 /** Module version */
1302 char szVersion[16];
1303} VMMDevSharedModuleUnregistrationRequest;
1304AssertCompileSize(VMMDevSharedModuleUnregistrationRequest, 24+4+4+8+128+16);
1305
1306
1307/**
1308 * Shared module periodic check
1309 */
1310typedef struct
1311{
1312 /** Header. */
1313 VMMDevRequestHeader header;
1314} VMMDevSharedModuleCheckRequest;
1315AssertCompileSize(VMMDevSharedModuleCheckRequest, 24);
1316
1317/**
1318 * Paging sharing enabled query
1319 */
1320typedef struct
1321{
1322 /** Header. */
1323 VMMDevRequestHeader header;
1324 /** Enabled flag (out) */
1325 bool fEnabled;
1326 /** Alignment */
1327 bool fAlignment[3];
1328} VMMDevPageSharingStatusRequest;
1329AssertCompileSize(VMMDevPageSharingStatusRequest, 24+4);
1330
1331
1332/**
1333 * Page sharing status query (debug build only)
1334 */
1335typedef struct
1336{
1337 /** Header. */
1338 VMMDevRequestHeader header;
1339 /** Page address. */
1340 RTGCPTR GCPtrPage;
1341 /** Page flags. */
1342 uint64_t uPageFlags;
1343 /** Shared flag (out) */
1344 bool fShared;
1345 /** Alignment */
1346 bool fAlignment[3];
1347} VMMDevPageIsSharedRequest;
1348
1349/**
1350 * Session id request structure.
1351 *
1352 * Used by VMMDevReq_GetSessionId.
1353 */
1354typedef struct
1355{
1356 /** Header */
1357 VMMDevRequestHeader header;
1358 /** OUT: unique session id; the id will be different after each start, reset or restore of the VM */
1359 uint64_t idSession;
1360} VMMDevReqSessionId;
1361AssertCompileSize(VMMDevReqSessionId, 24+8);
1362
1363
1364/**
1365 * Write Core Dump request.
1366 *
1367 * Used by VMMDevReq_WriteCoreDump.
1368 */
1369typedef struct
1370{
1371 /** Header. */
1372 VMMDevRequestHeader header;
1373 /** Flags (reserved, MBZ). */
1374 uint32_t fFlags;
1375} VMMDevReqWriteCoreDump;
1376AssertCompileSize(VMMDevReqWriteCoreDump, 24+4);
1377
1378
1379#pragma pack()
1380
1381
1382#ifdef VBOX_WITH_HGCM
1383
1384/** @name HGCM flags.
1385 * @{
1386 */
1387# define VBOX_HGCM_REQ_DONE RT_BIT_32(VBOX_HGCM_REQ_DONE_BIT)
1388# define VBOX_HGCM_REQ_DONE_BIT 0
1389# define VBOX_HGCM_REQ_CANCELLED (0x2)
1390/** @} */
1391
1392# pragma pack(4)
1393
1394/**
1395 * HGCM request header.
1396 */
1397typedef struct VMMDevHGCMRequestHeader
1398{
1399 /** Request header. */
1400 VMMDevRequestHeader header;
1401
1402 /** HGCM flags. */
1403 uint32_t fu32Flags;
1404
1405 /** Result code. */
1406 int32_t result;
1407} VMMDevHGCMRequestHeader;
1408AssertCompileSize(VMMDevHGCMRequestHeader, 24+8);
1409
1410/**
1411 * HGCM connect request structure.
1412 *
1413 * Used by VMMDevReq_HGCMConnect.
1414 */
1415typedef struct
1416{
1417 /** HGCM request header. */
1418 VMMDevHGCMRequestHeader header;
1419
1420 /** IN: Description of service to connect to. */
1421 HGCMServiceLocation loc;
1422
1423 /** OUT: Client identifier assigned by local instance of HGCM. */
1424 uint32_t u32ClientID;
1425} VMMDevHGCMConnect;
1426AssertCompileSize(VMMDevHGCMConnect, 32+132+4);
1427
1428
1429/**
1430 * HGCM disconnect request structure.
1431 *
1432 * Used by VMMDevReq_HGCMDisconnect.
1433 */
1434typedef struct
1435{
1436 /** HGCM request header. */
1437 VMMDevHGCMRequestHeader header;
1438
1439 /** IN: Client identifier. */
1440 uint32_t u32ClientID;
1441} VMMDevHGCMDisconnect;
1442AssertCompileSize(VMMDevHGCMDisconnect, 32+4);
1443
1444/**
1445 * HGCM parameter type.
1446 */
1447typedef enum
1448{
1449 VMMDevHGCMParmType_Invalid = 0,
1450 VMMDevHGCMParmType_32bit = 1,
1451 VMMDevHGCMParmType_64bit = 2,
1452 VMMDevHGCMParmType_PhysAddr = 3, /**< @deprecated Doesn't work, use PageList. */
1453 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
1454 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */
1455 VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */
1456 VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */
1457 VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */
1458 VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */
1459 VMMDevHGCMParmType_PageList = 10, /**< Physical addresses of locked pages for a buffer. */
1460 VMMDevHGCMParmType_SizeHack = 0x7fffffff
1461} HGCMFunctionParameterType;
1462AssertCompileSize(HGCMFunctionParameterType, 4);
1463
1464# ifdef VBOX_WITH_64_BITS_GUESTS
1465/**
1466 * HGCM function parameter, 32-bit client.
1467 */
1468typedef struct
1469{
1470 HGCMFunctionParameterType type;
1471 union
1472 {
1473 uint32_t value32;
1474 uint64_t value64;
1475 struct
1476 {
1477 uint32_t size;
1478
1479 union
1480 {
1481 RTGCPHYS32 physAddr;
1482 RTGCPTR32 linearAddr;
1483 } u;
1484 } Pointer;
1485 struct
1486 {
1487 uint32_t size; /**< Size of the buffer described by the page list. */
1488 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1489 } PageList;
1490 } u;
1491# ifdef __cplusplus
1492 void SetUInt32(uint32_t u32)
1493 {
1494 type = VMMDevHGCMParmType_32bit;
1495 u.value64 = 0; /* init unused bits to 0 */
1496 u.value32 = u32;
1497 }
1498
1499 int GetUInt32(uint32_t *pu32)
1500 {
1501 if (type == VMMDevHGCMParmType_32bit)
1502 {
1503 *pu32 = u.value32;
1504 return VINF_SUCCESS;
1505 }
1506 return VERR_INVALID_PARAMETER;
1507 }
1508
1509 void SetUInt64(uint64_t u64)
1510 {
1511 type = VMMDevHGCMParmType_64bit;
1512 u.value64 = u64;
1513 }
1514
1515 int GetUInt64(uint64_t *pu64)
1516 {
1517 if (type == VMMDevHGCMParmType_64bit)
1518 {
1519 *pu64 = u.value64;
1520 return VINF_SUCCESS;
1521 }
1522 return VERR_INVALID_PARAMETER;
1523 }
1524
1525 void SetPtr(void *pv, uint32_t cb)
1526 {
1527 type = VMMDevHGCMParmType_LinAddr;
1528 u.Pointer.size = cb;
1529 u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv;
1530 }
1531# endif /* __cplusplus */
1532} HGCMFunctionParameter32;
1533AssertCompileSize(HGCMFunctionParameter32, 4+8);
1534
1535/**
1536 * HGCM function parameter, 64-bit client.
1537 */
1538typedef struct
1539{
1540 HGCMFunctionParameterType type;
1541 union
1542 {
1543 uint32_t value32;
1544 uint64_t value64;
1545 struct
1546 {
1547 uint32_t size;
1548
1549 union
1550 {
1551 RTGCPHYS64 physAddr;
1552 RTGCPTR64 linearAddr;
1553 } u;
1554 } Pointer;
1555 struct
1556 {
1557 uint32_t size; /**< Size of the buffer described by the page list. */
1558 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1559 } PageList;
1560 } u;
1561# ifdef __cplusplus
1562 void SetUInt32(uint32_t u32)
1563 {
1564 type = VMMDevHGCMParmType_32bit;
1565 u.value64 = 0; /* init unused bits to 0 */
1566 u.value32 = u32;
1567 }
1568
1569 int GetUInt32(uint32_t *pu32)
1570 {
1571 if (type == VMMDevHGCMParmType_32bit)
1572 {
1573 *pu32 = u.value32;
1574 return VINF_SUCCESS;
1575 }
1576 return VERR_INVALID_PARAMETER;
1577 }
1578
1579 void SetUInt64(uint64_t u64)
1580 {
1581 type = VMMDevHGCMParmType_64bit;
1582 u.value64 = u64;
1583 }
1584
1585 int GetUInt64(uint64_t *pu64)
1586 {
1587 if (type == VMMDevHGCMParmType_64bit)
1588 {
1589 *pu64 = u.value64;
1590 return VINF_SUCCESS;
1591 }
1592 return VERR_INVALID_PARAMETER;
1593 }
1594
1595 void SetPtr(void *pv, uint32_t cb)
1596 {
1597 type = VMMDevHGCMParmType_LinAddr;
1598 u.Pointer.size = cb;
1599 u.Pointer.u.linearAddr = (uintptr_t)pv;
1600 }
1601# endif /** __cplusplus */
1602} HGCMFunctionParameter64;
1603AssertCompileSize(HGCMFunctionParameter64, 4+12);
1604
1605/* Redefine the structure type for the guest code. */
1606# ifndef VBOX_HGCM_HOST_CODE
1607# if ARCH_BITS == 64
1608# define HGCMFunctionParameter HGCMFunctionParameter64
1609# elif ARCH_BITS == 32
1610# define HGCMFunctionParameter HGCMFunctionParameter32
1611# else
1612# error "Unsupported sizeof (void *)"
1613# endif
1614# endif /* !VBOX_HGCM_HOST_CODE */
1615
1616# else /* !VBOX_WITH_64_BITS_GUESTS */
1617
1618/**
1619 * HGCM function parameter, 32-bit client.
1620 *
1621 * @todo If this is the same as HGCMFunctionParameter32, why the duplication?
1622 */
1623typedef struct
1624{
1625 HGCMFunctionParameterType type;
1626 union
1627 {
1628 uint32_t value32;
1629 uint64_t value64;
1630 struct
1631 {
1632 uint32_t size;
1633
1634 union
1635 {
1636 RTGCPHYS32 physAddr;
1637 RTGCPTR32 linearAddr;
1638 } u;
1639 } Pointer;
1640 struct
1641 {
1642 uint32_t size; /**< Size of the buffer described by the page list. */
1643 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1644 } PageList;
1645 } u;
1646# ifdef __cplusplus
1647 void SetUInt32(uint32_t u32)
1648 {
1649 type = VMMDevHGCMParmType_32bit;
1650 u.value64 = 0; /* init unused bits to 0 */
1651 u.value32 = u32;
1652 }
1653
1654 int GetUInt32(uint32_t *pu32)
1655 {
1656 if (type == VMMDevHGCMParmType_32bit)
1657 {
1658 *pu32 = u.value32;
1659 return VINF_SUCCESS;
1660 }
1661 return VERR_INVALID_PARAMETER;
1662 }
1663
1664 void SetUInt64(uint64_t u64)
1665 {
1666 type = VMMDevHGCMParmType_64bit;
1667 u.value64 = u64;
1668 }
1669
1670 int GetUInt64(uint64_t *pu64)
1671 {
1672 if (type == VMMDevHGCMParmType_64bit)
1673 {
1674 *pu64 = u.value64;
1675 return VINF_SUCCESS;
1676 }
1677 return VERR_INVALID_PARAMETER;
1678 }
1679
1680 void SetPtr(void *pv, uint32_t cb)
1681 {
1682 type = VMMDevHGCMParmType_LinAddr;
1683 u.Pointer.size = cb;
1684 u.Pointer.u.linearAddr = (uintptr_t)pv;
1685 }
1686# endif /* __cplusplus */
1687} HGCMFunctionParameter;
1688AssertCompileSize(HGCMFunctionParameter, 4+8);
1689# endif /* !VBOX_WITH_64_BITS_GUESTS */
1690
1691/**
1692 * HGCM call request structure.
1693 *
1694 * Used by VMMDevReq_HGCMCall, VMMDevReq_HGCMCall32 and VMMDevReq_HGCMCall64.
1695 */
1696typedef struct
1697{
1698 /* request header */
1699 VMMDevHGCMRequestHeader header;
1700
1701 /** IN: Client identifier. */
1702 uint32_t u32ClientID;
1703 /** IN: Service function number. */
1704 uint32_t u32Function;
1705 /** IN: Number of parameters. */
1706 uint32_t cParms;
1707 /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
1708} VMMDevHGCMCall;
1709AssertCompileSize(VMMDevHGCMCall, 32+12);
1710
1711/** @name Direction of data transfer (HGCMPageListInfo::flags). Bit flags.
1712 * @{ */
1713#define VBOX_HGCM_F_PARM_DIRECTION_NONE UINT32_C(0x00000000)
1714#define VBOX_HGCM_F_PARM_DIRECTION_TO_HOST UINT32_C(0x00000001)
1715#define VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST UINT32_C(0x00000002)
1716#define VBOX_HGCM_F_PARM_DIRECTION_BOTH UINT32_C(0x00000003)
1717/** Macro for validating that the specified flags are valid. */
1718#define VBOX_HGCM_F_PARM_ARE_VALID(fFlags) \
1719 ( (fFlags) > VBOX_HGCM_F_PARM_DIRECTION_NONE \
1720 && (fFlags) < VBOX_HGCM_F_PARM_DIRECTION_BOTH )
1721/** @} */
1722
1723/**
1724 * VMMDevHGCMParmType_PageList points to this structure to actually describe the
1725 * buffer.
1726 */
1727typedef struct
1728{
1729 uint32_t flags; /**< VBOX_HGCM_F_PARM_*. */
1730 uint16_t offFirstPage; /**< Offset in the first page where data begins. */
1731 uint16_t cPages; /**< Number of pages. */
1732 RTGCPHYS64 aPages[1]; /**< Page addresses. */
1733} HGCMPageListInfo;
1734AssertCompileSize(HGCMPageListInfo, 4+2+2+8);
1735
1736# pragma pack()
1737
1738/** Get the pointer to the first parmater of a HGCM call request. */
1739# define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1740/** Get the pointer to the first parmater of a 32-bit HGCM call request. */
1741# define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1742
1743# ifdef VBOX_WITH_64_BITS_GUESTS
1744/* Explicit defines for the host code. */
1745# ifdef VBOX_HGCM_HOST_CODE
1746# define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1747# define VMMDEV_HGCM_CALL_PARMS64(a) ((HGCMFunctionParameter64 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1748# endif /* VBOX_HGCM_HOST_CODE */
1749# endif /* VBOX_WITH_64_BITS_GUESTS */
1750
1751# define VBOX_HGCM_MAX_PARMS 32
1752
1753/**
1754 * HGCM cancel request structure.
1755 *
1756 * The Cancel request is issued using the same physical memory address as was
1757 * used for the corresponding initial HGCMCall.
1758 *
1759 * Used by VMMDevReq_HGCMCancel.
1760 */
1761typedef struct
1762{
1763 /** Header. */
1764 VMMDevHGCMRequestHeader header;
1765} VMMDevHGCMCancel;
1766AssertCompileSize(VMMDevHGCMCancel, 32);
1767
1768/**
1769 * HGCM cancel request structure, version 2.
1770 *
1771 * Used by VMMDevReq_HGCMCancel2.
1772 *
1773 * VINF_SUCCESS when cancelled.
1774 * VERR_NOT_FOUND if the specified request cannot be found.
1775 * VERR_INVALID_PARAMETER if the address is invalid valid.
1776 */
1777typedef struct
1778{
1779 /** Header. */
1780 VMMDevRequestHeader header;
1781 /** The physical address of the request to cancel. */
1782 RTGCPHYS32 physReqToCancel;
1783} VMMDevHGCMCancel2;
1784AssertCompileSize(VMMDevHGCMCancel2, 24+4);
1785
1786#endif /* VBOX_WITH_HGCM */
1787
1788
1789/**
1790 * Inline helper to determine the request size for the given operation.
1791 *
1792 * @returns Size.
1793 * @param requestType The VMMDev request type.
1794 */
1795DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
1796{
1797 switch (requestType)
1798 {
1799 case VMMDevReq_GetMouseStatus:
1800 case VMMDevReq_SetMouseStatus:
1801 return sizeof(VMMDevReqMouseStatus);
1802 case VMMDevReq_SetPointerShape:
1803 return sizeof(VMMDevReqMousePointer);
1804 case VMMDevReq_GetHostVersion:
1805 return sizeof(VMMDevReqHostVersion);
1806 case VMMDevReq_Idle:
1807 return sizeof(VMMDevReqIdle);
1808 case VMMDevReq_GetHostTime:
1809 return sizeof(VMMDevReqHostTime);
1810 case VMMDevReq_GetHypervisorInfo:
1811 case VMMDevReq_SetHypervisorInfo:
1812 return sizeof(VMMDevReqHypervisorInfo);
1813 case VMMDevReq_RegisterPatchMemory:
1814 case VMMDevReq_DeregisterPatchMemory:
1815 return sizeof(VMMDevReqPatchMemory);
1816 case VMMDevReq_SetPowerStatus:
1817 return sizeof(VMMDevPowerStateRequest);
1818 case VMMDevReq_AcknowledgeEvents:
1819 return sizeof(VMMDevEvents);
1820 case VMMDevReq_ReportGuestInfo:
1821 return sizeof(VMMDevReportGuestInfo);
1822 case VMMDevReq_ReportGuestInfo2:
1823 return sizeof(VMMDevReportGuestInfo2);
1824 case VMMDevReq_ReportGuestStatus:
1825 return sizeof(VMMDevReportGuestStatus);
1826 case VMMDevReq_GetDisplayChangeRequest:
1827 return sizeof(VMMDevDisplayChangeRequest);
1828 case VMMDevReq_GetDisplayChangeRequest2:
1829 return sizeof(VMMDevDisplayChangeRequest2);
1830 case VMMDevReq_VideoModeSupported:
1831 return sizeof(VMMDevVideoModeSupportedRequest);
1832 case VMMDevReq_GetHeightReduction:
1833 return sizeof(VMMDevGetHeightReductionRequest);
1834 case VMMDevReq_ReportGuestCapabilities:
1835 return sizeof(VMMDevReqGuestCapabilities);
1836 case VMMDevReq_SetGuestCapabilities:
1837 return sizeof(VMMDevReqGuestCapabilities2);
1838#ifdef VBOX_WITH_HGCM
1839 case VMMDevReq_HGCMConnect:
1840 return sizeof(VMMDevHGCMConnect);
1841 case VMMDevReq_HGCMDisconnect:
1842 return sizeof(VMMDevHGCMDisconnect);
1843#ifdef VBOX_WITH_64_BITS_GUESTS
1844 case VMMDevReq_HGCMCall32:
1845 return sizeof(VMMDevHGCMCall);
1846 case VMMDevReq_HGCMCall64:
1847 return sizeof(VMMDevHGCMCall);
1848#else
1849 case VMMDevReq_HGCMCall:
1850 return sizeof(VMMDevHGCMCall);
1851#endif /* VBOX_WITH_64_BITS_GUESTS */
1852 case VMMDevReq_HGCMCancel:
1853 return sizeof(VMMDevHGCMCancel);
1854#endif /* VBOX_WITH_HGCM */
1855 case VMMDevReq_VideoAccelEnable:
1856 return sizeof(VMMDevVideoAccelEnable);
1857 case VMMDevReq_VideoAccelFlush:
1858 return sizeof(VMMDevVideoAccelFlush);
1859 case VMMDevReq_VideoSetVisibleRegion:
1860 /* The original protocol didn't consider a guest with NO visible
1861 * windows */
1862 return sizeof(VMMDevVideoSetVisibleRegion) - sizeof(RTRECT);
1863 case VMMDevReq_GetSeamlessChangeRequest:
1864 return sizeof(VMMDevSeamlessChangeRequest);
1865 case VMMDevReq_QueryCredentials:
1866 return sizeof(VMMDevCredentials);
1867 case VMMDevReq_ReportGuestStats:
1868 return sizeof(VMMDevReportGuestStats);
1869 case VMMDevReq_GetMemBalloonChangeRequest:
1870 return sizeof(VMMDevGetMemBalloonChangeRequest);
1871 case VMMDevReq_GetStatisticsChangeRequest:
1872 return sizeof(VMMDevGetStatisticsChangeRequest);
1873 case VMMDevReq_ChangeMemBalloon:
1874 return sizeof(VMMDevChangeMemBalloon);
1875 case VMMDevReq_GetVRDPChangeRequest:
1876 return sizeof(VMMDevVRDPChangeRequest);
1877 case VMMDevReq_LogString:
1878 return sizeof(VMMDevReqLogString);
1879 case VMMDevReq_CtlGuestFilterMask:
1880 return sizeof(VMMDevCtlGuestFilterMask);
1881 case VMMDevReq_GetCpuHotPlugRequest:
1882 return sizeof(VMMDevGetCpuHotPlugRequest);
1883 case VMMDevReq_SetCpuHotPlugStatus:
1884 return sizeof(VMMDevCpuHotPlugStatusRequest);
1885 case VMMDevReq_RegisterSharedModule:
1886 return sizeof(VMMDevSharedModuleRegistrationRequest);
1887 case VMMDevReq_UnregisterSharedModule:
1888 return sizeof(VMMDevSharedModuleUnregistrationRequest);
1889 case VMMDevReq_CheckSharedModules:
1890 return sizeof(VMMDevSharedModuleCheckRequest);
1891 case VMMDevReq_GetPageSharingStatus:
1892 return sizeof(VMMDevPageSharingStatusRequest);
1893 case VMMDevReq_DebugIsPageShared:
1894 return sizeof(VMMDevPageIsSharedRequest);
1895 case VMMDevReq_GetSessionId:
1896 return sizeof(VMMDevReqSessionId);
1897 default:
1898 return 0;
1899 }
1900}
1901
1902
1903/**
1904 * Initializes a request structure.
1905 *
1906 * @returns VBox status code.
1907 * @param req The request structure to initialize.
1908 * @param type The request type.
1909 */
1910DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
1911{
1912 uint32_t requestSize;
1913 if (!req)
1914 return VERR_INVALID_PARAMETER;
1915 requestSize = (uint32_t)vmmdevGetRequestSize(type);
1916 if (!requestSize)
1917 return VERR_INVALID_PARAMETER;
1918 req->size = requestSize;
1919 req->version = VMMDEV_REQUEST_HEADER_VERSION;
1920 req->requestType = type;
1921 req->rc = VERR_GENERAL_FAILURE;
1922 req->reserved1 = 0;
1923 req->reserved2 = 0;
1924 return VINF_SUCCESS;
1925}
1926
1927/** @} */
1928
1929
1930/**
1931 * VBVA command header.
1932 *
1933 * @todo Where does this fit in?
1934 */
1935#pragma pack(1) /* unnecessary */
1936typedef struct VBVACMDHDR
1937{
1938 /** Coordinates of affected rectangle. */
1939 int16_t x;
1940 int16_t y;
1941 uint16_t w;
1942 uint16_t h;
1943} VBVACMDHDR;
1944#pragma pack()
1945
1946/** @name VBVA ring defines.
1947 *
1948 * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of
1949 * data. For example big bitmaps which do not fit to the buffer.
1950 *
1951 * Guest starts writing to the buffer by initializing a record entry in the
1952 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
1953 * written. As data is written to the ring buffer, the guest increases off32End
1954 * for the record.
1955 *
1956 * The host reads the aRecords on flushes and processes all completed records.
1957 * When host encounters situation when only a partial record presents and
1958 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE -
1959 * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates
1960 * off32Head. After that on each flush the host continues fetching the data
1961 * until the record is completed.
1962 *
1963 */
1964#define VBVA_RING_BUFFER_SIZE (_4M - _1K)
1965#define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
1966
1967#define VBVA_MAX_RECORDS (64)
1968
1969#define VBVA_F_MODE_ENABLED (0x00000001)
1970#define VBVA_F_MODE_VRDP (0x00000002)
1971#define VBVA_F_MODE_VRDP_RESET (0x00000004)
1972#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
1973
1974#define VBVA_F_RECORD_PARTIAL (0x80000000)
1975/** @} */
1976
1977/**
1978 * VBVA record.
1979 */
1980typedef struct VBVARECORD
1981{
1982 /** The length of the record. Changed by guest. */
1983 uint32_t cbRecord;
1984} VBVARECORD;
1985AssertCompileSize(VBVARECORD, 4);
1986
1987
1988/**
1989 * VBVA memory layout.
1990 *
1991 * This is a subsection of the VMMDevMemory structure.
1992 */
1993#pragma pack(1) /* paranoia */
1994typedef struct VBVAMEMORY
1995{
1996 /** VBVA_F_MODE_*. */
1997 uint32_t fu32ModeFlags;
1998
1999 /** The offset where the data start in the buffer. */
2000 uint32_t off32Data;
2001 /** The offset where next data must be placed in the buffer. */
2002 uint32_t off32Free;
2003
2004 /** The ring buffer for data. */
2005 uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
2006
2007 /** The queue of record descriptions. */
2008 VBVARECORD aRecords[VBVA_MAX_RECORDS];
2009 uint32_t indexRecordFirst;
2010 uint32_t indexRecordFree;
2011
2012 /** RDP orders supported by the client. The guest reports only them
2013 * and falls back to DIRTY rects for not supported ones.
2014 *
2015 * (1 << VBVA_VRDP_*)
2016 */
2017 uint32_t fu32SupportedOrders;
2018
2019} VBVAMEMORY;
2020#pragma pack()
2021AssertCompileSize(VBVAMEMORY, 12 + (_4M-_1K) + 4*64 + 12);
2022
2023
2024/**
2025 * The layout of VMMDEV RAM region that contains information for guest.
2026 */
2027#pragma pack(1) /* paranoia */
2028typedef struct VMMDevMemory
2029{
2030 /** The size of this structure. */
2031 uint32_t u32Size;
2032 /** The structure version. (VMMDEV_MEMORY_VERSION) */
2033 uint32_t u32Version;
2034
2035 union
2036 {
2037 struct
2038 {
2039 /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
2040 bool fHaveEvents;
2041 } V1_04;
2042
2043 struct
2044 {
2045 /** Pending events flags, set by host. */
2046 uint32_t u32HostEvents;
2047 /** Mask of events the guest wants to see, set by guest. */
2048 uint32_t u32GuestEventMask;
2049 } V1_03;
2050 } V;
2051
2052 VBVAMEMORY vbvaMemory;
2053
2054} VMMDevMemory;
2055AssertCompileSize(VMMDevMemory, 8+8 + (12 + (_4M-_1K) + 4*64 + 12) );
2056#pragma pack()
2057
2058/** Version of VMMDevMemory structure (VMMDevMemory::u32Version). */
2059#define VMMDEV_MEMORY_VERSION (1)
2060
2061/** @} */
2062RT_C_DECLS_END
2063
2064#endif
2065
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette