VirtualBox

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

Last change on this file since 29567 was 29344, checked in by vboxsync, 15 years ago

Always include page sharing

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