VirtualBox

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

Last change on this file since 28404 was 28404, checked in by vboxsync, 15 years ago

Shared pages updates

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