VirtualBox

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

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

Devices/VMMDev: inform the guest if we have an absolute pointing device

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