VirtualBox

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

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

Shared paging interface updates

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

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