VirtualBox

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

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

VBoxGuest.h/VMMDev.h/VBoxGuestLib.h usage cleanup.

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