VirtualBox

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

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

HGCM&Co: physical page list.

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

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