VirtualBox

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

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

VMMDev: Added facility for auto-logon modules.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 61.8 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_AutoLogon = 90, /* VBoxGINA / VBoxCredProv / pam_vbox. */
712 VBoxGuestFacilityType_VBoxService = 100,
713 VBoxGuestFacilityType_VBoxTrayClient = 101, /* VBoxTray (Windows), VBoxClient (Linux, Unix). */
714 VBoxGuestFacilityType_Seamless = 1000,
715 VBoxGuestFacilityType_Graphics = 1100,
716 VBoxGuestFacilityType_All = 0x7ffffffe,
717 VBoxGuestFacilityType_SizeHack = 0x7fffffff
718} VBoxGuestFacilityType;
719AssertCompileSize(VBoxGuestFacilityType, 4);
720
721
722/**
723 * The current guest status of a facility.
724 * This needs to be kept in sync with AdditionsFacilityStatus of the Main API!
725 */
726typedef enum
727{
728 VBoxGuestFacilityStatus_Inactive = 0,
729 VBoxGuestFacilityStatus_Paused = 1,
730 VBoxGuestFacilityStatus_PreInit = 20,
731 VBoxGuestFacilityStatus_Init = 30,
732 VBoxGuestFacilityStatus_Active = 50,
733 VBoxGuestFacilityStatus_Terminating = 100,
734 VBoxGuestFacilityStatus_Terminated = 101,
735 VBoxGuestFacilityStatus_Failed = 800,
736 VBoxGuestFacilityStatus_Unknown = 999,
737 VBoxGuestFacilityStatus_SizeHack = 0x7fffffff
738} VBoxGuestFacilityStatus;
739AssertCompileSize(VBoxGuestFacilityStatus, 4);
740
741
742/**
743 * The facility class.
744 * This needs to be kept in sync with AdditionsFacilityClass of the Main API!
745 */
746typedef enum
747{
748 VBoxGuestFacilityClass_None = 0,
749 VBoxGuestFacilityClass_Driver = 10,
750 VBoxGuestFacilityClass_Service = 30,
751 VBoxGuestFacilityClass_Program = 50,
752 VBoxGuestFacilityClass_Feature = 100,
753 VBoxGuestFacilityClass_ThirdParty = 999,
754 VBoxGuestFacilityClass_All = 0x7ffffffe,
755 VBoxGuestFacilityClass_SizeHack = 0x7fffffff
756} VBoxGuestFacilityClass;
757AssertCompileSize(VBoxGuestFacilityClass, 4);
758
759
760/**
761 * Guest status structure.
762 *
763 * Used by VMMDevReqGuestStatus.
764 */
765typedef struct VBoxGuestStatus
766{
767 /** Facility the status is indicated for. */
768 VBoxGuestFacilityType facility;
769 /** Current guest status. */
770 VBoxGuestFacilityStatus status;
771 /** Flags, not used at the moment. */
772 uint32_t flags;
773} VBoxGuestStatus;
774AssertCompileSize(VBoxGuestStatus, 12);
775
776/**
777 * Guest Additions status structure.
778 *
779 * Used by VMMDevReq_ReportGuestStatus.
780 */
781typedef struct
782{
783 /** Header. */
784 VMMDevRequestHeader header;
785 /** Guest information. */
786 VBoxGuestStatus guestStatus;
787} VMMDevReportGuestStatus;
788AssertCompileSize(VMMDevReportGuestStatus, 24+12);
789
790
791/**
792 * Guest statistics structure.
793 *
794 * Used by VMMDevReportGuestStats and PDMIVMMDEVCONNECTOR::pfnReportStatistics.
795 */
796typedef struct VBoxGuestStatistics
797{
798 /** Virtual CPU ID. */
799 uint32_t u32CpuId;
800 /** Reported statistics. */
801 uint32_t u32StatCaps;
802 /** Idle CPU load (0-100) for last interval. */
803 uint32_t u32CpuLoad_Idle;
804 /** Kernel CPU load (0-100) for last interval. */
805 uint32_t u32CpuLoad_Kernel;
806 /** User CPU load (0-100) for last interval. */
807 uint32_t u32CpuLoad_User;
808 /** Nr of threads. */
809 uint32_t u32Threads;
810 /** Nr of processes. */
811 uint32_t u32Processes;
812 /** Nr of handles. */
813 uint32_t u32Handles;
814 /** Memory load (0-100). */
815 uint32_t u32MemoryLoad;
816 /** Page size of guest system. */
817 uint32_t u32PageSize;
818 /** Total physical memory (in 4KB pages). */
819 uint32_t u32PhysMemTotal;
820 /** Available physical memory (in 4KB pages). */
821 uint32_t u32PhysMemAvail;
822 /** Ballooned physical memory (in 4KB pages). */
823 uint32_t u32PhysMemBalloon;
824 /** Total number of committed memory (which is not necessarily in-use) (in 4KB pages). */
825 uint32_t u32MemCommitTotal;
826 /** Total amount of memory used by the kernel (in 4KB pages). */
827 uint32_t u32MemKernelTotal;
828 /** Total amount of paged memory used by the kernel (in 4KB pages). */
829 uint32_t u32MemKernelPaged;
830 /** Total amount of nonpaged memory used by the kernel (in 4KB pages). */
831 uint32_t u32MemKernelNonPaged;
832 /** Total amount of memory used for the system cache (in 4KB pages). */
833 uint32_t u32MemSystemCache;
834 /** Pagefile size (in 4KB pages). */
835 uint32_t u32PageFileSize;
836} VBoxGuestStatistics;
837AssertCompileSize(VBoxGuestStatistics, 19*4);
838
839/** @name Guest statistics values (VBoxGuestStatistics::u32StatCaps).
840 * @{ */
841#define VBOX_GUEST_STAT_CPU_LOAD_IDLE RT_BIT(0)
842#define VBOX_GUEST_STAT_CPU_LOAD_KERNEL RT_BIT(1)
843#define VBOX_GUEST_STAT_CPU_LOAD_USER RT_BIT(2)
844#define VBOX_GUEST_STAT_THREADS RT_BIT(3)
845#define VBOX_GUEST_STAT_PROCESSES RT_BIT(4)
846#define VBOX_GUEST_STAT_HANDLES RT_BIT(5)
847#define VBOX_GUEST_STAT_MEMORY_LOAD RT_BIT(6)
848#define VBOX_GUEST_STAT_PHYS_MEM_TOTAL RT_BIT(7)
849#define VBOX_GUEST_STAT_PHYS_MEM_AVAIL RT_BIT(8)
850#define VBOX_GUEST_STAT_PHYS_MEM_BALLOON RT_BIT(9)
851#define VBOX_GUEST_STAT_MEM_COMMIT_TOTAL RT_BIT(10)
852#define VBOX_GUEST_STAT_MEM_KERNEL_TOTAL RT_BIT(11)
853#define VBOX_GUEST_STAT_MEM_KERNEL_PAGED RT_BIT(12)
854#define VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED RT_BIT(13)
855#define VBOX_GUEST_STAT_MEM_SYSTEM_CACHE RT_BIT(14)
856#define VBOX_GUEST_STAT_PAGE_FILE_SIZE RT_BIT(15)
857/** @} */
858
859/**
860 * Guest statistics command structure.
861 *
862 * Used by VMMDevReq_ReportGuestStats.
863 */
864typedef struct
865{
866 /** Header. */
867 VMMDevRequestHeader header;
868 /** Guest information. */
869 VBoxGuestStatistics guestStats;
870} VMMDevReportGuestStats;
871AssertCompileSize(VMMDevReportGuestStats, 24+19*4);
872
873
874/** Memory balloon change request structure. */
875#define VMMDEV_MAX_MEMORY_BALLOON(PhysMemTotal) ( (9 * (PhysMemTotal)) / 10 )
876
877/**
878 * Poll for ballooning change request.
879 *
880 * Used by VMMDevReq_GetMemBalloonChangeRequest.
881 */
882typedef struct
883{
884 /** Header. */
885 VMMDevRequestHeader header;
886 /** Balloon size in megabytes. */
887 uint32_t cBalloonChunks;
888 /** Guest ram size in megabytes. */
889 uint32_t cPhysMemChunks;
890 /** Setting this to VMMDEV_EVENT_BALLOON_CHANGE_REQUEST indicates that the
891 * request is a response to that event.
892 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
893 uint32_t eventAck;
894} VMMDevGetMemBalloonChangeRequest;
895AssertCompileSize(VMMDevGetMemBalloonChangeRequest, 24+12);
896
897
898/**
899 * Change the size of the balloon.
900 *
901 * Used by VMMDevReq_ChangeMemBalloon.
902 */
903typedef struct
904{
905 /** Header. */
906 VMMDevRequestHeader header;
907 /** The number of pages in the array. */
908 uint32_t cPages;
909 /** true = inflate, false = deflate. */
910 uint32_t fInflate;
911 /** Physical address (RTGCPHYS) of each page, variable size. */
912 RTGCPHYS aPhysPage[1];
913} VMMDevChangeMemBalloon;
914AssertCompileSize(VMMDevChangeMemBalloon, 24+16);
915
916/** @name The ballooning chunk size which VMMDev works at.
917 * @{ */
918#define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (_1M/4096)
919#define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE (VMMDEV_MEMORY_BALLOON_CHUNK_PAGES*4096)
920/** @} */
921
922
923/**
924 * Guest statistics interval change request structure.
925 *
926 * Used by VMMDevReq_GetStatisticsChangeRequest.
927 */
928typedef struct
929{
930 /** Header. */
931 VMMDevRequestHeader header;
932 /** The interval in seconds. */
933 uint32_t u32StatInterval;
934 /** Setting this to VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST indicates
935 * that the request is a response to that event.
936 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
937 uint32_t eventAck;
938} VMMDevGetStatisticsChangeRequest;
939AssertCompileSize(VMMDevGetStatisticsChangeRequest, 24+8);
940
941
942/** The size of a string field in the credentials request (including '\\0').
943 * @see VMMDevCredentials */
944#define VMMDEV_CREDENTIALS_SZ_SIZE 128
945
946/**
947 * Credentials request structure.
948 *
949 * Used by VMMDevReq_QueryCredentials.
950 */
951#pragma pack(4)
952typedef struct
953{
954 /** Header. */
955 VMMDevRequestHeader header;
956 /** IN/OUT: Request flags. */
957 uint32_t u32Flags;
958 /** OUT: User name (UTF-8). */
959 char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
960 /** OUT: Password (UTF-8). */
961 char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
962 /** OUT: Domain name (UTF-8). */
963 char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
964} VMMDevCredentials;
965AssertCompileSize(VMMDevCredentials, 24+4+3*128);
966#pragma pack()
967
968/** @name Credentials request flag (VMMDevCredentials::u32Flags)
969 * @{ */
970/** query from host whether credentials are present */
971#define VMMDEV_CREDENTIALS_QUERYPRESENCE RT_BIT(1)
972/** read credentials from host (can be combined with clear) */
973#define VMMDEV_CREDENTIALS_READ RT_BIT(2)
974/** clear credentials on host (can be combined with read) */
975#define VMMDEV_CREDENTIALS_CLEAR RT_BIT(3)
976/** read credentials for judgement in the guest */
977#define VMMDEV_CREDENTIALS_READJUDGE RT_BIT(8)
978/** clear credentials for judegement on the host */
979#define VMMDEV_CREDENTIALS_CLEARJUDGE RT_BIT(9)
980/** report credentials acceptance by guest */
981#define VMMDEV_CREDENTIALS_JUDGE_OK RT_BIT(10)
982/** report credentials denial by guest */
983#define VMMDEV_CREDENTIALS_JUDGE_DENY RT_BIT(11)
984/** report that no judgement could be made by guest */
985#define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT RT_BIT(12)
986
987/** flag telling the guest that credentials are present */
988#define VMMDEV_CREDENTIALS_PRESENT RT_BIT(16)
989/** flag telling guest that local logons should be prohibited */
990#define VMMDEV_CREDENTIALS_NOLOCALLOGON RT_BIT(17)
991/** @} */
992
993
994/**
995 * Seamless mode change request structure.
996 *
997 * Used by VMMDevReq_GetSeamlessChangeRequest.
998 */
999typedef struct
1000{
1001 /** Header. */
1002 VMMDevRequestHeader header;
1003
1004 /** New seamless mode. */
1005 VMMDevSeamlessMode mode;
1006 /** Setting this to VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST indicates
1007 * that the request is a response to that event.
1008 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
1009 uint32_t eventAck;
1010} VMMDevSeamlessChangeRequest;
1011AssertCompileSize(VMMDevSeamlessChangeRequest, 24+8);
1012AssertCompileMemberOffset(VMMDevSeamlessChangeRequest, eventAck, 24+4);
1013
1014
1015/**
1016 * Display change request structure.
1017 *
1018 * Used by VMMDevReq_GetDisplayChangeRequest.
1019 */
1020typedef struct
1021{
1022 /** Header. */
1023 VMMDevRequestHeader header;
1024 /** Horizontal pixel resolution (0 = do not change). */
1025 uint32_t xres;
1026 /** Vertical pixel resolution (0 = do not change). */
1027 uint32_t yres;
1028 /** Bits per pixel (0 = do not change). */
1029 uint32_t bpp;
1030 /** Setting this to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST indicates
1031 * that the request is a response to that event.
1032 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
1033 uint32_t eventAck;
1034} VMMDevDisplayChangeRequest;
1035AssertCompileSize(VMMDevDisplayChangeRequest, 24+16);
1036
1037
1038/**
1039 * Display change request structure, version 2.
1040 *
1041 * Used by VMMDevReq_GetDisplayChangeRequest2.
1042 */
1043typedef struct
1044{
1045 /** Header. */
1046 VMMDevRequestHeader header;
1047 /** Horizontal pixel resolution (0 = do not change). */
1048 uint32_t xres;
1049 /** Vertical pixel resolution (0 = do not change). */
1050 uint32_t yres;
1051 /** Bits per pixel (0 = do not change). */
1052 uint32_t bpp;
1053 /** Setting this to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST indicates
1054 * that the request is a response to that event.
1055 * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
1056 uint32_t eventAck;
1057 /** 0 for primary display, 1 for the first secondary, etc. */
1058 uint32_t display;
1059} VMMDevDisplayChangeRequest2;
1060AssertCompileSize(VMMDevDisplayChangeRequest2, 24+20);
1061
1062
1063/**
1064 * Video mode supported request structure.
1065 *
1066 * Used by VMMDevReq_VideoModeSupported.
1067 */
1068typedef struct
1069{
1070 /** Header. */
1071 VMMDevRequestHeader header;
1072 /** IN: Horizontal pixel resolution. */
1073 uint32_t width;
1074 /** IN: Vertical pixel resolution. */
1075 uint32_t height;
1076 /** IN: Bits per pixel. */
1077 uint32_t bpp;
1078 /** OUT: Support indicator. */
1079 bool fSupported;
1080} VMMDevVideoModeSupportedRequest;
1081AssertCompileSize(VMMDevVideoModeSupportedRequest, 24+16);
1082
1083/**
1084 * Video mode supported request structure for a specific display.
1085 *
1086 * Used by VMMDevReq_VideoModeSupported2.
1087 */
1088typedef struct
1089{
1090 /** Header. */
1091 VMMDevRequestHeader header;
1092 /** IN: The guest display number. */
1093 uint32_t display;
1094 /** IN: Horizontal pixel resolution. */
1095 uint32_t width;
1096 /** IN: Vertical pixel resolution. */
1097 uint32_t height;
1098 /** IN: Bits per pixel. */
1099 uint32_t bpp;
1100 /** OUT: Support indicator. */
1101 bool fSupported;
1102} VMMDevVideoModeSupportedRequest2;
1103AssertCompileSize(VMMDevVideoModeSupportedRequest2, 24+20);
1104
1105/**
1106 * Video modes height reduction request structure.
1107 *
1108 * Used by VMMDevReq_GetHeightReduction.
1109 */
1110typedef struct
1111{
1112 /** Header. */
1113 VMMDevRequestHeader header;
1114 /** OUT: Height reduction in pixels. */
1115 uint32_t heightReduction;
1116} VMMDevGetHeightReductionRequest;
1117AssertCompileSize(VMMDevGetHeightReductionRequest, 24+4);
1118
1119
1120/**
1121 * VRDP change request structure.
1122 *
1123 * Used by VMMDevReq_GetVRDPChangeRequest.
1124 */
1125typedef struct
1126{
1127 /** Header */
1128 VMMDevRequestHeader header;
1129 /** Whether VRDP is active or not. */
1130 uint8_t u8VRDPActive;
1131 /** The configured experience level for active VRDP. */
1132 uint32_t u32VRDPExperienceLevel;
1133} VMMDevVRDPChangeRequest;
1134AssertCompileSize(VMMDevVRDPChangeRequest, 24+8);
1135AssertCompileMemberOffset(VMMDevVRDPChangeRequest, u8VRDPActive, 24);
1136AssertCompileMemberOffset(VMMDevVRDPChangeRequest, u32VRDPExperienceLevel, 24+4);
1137
1138/** @name VRDP Experience level (VMMDevVRDPChangeRequest::u32VRDPExperienceLevel)
1139 * @{ */
1140#define VRDP_EXPERIENCE_LEVEL_ZERO 0 /**< Theming disabled. */
1141#define VRDP_EXPERIENCE_LEVEL_LOW 1 /**< Full window dragging and desktop wallpaper disabled. */
1142#define VRDP_EXPERIENCE_LEVEL_MEDIUM 2 /**< Font smoothing, gradients. */
1143#define VRDP_EXPERIENCE_LEVEL_HIGH 3 /**< Animation effects disabled. */
1144#define VRDP_EXPERIENCE_LEVEL_FULL 4 /**< Everything enabled. */
1145/** @} */
1146
1147
1148/**
1149 * VBVA enable request structure.
1150 *
1151 * Used by VMMDevReq_VideoAccelEnable.
1152 */
1153typedef struct
1154{
1155 /** Header. */
1156 VMMDevRequestHeader header;
1157 /** 0 - disable, !0 - enable. */
1158 uint32_t u32Enable;
1159 /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
1160 * The host will refuse to enable VBVA if the size is not equal to
1161 * VBVA_RING_BUFFER_SIZE.
1162 */
1163 uint32_t cbRingBuffer;
1164 /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
1165 uint32_t fu32Status;
1166} VMMDevVideoAccelEnable;
1167AssertCompileSize(VMMDevVideoAccelEnable, 24+12);
1168
1169/** @name VMMDevVideoAccelEnable::fu32Status.
1170 * @{ */
1171#define VBVA_F_STATUS_ACCEPTED (0x01)
1172#define VBVA_F_STATUS_ENABLED (0x02)
1173/** @} */
1174
1175
1176/**
1177 * VBVA flush request structure.
1178 *
1179 * Used by VMMDevReq_VideoAccelFlush.
1180 */
1181typedef struct
1182{
1183 /** Header. */
1184 VMMDevRequestHeader header;
1185} VMMDevVideoAccelFlush;
1186AssertCompileSize(VMMDevVideoAccelFlush, 24);
1187
1188
1189/**
1190 * VBVA set visible region request structure.
1191 *
1192 * Used by VMMDevReq_VideoSetVisibleRegion.
1193 */
1194typedef struct
1195{
1196 /** Header. */
1197 VMMDevRequestHeader header;
1198 /** Number of rectangles */
1199 uint32_t cRect;
1200 /** Rectangle array.
1201 * @todo array is spelled aRects[1]. */
1202 RTRECT Rect;
1203} VMMDevVideoSetVisibleRegion;
1204AssertCompileSize(RTRECT, 16);
1205AssertCompileSize(VMMDevVideoSetVisibleRegion, 24+4+16);
1206
1207/**
1208 * CPU event types.
1209 */
1210typedef enum
1211{
1212 VMMDevCpuStatusType_Invalid = 0,
1213 VMMDevCpuStatusType_Disable = 1,
1214 VMMDevCpuStatusType_Enable = 2,
1215 VMMDevCpuStatusType_SizeHack = 0x7fffffff
1216} VMMDevCpuStatusType;
1217
1218/**
1219 * CPU hotplug event status request.
1220 */
1221typedef struct
1222{
1223 /** Header. */
1224 VMMDevRequestHeader header;
1225 /** Status type */
1226 VMMDevCpuStatusType enmStatusType;
1227} VMMDevCpuHotPlugStatusRequest;
1228AssertCompileSize(VMMDevCpuHotPlugStatusRequest, 24+4);
1229
1230/**
1231 * Get the ID of the changed CPU and event type.
1232 */
1233typedef struct
1234{
1235 /** Header. */
1236 VMMDevRequestHeader header;
1237 /** Event type */
1238 VMMDevCpuEventType enmEventType;
1239 /** core id of the CPU changed */
1240 uint32_t idCpuCore;
1241 /** package id of the CPU changed */
1242 uint32_t idCpuPackage;
1243} VMMDevGetCpuHotPlugRequest;
1244AssertCompileSize(VMMDevGetCpuHotPlugRequest, 24+4+4+4);
1245
1246
1247/**
1248 * Shared region description
1249 */
1250typedef struct VMMDEVSHAREDREGIONDESC
1251{
1252 RTGCPTR64 GCRegionAddr;
1253 uint32_t cbRegion;
1254 uint32_t u32Alignment;
1255} VMMDEVSHAREDREGIONDESC;
1256AssertCompileSize(VMMDEVSHAREDREGIONDESC, 16);
1257
1258#define VMMDEVSHAREDREGIONDESC_MAX 32
1259
1260/**
1261 * Shared module registration
1262 */
1263typedef struct
1264{
1265 /** Header. */
1266 VMMDevRequestHeader header;
1267 /** Shared module size. */
1268 uint32_t cbModule;
1269 /** Number of included region descriptors */
1270 uint32_t cRegions;
1271 /** Base address of the shared module. */
1272 RTGCPTR64 GCBaseAddr;
1273 /** Guest OS type. */
1274 VBOXOSFAMILY enmGuestOS;
1275 /** Alignment. */
1276 uint32_t u32Align;
1277 /** Module name */
1278 char szName[128];
1279 /** Module version */
1280 char szVersion[16];
1281 /** Shared region descriptor(s). */
1282 VMMDEVSHAREDREGIONDESC aRegions[1];
1283} VMMDevSharedModuleRegistrationRequest;
1284AssertCompileSize(VMMDevSharedModuleRegistrationRequest, 24+4+4+8+4+4+128+16+16);
1285
1286
1287/**
1288 * Shared module unregistration
1289 */
1290typedef struct
1291{
1292 /** Header. */
1293 VMMDevRequestHeader header;
1294 /** Shared module size. */
1295 uint32_t cbModule;
1296 /** Align at 8 byte boundary. */
1297 uint32_t u32Alignment;
1298 /** Base address of the shared module. */
1299 RTGCPTR64 GCBaseAddr;
1300 /** Module name */
1301 char szName[128];
1302 /** Module version */
1303 char szVersion[16];
1304} VMMDevSharedModuleUnregistrationRequest;
1305AssertCompileSize(VMMDevSharedModuleUnregistrationRequest, 24+4+4+8+128+16);
1306
1307
1308/**
1309 * Shared module periodic check
1310 */
1311typedef struct
1312{
1313 /** Header. */
1314 VMMDevRequestHeader header;
1315} VMMDevSharedModuleCheckRequest;
1316AssertCompileSize(VMMDevSharedModuleCheckRequest, 24);
1317
1318/**
1319 * Paging sharing enabled query
1320 */
1321typedef struct
1322{
1323 /** Header. */
1324 VMMDevRequestHeader header;
1325 /** Enabled flag (out) */
1326 bool fEnabled;
1327 /** Alignment */
1328 bool fAlignment[3];
1329} VMMDevPageSharingStatusRequest;
1330AssertCompileSize(VMMDevPageSharingStatusRequest, 24+4);
1331
1332
1333/**
1334 * Page sharing status query (debug build only)
1335 */
1336typedef struct
1337{
1338 /** Header. */
1339 VMMDevRequestHeader header;
1340 /** Page address. */
1341 RTGCPTR GCPtrPage;
1342 /** Page flags. */
1343 uint64_t uPageFlags;
1344 /** Shared flag (out) */
1345 bool fShared;
1346 /** Alignment */
1347 bool fAlignment[3];
1348} VMMDevPageIsSharedRequest;
1349
1350/**
1351 * Session id request structure.
1352 *
1353 * Used by VMMDevReq_GetSessionId.
1354 */
1355typedef struct
1356{
1357 /** Header */
1358 VMMDevRequestHeader header;
1359 /** OUT: unique session id; the id will be different after each start, reset or restore of the VM */
1360 uint64_t idSession;
1361} VMMDevReqSessionId;
1362AssertCompileSize(VMMDevReqSessionId, 24+8);
1363
1364
1365/**
1366 * Write Core Dump request.
1367 *
1368 * Used by VMMDevReq_WriteCoreDump.
1369 */
1370typedef struct
1371{
1372 /** Header. */
1373 VMMDevRequestHeader header;
1374 /** Flags (reserved, MBZ). */
1375 uint32_t fFlags;
1376} VMMDevReqWriteCoreDump;
1377AssertCompileSize(VMMDevReqWriteCoreDump, 24+4);
1378
1379
1380#pragma pack()
1381
1382
1383#ifdef VBOX_WITH_HGCM
1384
1385/** @name HGCM flags.
1386 * @{
1387 */
1388# define VBOX_HGCM_REQ_DONE RT_BIT_32(VBOX_HGCM_REQ_DONE_BIT)
1389# define VBOX_HGCM_REQ_DONE_BIT 0
1390# define VBOX_HGCM_REQ_CANCELLED (0x2)
1391/** @} */
1392
1393# pragma pack(4)
1394
1395/**
1396 * HGCM request header.
1397 */
1398typedef struct VMMDevHGCMRequestHeader
1399{
1400 /** Request header. */
1401 VMMDevRequestHeader header;
1402
1403 /** HGCM flags. */
1404 uint32_t fu32Flags;
1405
1406 /** Result code. */
1407 int32_t result;
1408} VMMDevHGCMRequestHeader;
1409AssertCompileSize(VMMDevHGCMRequestHeader, 24+8);
1410
1411/**
1412 * HGCM connect request structure.
1413 *
1414 * Used by VMMDevReq_HGCMConnect.
1415 */
1416typedef struct
1417{
1418 /** HGCM request header. */
1419 VMMDevHGCMRequestHeader header;
1420
1421 /** IN: Description of service to connect to. */
1422 HGCMServiceLocation loc;
1423
1424 /** OUT: Client identifier assigned by local instance of HGCM. */
1425 uint32_t u32ClientID;
1426} VMMDevHGCMConnect;
1427AssertCompileSize(VMMDevHGCMConnect, 32+132+4);
1428
1429
1430/**
1431 * HGCM disconnect request structure.
1432 *
1433 * Used by VMMDevReq_HGCMDisconnect.
1434 */
1435typedef struct
1436{
1437 /** HGCM request header. */
1438 VMMDevHGCMRequestHeader header;
1439
1440 /** IN: Client identifier. */
1441 uint32_t u32ClientID;
1442} VMMDevHGCMDisconnect;
1443AssertCompileSize(VMMDevHGCMDisconnect, 32+4);
1444
1445/**
1446 * HGCM parameter type.
1447 */
1448typedef enum
1449{
1450 VMMDevHGCMParmType_Invalid = 0,
1451 VMMDevHGCMParmType_32bit = 1,
1452 VMMDevHGCMParmType_64bit = 2,
1453 VMMDevHGCMParmType_PhysAddr = 3, /**< @deprecated Doesn't work, use PageList. */
1454 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
1455 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */
1456 VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */
1457 VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */
1458 VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */
1459 VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */
1460 VMMDevHGCMParmType_PageList = 10, /**< Physical addresses of locked pages for a buffer. */
1461 VMMDevHGCMParmType_SizeHack = 0x7fffffff
1462} HGCMFunctionParameterType;
1463AssertCompileSize(HGCMFunctionParameterType, 4);
1464
1465# ifdef VBOX_WITH_64_BITS_GUESTS
1466/**
1467 * HGCM function parameter, 32-bit client.
1468 */
1469typedef struct
1470{
1471 HGCMFunctionParameterType type;
1472 union
1473 {
1474 uint32_t value32;
1475 uint64_t value64;
1476 struct
1477 {
1478 uint32_t size;
1479
1480 union
1481 {
1482 RTGCPHYS32 physAddr;
1483 RTGCPTR32 linearAddr;
1484 } u;
1485 } Pointer;
1486 struct
1487 {
1488 uint32_t size; /**< Size of the buffer described by the page list. */
1489 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1490 } PageList;
1491 } u;
1492# ifdef __cplusplus
1493 void SetUInt32(uint32_t u32)
1494 {
1495 type = VMMDevHGCMParmType_32bit;
1496 u.value64 = 0; /* init unused bits to 0 */
1497 u.value32 = u32;
1498 }
1499
1500 int GetUInt32(uint32_t *pu32)
1501 {
1502 if (type == VMMDevHGCMParmType_32bit)
1503 {
1504 *pu32 = u.value32;
1505 return VINF_SUCCESS;
1506 }
1507 return VERR_INVALID_PARAMETER;
1508 }
1509
1510 void SetUInt64(uint64_t u64)
1511 {
1512 type = VMMDevHGCMParmType_64bit;
1513 u.value64 = u64;
1514 }
1515
1516 int GetUInt64(uint64_t *pu64)
1517 {
1518 if (type == VMMDevHGCMParmType_64bit)
1519 {
1520 *pu64 = u.value64;
1521 return VINF_SUCCESS;
1522 }
1523 return VERR_INVALID_PARAMETER;
1524 }
1525
1526 void SetPtr(void *pv, uint32_t cb)
1527 {
1528 type = VMMDevHGCMParmType_LinAddr;
1529 u.Pointer.size = cb;
1530 u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv;
1531 }
1532# endif /* __cplusplus */
1533} HGCMFunctionParameter32;
1534AssertCompileSize(HGCMFunctionParameter32, 4+8);
1535
1536/**
1537 * HGCM function parameter, 64-bit client.
1538 */
1539typedef struct
1540{
1541 HGCMFunctionParameterType type;
1542 union
1543 {
1544 uint32_t value32;
1545 uint64_t value64;
1546 struct
1547 {
1548 uint32_t size;
1549
1550 union
1551 {
1552 RTGCPHYS64 physAddr;
1553 RTGCPTR64 linearAddr;
1554 } u;
1555 } Pointer;
1556 struct
1557 {
1558 uint32_t size; /**< Size of the buffer described by the page list. */
1559 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1560 } PageList;
1561 } u;
1562# ifdef __cplusplus
1563 void SetUInt32(uint32_t u32)
1564 {
1565 type = VMMDevHGCMParmType_32bit;
1566 u.value64 = 0; /* init unused bits to 0 */
1567 u.value32 = u32;
1568 }
1569
1570 int GetUInt32(uint32_t *pu32)
1571 {
1572 if (type == VMMDevHGCMParmType_32bit)
1573 {
1574 *pu32 = u.value32;
1575 return VINF_SUCCESS;
1576 }
1577 return VERR_INVALID_PARAMETER;
1578 }
1579
1580 void SetUInt64(uint64_t u64)
1581 {
1582 type = VMMDevHGCMParmType_64bit;
1583 u.value64 = u64;
1584 }
1585
1586 int GetUInt64(uint64_t *pu64)
1587 {
1588 if (type == VMMDevHGCMParmType_64bit)
1589 {
1590 *pu64 = u.value64;
1591 return VINF_SUCCESS;
1592 }
1593 return VERR_INVALID_PARAMETER;
1594 }
1595
1596 void SetPtr(void *pv, uint32_t cb)
1597 {
1598 type = VMMDevHGCMParmType_LinAddr;
1599 u.Pointer.size = cb;
1600 u.Pointer.u.linearAddr = (uintptr_t)pv;
1601 }
1602# endif /** __cplusplus */
1603} HGCMFunctionParameter64;
1604AssertCompileSize(HGCMFunctionParameter64, 4+12);
1605
1606/* Redefine the structure type for the guest code. */
1607# ifndef VBOX_HGCM_HOST_CODE
1608# if ARCH_BITS == 64
1609# define HGCMFunctionParameter HGCMFunctionParameter64
1610# elif ARCH_BITS == 32
1611# define HGCMFunctionParameter HGCMFunctionParameter32
1612# else
1613# error "Unsupported sizeof (void *)"
1614# endif
1615# endif /* !VBOX_HGCM_HOST_CODE */
1616
1617# else /* !VBOX_WITH_64_BITS_GUESTS */
1618
1619/**
1620 * HGCM function parameter, 32-bit client.
1621 *
1622 * @todo If this is the same as HGCMFunctionParameter32, why the duplication?
1623 */
1624typedef struct
1625{
1626 HGCMFunctionParameterType type;
1627 union
1628 {
1629 uint32_t value32;
1630 uint64_t value64;
1631 struct
1632 {
1633 uint32_t size;
1634
1635 union
1636 {
1637 RTGCPHYS32 physAddr;
1638 RTGCPTR32 linearAddr;
1639 } u;
1640 } Pointer;
1641 struct
1642 {
1643 uint32_t size; /**< Size of the buffer described by the page list. */
1644 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1645 } PageList;
1646 } u;
1647# ifdef __cplusplus
1648 void SetUInt32(uint32_t u32)
1649 {
1650 type = VMMDevHGCMParmType_32bit;
1651 u.value64 = 0; /* init unused bits to 0 */
1652 u.value32 = u32;
1653 }
1654
1655 int GetUInt32(uint32_t *pu32)
1656 {
1657 if (type == VMMDevHGCMParmType_32bit)
1658 {
1659 *pu32 = u.value32;
1660 return VINF_SUCCESS;
1661 }
1662 return VERR_INVALID_PARAMETER;
1663 }
1664
1665 void SetUInt64(uint64_t u64)
1666 {
1667 type = VMMDevHGCMParmType_64bit;
1668 u.value64 = u64;
1669 }
1670
1671 int GetUInt64(uint64_t *pu64)
1672 {
1673 if (type == VMMDevHGCMParmType_64bit)
1674 {
1675 *pu64 = u.value64;
1676 return VINF_SUCCESS;
1677 }
1678 return VERR_INVALID_PARAMETER;
1679 }
1680
1681 void SetPtr(void *pv, uint32_t cb)
1682 {
1683 type = VMMDevHGCMParmType_LinAddr;
1684 u.Pointer.size = cb;
1685 u.Pointer.u.linearAddr = (uintptr_t)pv;
1686 }
1687# endif /* __cplusplus */
1688} HGCMFunctionParameter;
1689AssertCompileSize(HGCMFunctionParameter, 4+8);
1690# endif /* !VBOX_WITH_64_BITS_GUESTS */
1691
1692/**
1693 * HGCM call request structure.
1694 *
1695 * Used by VMMDevReq_HGCMCall, VMMDevReq_HGCMCall32 and VMMDevReq_HGCMCall64.
1696 */
1697typedef struct
1698{
1699 /* request header */
1700 VMMDevHGCMRequestHeader header;
1701
1702 /** IN: Client identifier. */
1703 uint32_t u32ClientID;
1704 /** IN: Service function number. */
1705 uint32_t u32Function;
1706 /** IN: Number of parameters. */
1707 uint32_t cParms;
1708 /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
1709} VMMDevHGCMCall;
1710AssertCompileSize(VMMDevHGCMCall, 32+12);
1711
1712/** @name Direction of data transfer (HGCMPageListInfo::flags). Bit flags.
1713 * @{ */
1714#define VBOX_HGCM_F_PARM_DIRECTION_NONE UINT32_C(0x00000000)
1715#define VBOX_HGCM_F_PARM_DIRECTION_TO_HOST UINT32_C(0x00000001)
1716#define VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST UINT32_C(0x00000002)
1717#define VBOX_HGCM_F_PARM_DIRECTION_BOTH UINT32_C(0x00000003)
1718/** Macro for validating that the specified flags are valid. */
1719#define VBOX_HGCM_F_PARM_ARE_VALID(fFlags) \
1720 ( (fFlags) > VBOX_HGCM_F_PARM_DIRECTION_NONE \
1721 && (fFlags) < VBOX_HGCM_F_PARM_DIRECTION_BOTH )
1722/** @} */
1723
1724/**
1725 * VMMDevHGCMParmType_PageList points to this structure to actually describe the
1726 * buffer.
1727 */
1728typedef struct
1729{
1730 uint32_t flags; /**< VBOX_HGCM_F_PARM_*. */
1731 uint16_t offFirstPage; /**< Offset in the first page where data begins. */
1732 uint16_t cPages; /**< Number of pages. */
1733 RTGCPHYS64 aPages[1]; /**< Page addresses. */
1734} HGCMPageListInfo;
1735AssertCompileSize(HGCMPageListInfo, 4+2+2+8);
1736
1737# pragma pack()
1738
1739/** Get the pointer to the first parmater of a HGCM call request. */
1740# define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1741/** Get the pointer to the first parmater of a 32-bit HGCM call request. */
1742# define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1743
1744# ifdef VBOX_WITH_64_BITS_GUESTS
1745/* Explicit defines for the host code. */
1746# ifdef VBOX_HGCM_HOST_CODE
1747# define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1748# define VMMDEV_HGCM_CALL_PARMS64(a) ((HGCMFunctionParameter64 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1749# endif /* VBOX_HGCM_HOST_CODE */
1750# endif /* VBOX_WITH_64_BITS_GUESTS */
1751
1752# define VBOX_HGCM_MAX_PARMS 32
1753
1754/**
1755 * HGCM cancel request structure.
1756 *
1757 * The Cancel request is issued using the same physical memory address as was
1758 * used for the corresponding initial HGCMCall.
1759 *
1760 * Used by VMMDevReq_HGCMCancel.
1761 */
1762typedef struct
1763{
1764 /** Header. */
1765 VMMDevHGCMRequestHeader header;
1766} VMMDevHGCMCancel;
1767AssertCompileSize(VMMDevHGCMCancel, 32);
1768
1769/**
1770 * HGCM cancel request structure, version 2.
1771 *
1772 * Used by VMMDevReq_HGCMCancel2.
1773 *
1774 * VINF_SUCCESS when cancelled.
1775 * VERR_NOT_FOUND if the specified request cannot be found.
1776 * VERR_INVALID_PARAMETER if the address is invalid valid.
1777 */
1778typedef struct
1779{
1780 /** Header. */
1781 VMMDevRequestHeader header;
1782 /** The physical address of the request to cancel. */
1783 RTGCPHYS32 physReqToCancel;
1784} VMMDevHGCMCancel2;
1785AssertCompileSize(VMMDevHGCMCancel2, 24+4);
1786
1787#endif /* VBOX_WITH_HGCM */
1788
1789
1790/**
1791 * Inline helper to determine the request size for the given operation.
1792 *
1793 * @returns Size.
1794 * @param requestType The VMMDev request type.
1795 */
1796DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
1797{
1798 switch (requestType)
1799 {
1800 case VMMDevReq_GetMouseStatus:
1801 case VMMDevReq_SetMouseStatus:
1802 return sizeof(VMMDevReqMouseStatus);
1803 case VMMDevReq_SetPointerShape:
1804 return sizeof(VMMDevReqMousePointer);
1805 case VMMDevReq_GetHostVersion:
1806 return sizeof(VMMDevReqHostVersion);
1807 case VMMDevReq_Idle:
1808 return sizeof(VMMDevReqIdle);
1809 case VMMDevReq_GetHostTime:
1810 return sizeof(VMMDevReqHostTime);
1811 case VMMDevReq_GetHypervisorInfo:
1812 case VMMDevReq_SetHypervisorInfo:
1813 return sizeof(VMMDevReqHypervisorInfo);
1814 case VMMDevReq_RegisterPatchMemory:
1815 case VMMDevReq_DeregisterPatchMemory:
1816 return sizeof(VMMDevReqPatchMemory);
1817 case VMMDevReq_SetPowerStatus:
1818 return sizeof(VMMDevPowerStateRequest);
1819 case VMMDevReq_AcknowledgeEvents:
1820 return sizeof(VMMDevEvents);
1821 case VMMDevReq_ReportGuestInfo:
1822 return sizeof(VMMDevReportGuestInfo);
1823 case VMMDevReq_ReportGuestInfo2:
1824 return sizeof(VMMDevReportGuestInfo2);
1825 case VMMDevReq_ReportGuestStatus:
1826 return sizeof(VMMDevReportGuestStatus);
1827 case VMMDevReq_GetDisplayChangeRequest:
1828 return sizeof(VMMDevDisplayChangeRequest);
1829 case VMMDevReq_GetDisplayChangeRequest2:
1830 return sizeof(VMMDevDisplayChangeRequest2);
1831 case VMMDevReq_VideoModeSupported:
1832 return sizeof(VMMDevVideoModeSupportedRequest);
1833 case VMMDevReq_GetHeightReduction:
1834 return sizeof(VMMDevGetHeightReductionRequest);
1835 case VMMDevReq_ReportGuestCapabilities:
1836 return sizeof(VMMDevReqGuestCapabilities);
1837 case VMMDevReq_SetGuestCapabilities:
1838 return sizeof(VMMDevReqGuestCapabilities2);
1839#ifdef VBOX_WITH_HGCM
1840 case VMMDevReq_HGCMConnect:
1841 return sizeof(VMMDevHGCMConnect);
1842 case VMMDevReq_HGCMDisconnect:
1843 return sizeof(VMMDevHGCMDisconnect);
1844#ifdef VBOX_WITH_64_BITS_GUESTS
1845 case VMMDevReq_HGCMCall32:
1846 return sizeof(VMMDevHGCMCall);
1847 case VMMDevReq_HGCMCall64:
1848 return sizeof(VMMDevHGCMCall);
1849#else
1850 case VMMDevReq_HGCMCall:
1851 return sizeof(VMMDevHGCMCall);
1852#endif /* VBOX_WITH_64_BITS_GUESTS */
1853 case VMMDevReq_HGCMCancel:
1854 return sizeof(VMMDevHGCMCancel);
1855#endif /* VBOX_WITH_HGCM */
1856 case VMMDevReq_VideoAccelEnable:
1857 return sizeof(VMMDevVideoAccelEnable);
1858 case VMMDevReq_VideoAccelFlush:
1859 return sizeof(VMMDevVideoAccelFlush);
1860 case VMMDevReq_VideoSetVisibleRegion:
1861 /* The original protocol didn't consider a guest with NO visible
1862 * windows */
1863 return sizeof(VMMDevVideoSetVisibleRegion) - sizeof(RTRECT);
1864 case VMMDevReq_GetSeamlessChangeRequest:
1865 return sizeof(VMMDevSeamlessChangeRequest);
1866 case VMMDevReq_QueryCredentials:
1867 return sizeof(VMMDevCredentials);
1868 case VMMDevReq_ReportGuestStats:
1869 return sizeof(VMMDevReportGuestStats);
1870 case VMMDevReq_GetMemBalloonChangeRequest:
1871 return sizeof(VMMDevGetMemBalloonChangeRequest);
1872 case VMMDevReq_GetStatisticsChangeRequest:
1873 return sizeof(VMMDevGetStatisticsChangeRequest);
1874 case VMMDevReq_ChangeMemBalloon:
1875 return sizeof(VMMDevChangeMemBalloon);
1876 case VMMDevReq_GetVRDPChangeRequest:
1877 return sizeof(VMMDevVRDPChangeRequest);
1878 case VMMDevReq_LogString:
1879 return sizeof(VMMDevReqLogString);
1880 case VMMDevReq_CtlGuestFilterMask:
1881 return sizeof(VMMDevCtlGuestFilterMask);
1882 case VMMDevReq_GetCpuHotPlugRequest:
1883 return sizeof(VMMDevGetCpuHotPlugRequest);
1884 case VMMDevReq_SetCpuHotPlugStatus:
1885 return sizeof(VMMDevCpuHotPlugStatusRequest);
1886 case VMMDevReq_RegisterSharedModule:
1887 return sizeof(VMMDevSharedModuleRegistrationRequest);
1888 case VMMDevReq_UnregisterSharedModule:
1889 return sizeof(VMMDevSharedModuleUnregistrationRequest);
1890 case VMMDevReq_CheckSharedModules:
1891 return sizeof(VMMDevSharedModuleCheckRequest);
1892 case VMMDevReq_GetPageSharingStatus:
1893 return sizeof(VMMDevPageSharingStatusRequest);
1894 case VMMDevReq_DebugIsPageShared:
1895 return sizeof(VMMDevPageIsSharedRequest);
1896 case VMMDevReq_GetSessionId:
1897 return sizeof(VMMDevReqSessionId);
1898 default:
1899 return 0;
1900 }
1901}
1902
1903
1904/**
1905 * Initializes a request structure.
1906 *
1907 * @returns VBox status code.
1908 * @param req The request structure to initialize.
1909 * @param type The request type.
1910 */
1911DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
1912{
1913 uint32_t requestSize;
1914 if (!req)
1915 return VERR_INVALID_PARAMETER;
1916 requestSize = (uint32_t)vmmdevGetRequestSize(type);
1917 if (!requestSize)
1918 return VERR_INVALID_PARAMETER;
1919 req->size = requestSize;
1920 req->version = VMMDEV_REQUEST_HEADER_VERSION;
1921 req->requestType = type;
1922 req->rc = VERR_GENERAL_FAILURE;
1923 req->reserved1 = 0;
1924 req->reserved2 = 0;
1925 return VINF_SUCCESS;
1926}
1927
1928/** @} */
1929
1930
1931/**
1932 * VBVA command header.
1933 *
1934 * @todo Where does this fit in?
1935 */
1936#pragma pack(1) /* unnecessary */
1937typedef struct VBVACMDHDR
1938{
1939 /** Coordinates of affected rectangle. */
1940 int16_t x;
1941 int16_t y;
1942 uint16_t w;
1943 uint16_t h;
1944} VBVACMDHDR;
1945#pragma pack()
1946
1947/** @name VBVA ring defines.
1948 *
1949 * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of
1950 * data. For example big bitmaps which do not fit to the buffer.
1951 *
1952 * Guest starts writing to the buffer by initializing a record entry in the
1953 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
1954 * written. As data is written to the ring buffer, the guest increases off32End
1955 * for the record.
1956 *
1957 * The host reads the aRecords on flushes and processes all completed records.
1958 * When host encounters situation when only a partial record presents and
1959 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE -
1960 * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates
1961 * off32Head. After that on each flush the host continues fetching the data
1962 * until the record is completed.
1963 *
1964 */
1965#define VBVA_RING_BUFFER_SIZE (_4M - _1K)
1966#define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
1967
1968#define VBVA_MAX_RECORDS (64)
1969
1970#define VBVA_F_MODE_ENABLED (0x00000001)
1971#define VBVA_F_MODE_VRDP (0x00000002)
1972#define VBVA_F_MODE_VRDP_RESET (0x00000004)
1973#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
1974
1975#define VBVA_F_RECORD_PARTIAL (0x80000000)
1976/** @} */
1977
1978/**
1979 * VBVA record.
1980 */
1981typedef struct VBVARECORD
1982{
1983 /** The length of the record. Changed by guest. */
1984 uint32_t cbRecord;
1985} VBVARECORD;
1986AssertCompileSize(VBVARECORD, 4);
1987
1988
1989/**
1990 * VBVA memory layout.
1991 *
1992 * This is a subsection of the VMMDevMemory structure.
1993 */
1994#pragma pack(1) /* paranoia */
1995typedef struct VBVAMEMORY
1996{
1997 /** VBVA_F_MODE_*. */
1998 uint32_t fu32ModeFlags;
1999
2000 /** The offset where the data start in the buffer. */
2001 uint32_t off32Data;
2002 /** The offset where next data must be placed in the buffer. */
2003 uint32_t off32Free;
2004
2005 /** The ring buffer for data. */
2006 uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
2007
2008 /** The queue of record descriptions. */
2009 VBVARECORD aRecords[VBVA_MAX_RECORDS];
2010 uint32_t indexRecordFirst;
2011 uint32_t indexRecordFree;
2012
2013 /** RDP orders supported by the client. The guest reports only them
2014 * and falls back to DIRTY rects for not supported ones.
2015 *
2016 * (1 << VBVA_VRDP_*)
2017 */
2018 uint32_t fu32SupportedOrders;
2019
2020} VBVAMEMORY;
2021#pragma pack()
2022AssertCompileSize(VBVAMEMORY, 12 + (_4M-_1K) + 4*64 + 12);
2023
2024
2025/**
2026 * The layout of VMMDEV RAM region that contains information for guest.
2027 */
2028#pragma pack(1) /* paranoia */
2029typedef struct VMMDevMemory
2030{
2031 /** The size of this structure. */
2032 uint32_t u32Size;
2033 /** The structure version. (VMMDEV_MEMORY_VERSION) */
2034 uint32_t u32Version;
2035
2036 union
2037 {
2038 struct
2039 {
2040 /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
2041 bool fHaveEvents;
2042 } V1_04;
2043
2044 struct
2045 {
2046 /** Pending events flags, set by host. */
2047 uint32_t u32HostEvents;
2048 /** Mask of events the guest wants to see, set by guest. */
2049 uint32_t u32GuestEventMask;
2050 } V1_03;
2051 } V;
2052
2053 VBVAMEMORY vbvaMemory;
2054
2055} VMMDevMemory;
2056AssertCompileSize(VMMDevMemory, 8+8 + (12 + (_4M-_1K) + 4*64 + 12) );
2057#pragma pack()
2058
2059/** Version of VMMDevMemory structure (VMMDevMemory::u32Version). */
2060#define VMMDEV_MEMORY_VERSION (1)
2061
2062/** @} */
2063RT_C_DECLS_END
2064
2065#endif
2066
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