VirtualBox

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

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

VMMDev.h: UINT32_C() instead of const-1.

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

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