VirtualBox

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

Last change on this file since 21485 was 21463, checked in by vboxsync, 16 years ago

VMMDev.h: doxygen

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