VirtualBox

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

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

Devices/VMMDev: new mouse capability flag VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR to say that the host supports the guest disabling VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR again

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette