VirtualBox

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

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

VMMDev: Adjusted and implemented GetHostVersion.

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