VirtualBox

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

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

VMMDev.h: cleanup.

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