VirtualBox

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

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

VideoModeSupported for multimonitor. (xTracker 4655)

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