VirtualBox

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

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

VBoxGuest,VMMDev: New HGCM cancellation request.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 47.0 KB
Line 
1/** @file
2 * Virtual Device for Guest <-> VMM/Host communication (ADD,DEV).
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_VMMDev_h
31#define ___VBox_VMMDev_h
32
33#include <VBox/cdefs.h>
34#include <VBox/param.h> /* for the PCI IDs. */
35#include <VBox/types.h>
36#include <VBox/err.h>
37#include <VBox/ostypes.h>
38#include <VBox/VMMDev2.h>
39#include <iprt/assert.h>
40
41
42RT_C_DECLS_BEGIN
43
44/** @defgroup grp_vmmdev VMM Device
45 *
46 * Note! This interface cannot be changed, it can only be extended!
47 *
48 * @{
49 */
50
51
52/** Size of VMMDev RAM region accessible by guest.
53 * Must be big enough to contain VMMDevMemory structure (see further down).
54 * For now: 4 megabyte.
55 */
56#define VMMDEV_RAM_SIZE (4 * 256 * PAGE_SIZE)
57
58/** Size of VMMDev heap region accessible by guest.
59 * (Must be a power of two (pci range).)
60 */
61#define VMMDEV_HEAP_SIZE (4 * PAGE_SIZE)
62
63/** Port for generic request interface (relative offset). */
64#define VMMDEV_PORT_OFF_REQUEST 0
65
66
67/** @name VMMDev events.
68 *
69 * Used mainly by VMMDevReq_AcknowledgeEvents/VMMDevEvents and version 1.3 of
70 * VMMDevMemory.
71 *
72 * @{
73 */
74/** Host mouse capabilities has been changed. */
75#define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED RT_BIT(0)
76/** HGCM event. */
77#define VMMDEV_EVENT_HGCM RT_BIT(1)
78/** A display change request has been issued. */
79#define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST RT_BIT(2)
80/** Credentials are available for judgement. */
81#define VMMDEV_EVENT_JUDGE_CREDENTIALS RT_BIT(3)
82/** The guest has been restored. */
83#define VMMDEV_EVENT_RESTORED RT_BIT(4)
84/** Seamless mode state changed. */
85#define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST RT_BIT(5)
86/** Memory balloon size changed. */
87#define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST RT_BIT(6)
88/** Statistics interval changed. */
89#define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST RT_BIT(7)
90/** VRDP status changed. */
91#define VMMDEV_EVENT_VRDP RT_BIT(8)
92/** New mouse position data available */
93#define VMMDEV_EVENT_MOUSE_POSITION_CHANGED RT_BIT(9)
94/** @} */
95
96
97/** @defgroup grp_vmmdev_req VMMDev Generic Request Interface
98 * @{
99 */
100
101/** @name Current version of the VMMDev interface.
102 *
103 * Additions are allowed to work only if
104 * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
105 * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
106 *
107 * @remarks These defines also live in the 16-bit and assembly versions of this
108 * header.
109 */
110#define VMMDEV_VERSION 0x00010004
111#define VMMDEV_VERSION_MAJOR (VMMDEV_VERSION >> 16)
112#define VMMDEV_VERSION_MINOR (VMMDEV_VERSION & 0xffff)
113/** @} */
114
115/** Maximum request packet size. */
116#define VMMDEV_MAX_VMMDEVREQ_SIZE _1M
117
118/**
119 * VMMDev request types.
120 * @note when updating this, adjust vmmdevGetRequestSize() as well
121 */
122typedef enum
123{
124 VMMDevReq_InvalidRequest = 0,
125 VMMDevReq_GetMouseStatus = 1,
126 VMMDevReq_SetMouseStatus = 2,
127 VMMDevReq_SetPointerShape = 3,
128 VMMDevReq_GetHostVersion = 4,
129 VMMDevReq_Idle = 5,
130 VMMDevReq_GetHostTime = 10,
131 VMMDevReq_GetHypervisorInfo = 20,
132 VMMDevReq_SetHypervisorInfo = 21,
133 VMMDevReq_SetPowerStatus = 30,
134 VMMDevReq_AcknowledgeEvents = 41,
135 VMMDevReq_CtlGuestFilterMask = 42,
136 VMMDevReq_ReportGuestInfo = 50,
137 VMMDevReq_GetDisplayChangeRequest = 51,
138 VMMDevReq_VideoModeSupported = 52,
139 VMMDevReq_GetHeightReduction = 53,
140 VMMDevReq_GetDisplayChangeRequest2 = 54,
141 VMMDevReq_ReportGuestCapabilities = 55,
142 VMMDevReq_SetGuestCapabilities = 56,
143#ifdef VBOX_WITH_HGCM
144 VMMDevReq_HGCMConnect = 60,
145 VMMDevReq_HGCMDisconnect = 61,
146#ifdef VBOX_WITH_64_BITS_GUESTS
147 VMMDevReq_HGCMCall32 = 62,
148 VMMDevReq_HGCMCall64 = 63,
149#else
150 VMMDevReq_HGCMCall = 62,
151#endif /* VBOX_WITH_64_BITS_GUESTS */
152 VMMDevReq_HGCMCancel = 64,
153 VMMDevReq_HGCMCancel2 = 65,
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 page lists are supported by HGCM. */
365#define VMMDEV_HVF_HGCM_PHYS_PAGE_LIST 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 RT_BIT_32(VBOX_HGCM_REQ_DONE_BIT)
957# define VBOX_HGCM_REQ_DONE_BIT 0
958# define VBOX_HGCM_REQ_CANCELLED (0x2)
959/** @} */
960
961# pragma pack(4)
962
963/**
964 * HGCM request header.
965 */
966typedef struct VMMDevHGCMRequestHeader
967{
968 /** Request header. */
969 VMMDevRequestHeader header;
970
971 /** HGCM flags. */
972 uint32_t fu32Flags;
973
974 /** Result code. */
975 int32_t result;
976} VMMDevHGCMRequestHeader;
977AssertCompileSize(VMMDevHGCMRequestHeader, 24+8);
978
979/**
980 * HGCM connect request structure.
981 *
982 * Used by VMMDevReq_HGCMConnect.
983 */
984typedef struct
985{
986 /** HGCM request header. */
987 VMMDevHGCMRequestHeader header;
988
989 /** IN: Description of service to connect to. */
990 HGCMServiceLocation loc;
991
992 /** OUT: Client identifier assigned by local instance of HGCM. */
993 uint32_t u32ClientID;
994} VMMDevHGCMConnect;
995AssertCompileSize(VMMDevHGCMConnect, 32+132+4);
996
997
998/**
999 * HGCM disconnect request structure.
1000 *
1001 * Used by VMMDevReq_HGCMDisconnect.
1002 */
1003typedef struct
1004{
1005 /** HGCM request header. */
1006 VMMDevHGCMRequestHeader header;
1007
1008 /** IN: Client identifier. */
1009 uint32_t u32ClientID;
1010} VMMDevHGCMDisconnect;
1011AssertCompileSize(VMMDevHGCMDisconnect, 32+4);
1012
1013/**
1014 * HGCM parameter type.
1015 */
1016typedef enum
1017{
1018 VMMDevHGCMParmType_Invalid = 0,
1019 VMMDevHGCMParmType_32bit = 1,
1020 VMMDevHGCMParmType_64bit = 2,
1021 VMMDevHGCMParmType_PhysAddr = 3, /**< @deprecated Doesn't work, use PageList. */
1022 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
1023 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */
1024 VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */
1025 VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */
1026 VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */
1027 VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */
1028 VMMDevHGCMParmType_PageList = 10, /**< Physical addresses of locked pages for a buffer. */
1029 VMMDevHGCMParmType_SizeHack = 0x7fffffff
1030} HGCMFunctionParameterType;
1031AssertCompileSize(HGCMFunctionParameterType, 4);
1032
1033# ifdef VBOX_WITH_64_BITS_GUESTS
1034/**
1035 * HGCM function parameter, 32-bit client.
1036 */
1037typedef struct
1038{
1039 HGCMFunctionParameterType type;
1040 union
1041 {
1042 uint32_t value32;
1043 uint64_t value64;
1044 struct
1045 {
1046 uint32_t size;
1047
1048 union
1049 {
1050 RTGCPHYS32 physAddr;
1051 RTGCPTR32 linearAddr;
1052 } u;
1053 } Pointer;
1054 struct
1055 {
1056 uint32_t size; /**< Size of the buffer described by the page list. */
1057 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1058 } PageList;
1059 } u;
1060# ifdef __cplusplus
1061 void SetUInt32(uint32_t u32)
1062 {
1063 type = VMMDevHGCMParmType_32bit;
1064 u.value64 = 0; /* init unused bits to 0 */
1065 u.value32 = u32;
1066 }
1067
1068 int GetUInt32(uint32_t *pu32)
1069 {
1070 if (type == VMMDevHGCMParmType_32bit)
1071 {
1072 *pu32 = u.value32;
1073 return VINF_SUCCESS;
1074 }
1075 return VERR_INVALID_PARAMETER;
1076 }
1077
1078 void SetUInt64(uint64_t u64)
1079 {
1080 type = VMMDevHGCMParmType_64bit;
1081 u.value64 = u64;
1082 }
1083
1084 int GetUInt64(uint64_t *pu64)
1085 {
1086 if (type == VMMDevHGCMParmType_64bit)
1087 {
1088 *pu64 = u.value64;
1089 return VINF_SUCCESS;
1090 }
1091 return VERR_INVALID_PARAMETER;
1092 }
1093
1094 void SetPtr(void *pv, uint32_t cb)
1095 {
1096 type = VMMDevHGCMParmType_LinAddr;
1097 u.Pointer.size = cb;
1098 u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv;
1099 }
1100# endif /* __cplusplus */
1101} HGCMFunctionParameter32;
1102AssertCompileSize(HGCMFunctionParameter32, 4+8);
1103
1104/**
1105 * HGCM function parameter, 64-bit client.
1106 */
1107typedef struct
1108{
1109 HGCMFunctionParameterType type;
1110 union
1111 {
1112 uint32_t value32;
1113 uint64_t value64;
1114 struct
1115 {
1116 uint32_t size;
1117
1118 union
1119 {
1120 RTGCPHYS64 physAddr;
1121 RTGCPTR64 linearAddr;
1122 } u;
1123 } Pointer;
1124 struct
1125 {
1126 uint32_t size; /**< Size of the buffer described by the page list. */
1127 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1128 } PageList;
1129 } u;
1130# ifdef __cplusplus
1131 void SetUInt32(uint32_t u32)
1132 {
1133 type = VMMDevHGCMParmType_32bit;
1134 u.value64 = 0; /* init unused bits to 0 */
1135 u.value32 = u32;
1136 }
1137
1138 int GetUInt32(uint32_t *pu32)
1139 {
1140 if (type == VMMDevHGCMParmType_32bit)
1141 {
1142 *pu32 = u.value32;
1143 return VINF_SUCCESS;
1144 }
1145 return VERR_INVALID_PARAMETER;
1146 }
1147
1148 void SetUInt64(uint64_t u64)
1149 {
1150 type = VMMDevHGCMParmType_64bit;
1151 u.value64 = u64;
1152 }
1153
1154 int GetUInt64(uint64_t *pu64)
1155 {
1156 if (type == VMMDevHGCMParmType_64bit)
1157 {
1158 *pu64 = u.value64;
1159 return VINF_SUCCESS;
1160 }
1161 return VERR_INVALID_PARAMETER;
1162 }
1163
1164 void SetPtr(void *pv, uint32_t cb)
1165 {
1166 type = VMMDevHGCMParmType_LinAddr;
1167 u.Pointer.size = cb;
1168 u.Pointer.u.linearAddr = (uintptr_t)pv;
1169 }
1170# endif /** __cplusplus */
1171} HGCMFunctionParameter64;
1172AssertCompileSize(HGCMFunctionParameter64, 4+12);
1173
1174/* Redefine the structure type for the guest code. */
1175# ifndef VBOX_HGCM_HOST_CODE
1176# if ARCH_BITS == 64
1177# define HGCMFunctionParameter HGCMFunctionParameter64
1178# elif ARCH_BITS == 32
1179# define HGCMFunctionParameter HGCMFunctionParameter32
1180# else
1181# error "Unsupported sizeof (void *)"
1182# endif
1183# endif /* !VBOX_HGCM_HOST_CODE */
1184
1185# else /* !VBOX_WITH_64_BITS_GUESTS */
1186
1187/**
1188 * HGCM function parameter, 32-bit client.
1189 *
1190 * @todo If this is the same as HGCMFunctionParameter32, why the duplication?
1191 */
1192typedef struct
1193{
1194 HGCMFunctionParameterType type;
1195 union
1196 {
1197 uint32_t value32;
1198 uint64_t value64;
1199 struct
1200 {
1201 uint32_t size;
1202
1203 union
1204 {
1205 RTGCPHYS32 physAddr;
1206 RTGCPTR32 linearAddr;
1207 } u;
1208 } Pointer;
1209 struct
1210 {
1211 uint32_t size; /**< Size of the buffer described by the page list. */
1212 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
1213 } PageList;
1214 } u;
1215# ifdef __cplusplus
1216 void SetUInt32(uint32_t u32)
1217 {
1218 type = VMMDevHGCMParmType_32bit;
1219 u.value64 = 0; /* init unused bits to 0 */
1220 u.value32 = u32;
1221 }
1222
1223 int GetUInt32(uint32_t *pu32)
1224 {
1225 if (type == VMMDevHGCMParmType_32bit)
1226 {
1227 *pu32 = u.value32;
1228 return VINF_SUCCESS;
1229 }
1230 return VERR_INVALID_PARAMETER;
1231 }
1232
1233 void SetUInt64(uint64_t u64)
1234 {
1235 type = VMMDevHGCMParmType_64bit;
1236 u.value64 = u64;
1237 }
1238
1239 int GetUInt64(uint64_t *pu64)
1240 {
1241 if (type == VMMDevHGCMParmType_64bit)
1242 {
1243 *pu64 = u.value64;
1244 return VINF_SUCCESS;
1245 }
1246 return VERR_INVALID_PARAMETER;
1247 }
1248
1249 void SetPtr(void *pv, uint32_t cb)
1250 {
1251 type = VMMDevHGCMParmType_LinAddr;
1252 u.Pointer.size = cb;
1253 u.Pointer.u.linearAddr = (uintptr_t)pv;
1254 }
1255# endif /* __cplusplus */
1256} HGCMFunctionParameter;
1257AssertCompileSize(HGCMFunctionParameter, 4+8);
1258# endif /* !VBOX_WITH_64_BITS_GUESTS */
1259
1260/**
1261 * HGCM call request structure.
1262 *
1263 * Used by VMMDevReq_HGCMCall, VMMDevReq_HGCMCall32 and VMMDevReq_HGCMCall64.
1264 */
1265typedef struct
1266{
1267 /* request header */
1268 VMMDevHGCMRequestHeader header;
1269
1270 /** IN: Client identifier. */
1271 uint32_t u32ClientID;
1272 /** IN: Service function number. */
1273 uint32_t u32Function;
1274 /** IN: Number of parameters. */
1275 uint32_t cParms;
1276 /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
1277} VMMDevHGCMCall;
1278AssertCompileSize(VMMDevHGCMCall, 32+12);
1279
1280/** @name Direction of data transfer (HGCMPageListInfo::flags). Bit flags.
1281 * @{ */
1282#define VBOX_HGCM_F_PARM_DIRECTION_NONE UINT32_C(0x00000000)
1283#define VBOX_HGCM_F_PARM_DIRECTION_TO_HOST UINT32_C(0x00000001)
1284#define VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST UINT32_C(0x00000002)
1285#define VBOX_HGCM_F_PARM_DIRECTION_BOTH UINT32_C(0x00000003)
1286/** Macro for validating that the specified flags are valid. */
1287#define VBOX_HGCM_F_PARM_ARE_VALID(fFlags) \
1288 ( (fFlags) > VBOX_HGCM_F_PARM_DIRECTION_NONE \
1289 && (fFlags) < VBOX_HGCM_F_PARM_DIRECTION_BOTH )
1290/** @} */
1291
1292/**
1293 * VMMDevHGCMParmType_PageList points to this structure to actually describe the
1294 * buffer.
1295 */
1296typedef struct
1297{
1298 uint32_t flags; /**< VBOX_HGCM_F_PARM_*. */
1299 uint16_t offFirstPage; /**< Offset in the first page where data begins. */
1300 uint16_t cPages; /**< Number of pages. */
1301 RTGCPHYS64 aPages[1]; /**< Page addesses. */
1302} HGCMPageListInfo;
1303AssertCompileSize(HGCMPageListInfo, 4+2+2+8);
1304
1305# pragma pack()
1306
1307/** Get the pointer to the first parmater of a HGCM call request. */
1308# define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1309/** Get the pointer to the first parmater of a 32-bit HGCM call request. */
1310# define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1311
1312# ifdef VBOX_WITH_64_BITS_GUESTS
1313/* Explicit defines for the host code. */
1314# ifdef VBOX_HGCM_HOST_CODE
1315# define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1316# define VMMDEV_HGCM_CALL_PARMS64(a) ((HGCMFunctionParameter64 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
1317# endif /* VBOX_HGCM_HOST_CODE */
1318# endif /* VBOX_WITH_64_BITS_GUESTS */
1319
1320# define VBOX_HGCM_MAX_PARMS 32
1321
1322/**
1323 * HGCM cancel request structure.
1324 *
1325 * The Cancel request is issued using the same physical memory address as was
1326 * used for the corresponding initial HGCMCall.
1327 *
1328 * Used by VMMDevReq_HGCMCancel.
1329 */
1330typedef struct
1331{
1332 /** Header. */
1333 VMMDevHGCMRequestHeader header;
1334} VMMDevHGCMCancel;
1335AssertCompileSize(VMMDevHGCMCancel, 32);
1336
1337/**
1338 * HGCM cancel request structure, version 2.
1339 *
1340 * Used by VMMDevReq_HGCMCancel2.
1341 *
1342 * VINF_SUCCESS when cancelled.
1343 * VERR_NOT_FOUND if the specified request cannot be found.
1344 * VERR_INVALID_PARAMETER if the address is invalid valid.
1345 */
1346typedef struct
1347{
1348 /** Header. */
1349 VMMDevRequestHeader header;
1350 /** The physical address of the request to cancel. */
1351 RTGCPHYS32 physReqToCancel;
1352} VMMDevHGCMCancel2;
1353AssertCompileSize(VMMDevHGCMCancel2, 24+4);
1354
1355#endif /* VBOX_WITH_HGCM */
1356
1357
1358/**
1359 * Inline helper to determine the request size for the given operation.
1360 *
1361 * @returns Size.
1362 * @param requestType The VMMDev request type.
1363 */
1364DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
1365{
1366 switch (requestType)
1367 {
1368 case VMMDevReq_GetMouseStatus:
1369 case VMMDevReq_SetMouseStatus:
1370 return sizeof(VMMDevReqMouseStatus);
1371 case VMMDevReq_SetPointerShape:
1372 return sizeof(VMMDevReqMousePointer);
1373 case VMMDevReq_GetHostVersion:
1374 return sizeof(VMMDevReqHostVersion);
1375 case VMMDevReq_Idle:
1376 return sizeof(VMMDevReqIdle);
1377 case VMMDevReq_GetHostTime:
1378 return sizeof(VMMDevReqHostTime);
1379 case VMMDevReq_GetHypervisorInfo:
1380 case VMMDevReq_SetHypervisorInfo:
1381 return sizeof(VMMDevReqHypervisorInfo);
1382 case VMMDevReq_SetPowerStatus:
1383 return sizeof(VMMDevPowerStateRequest);
1384 case VMMDevReq_AcknowledgeEvents:
1385 return sizeof(VMMDevEvents);
1386 case VMMDevReq_ReportGuestInfo:
1387 return sizeof(VMMDevReportGuestInfo);
1388 case VMMDevReq_GetDisplayChangeRequest:
1389 return sizeof(VMMDevDisplayChangeRequest);
1390 case VMMDevReq_GetDisplayChangeRequest2:
1391 return sizeof(VMMDevDisplayChangeRequest2);
1392 case VMMDevReq_VideoModeSupported:
1393 return sizeof(VMMDevVideoModeSupportedRequest);
1394 case VMMDevReq_GetHeightReduction:
1395 return sizeof(VMMDevGetHeightReductionRequest);
1396 case VMMDevReq_ReportGuestCapabilities:
1397 return sizeof(VMMDevReqGuestCapabilities);
1398 case VMMDevReq_SetGuestCapabilities:
1399 return sizeof(VMMDevReqGuestCapabilities2);
1400#ifdef VBOX_WITH_HGCM
1401 case VMMDevReq_HGCMConnect:
1402 return sizeof(VMMDevHGCMConnect);
1403 case VMMDevReq_HGCMDisconnect:
1404 return sizeof(VMMDevHGCMDisconnect);
1405#ifdef VBOX_WITH_64_BITS_GUESTS
1406 case VMMDevReq_HGCMCall32:
1407 return sizeof(VMMDevHGCMCall);
1408 case VMMDevReq_HGCMCall64:
1409 return sizeof(VMMDevHGCMCall);
1410#else
1411 case VMMDevReq_HGCMCall:
1412 return sizeof(VMMDevHGCMCall);
1413#endif /* VBOX_WITH_64_BITS_GUESTS */
1414 case VMMDevReq_HGCMCancel:
1415 return sizeof(VMMDevHGCMCancel);
1416#endif /* VBOX_WITH_HGCM */
1417 case VMMDevReq_VideoAccelEnable:
1418 return sizeof(VMMDevVideoAccelEnable);
1419 case VMMDevReq_VideoAccelFlush:
1420 return sizeof(VMMDevVideoAccelFlush);
1421 case VMMDevReq_VideoSetVisibleRegion:
1422 return sizeof(VMMDevVideoSetVisibleRegion);
1423 case VMMDevReq_GetSeamlessChangeRequest:
1424 return sizeof(VMMDevSeamlessChangeRequest);
1425 case VMMDevReq_QueryCredentials:
1426 return sizeof(VMMDevCredentials);
1427 case VMMDevReq_ReportGuestStats:
1428 return sizeof(VMMDevReportGuestStats);
1429 case VMMDevReq_GetMemBalloonChangeRequest:
1430 return sizeof(VMMDevGetMemBalloonChangeRequest);
1431 case VMMDevReq_GetStatisticsChangeRequest:
1432 return sizeof(VMMDevGetStatisticsChangeRequest);
1433 case VMMDevReq_ChangeMemBalloon:
1434 return sizeof(VMMDevChangeMemBalloon);
1435 case VMMDevReq_GetVRDPChangeRequest:
1436 return sizeof(VMMDevVRDPChangeRequest);
1437 case VMMDevReq_LogString:
1438 return sizeof(VMMDevReqLogString);
1439 case VMMDevReq_CtlGuestFilterMask:
1440 return sizeof(VMMDevCtlGuestFilterMask);
1441 default:
1442 return 0;
1443 }
1444}
1445
1446
1447/**
1448 * Initializes a request structure.
1449 *
1450 * @returns VBox status code.
1451 * @param req The request structure to initialize.
1452 * @param type The request type.
1453 */
1454DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
1455{
1456 uint32_t requestSize;
1457 if (!req)
1458 return VERR_INVALID_PARAMETER;
1459 requestSize = (uint32_t)vmmdevGetRequestSize(type);
1460 if (!requestSize)
1461 return VERR_INVALID_PARAMETER;
1462 req->size = requestSize;
1463 req->version = VMMDEV_REQUEST_HEADER_VERSION;
1464 req->requestType = type;
1465 req->rc = VERR_GENERAL_FAILURE;
1466 req->reserved1 = 0;
1467 req->reserved2 = 0;
1468 return VINF_SUCCESS;
1469}
1470
1471/** @} */
1472
1473
1474/**
1475 * VBVA command header.
1476 *
1477 * @todo Where does this fit in?
1478 */
1479#pragma pack(1) /* unnecessary */
1480typedef struct VBVACMDHDR
1481{
1482 /** Coordinates of affected rectangle. */
1483 int16_t x;
1484 int16_t y;
1485 uint16_t w;
1486 uint16_t h;
1487} VBVACMDHDR;
1488#pragma pack()
1489
1490/** @name VBVA ring defines.
1491 *
1492 * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of
1493 * data. For example big bitmaps which do not fit to the buffer.
1494 *
1495 * Guest starts writing to the buffer by initializing a record entry in the
1496 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
1497 * written. As data is written to the ring buffer, the guest increases off32End
1498 * for the record.
1499 *
1500 * The host reads the aRecords on flushes and processes all completed records.
1501 * When host encounters situation when only a partial record presents and
1502 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE -
1503 * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates
1504 * off32Head. After that on each flush the host continues fetching the data
1505 * until the record is completed.
1506 *
1507 */
1508#define VBVA_RING_BUFFER_SIZE (_4M - _1K)
1509#define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
1510
1511#define VBVA_MAX_RECORDS (64)
1512
1513#define VBVA_F_MODE_ENABLED (0x00000001)
1514#define VBVA_F_MODE_VRDP (0x00000002)
1515#define VBVA_F_MODE_VRDP_RESET (0x00000004)
1516#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
1517
1518#define VBVA_F_RECORD_PARTIAL (0x80000000)
1519/** @} */
1520
1521/**
1522 * VBVA record.
1523 */
1524typedef struct
1525{
1526 /** The length of the record. Changed by guest. */
1527 uint32_t cbRecord;
1528} VBVARECORD;
1529AssertCompileSize(VBVARECORD, 4);
1530
1531
1532/**
1533 * VBVA memory layout.
1534 *
1535 * This is a subsection of the VMMDevMemory structure.
1536 */
1537#pragma pack(1) /* paranoia */
1538typedef struct VBVAMEMORY
1539{
1540 /** VBVA_F_MODE_*. */
1541 uint32_t fu32ModeFlags;
1542
1543 /** The offset where the data start in the buffer. */
1544 uint32_t off32Data;
1545 /** The offset where next data must be placed in the buffer. */
1546 uint32_t off32Free;
1547
1548 /** The ring buffer for data. */
1549 uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
1550
1551 /** The queue of record descriptions. */
1552 VBVARECORD aRecords[VBVA_MAX_RECORDS];
1553 uint32_t indexRecordFirst;
1554 uint32_t indexRecordFree;
1555
1556 /** RDP orders supported by the client. The guest reports only them
1557 * and falls back to DIRTY rects for not supported ones.
1558 *
1559 * (1 << VBVA_VRDP_*)
1560 */
1561 uint32_t fu32SupportedOrders;
1562
1563} VBVAMEMORY;
1564#pragma pack()
1565AssertCompileSize(VBVAMEMORY, 12 + (_4M-_1K) + 4*64 + 12);
1566
1567
1568/**
1569 * The layout of VMMDEV RAM region that contains information for guest.
1570 */
1571#pragma pack(1) /* paranoia */
1572typedef struct VMMDevMemory
1573{
1574 /** The size of this structure. */
1575 uint32_t u32Size;
1576 /** The structure version. (VMMDEV_MEMORY_VERSION) */
1577 uint32_t u32Version;
1578
1579 union
1580 {
1581 struct
1582 {
1583 /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
1584 bool fHaveEvents;
1585 } V1_04;
1586
1587 struct
1588 {
1589 /** Pending events flags, set by host. */
1590 uint32_t u32HostEvents;
1591 /** Mask of events the guest wants to see, set by guest. */
1592 uint32_t u32GuestEventMask;
1593 } V1_03;
1594 } V;
1595
1596 VBVAMEMORY vbvaMemory;
1597
1598} VMMDevMemory;
1599AssertCompileSize(VMMDevMemory, 8+8 + (12 + (_4M-_1K) + 4*64 + 12) );
1600#pragma pack()
1601
1602/** Version of VMMDevMemory structure (VMMDevMemory::u32Version). */
1603#define VMMDEV_MEMORY_VERSION (1)
1604
1605
1606/** @} */
1607RT_C_DECLS_END
1608
1609#endif
1610
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