Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

VMMDev.h

Go to the documentation of this file.
/** @file
 * Virtual Device for Guest <-> VMM/Host communication (ADD,DEV).
 */

/*
 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 * VirtualBox OSE distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 * additional information or have any questions.
 */

#ifndef ___VBox_VMMDev_h
#define ___VBox_VMMDev_h

#include <VBox/cdefs.h>
#include <VBox/param.h>                 /* for the PCI IDs. */
#include <VBox/types.h>
#include <VBox/err.h>
#include <VBox/ostypes.h>
#include <VBox/VMMDev2.h>
#include <iprt/assert.h>


RT_C_DECLS_BEGIN

/** @defgroup grp_vmmdev    VMM Device
 *
 * Note! This interface cannot be changed, it can only be extended!
 *
 * @{
 */


/** Size of VMMDev RAM region accessible by guest.
 * Must be big enough to contain VMMDevMemory structure (see further down).
 * For now: 4 megabyte.
 */
00056 #define VMMDEV_RAM_SIZE                                     (4 * 256 * PAGE_SIZE)

/** Size of VMMDev heap region accessible by guest.
 *  (Must be a power of two (pci range).)
 */
00061 #define VMMDEV_HEAP_SIZE                                    (4 * PAGE_SIZE)

/** Port for generic request interface (relative offset). */
00064 #define VMMDEV_PORT_OFF_REQUEST                             0


/** @name VMMDev events.
 *
 * Used mainly by VMMDevReq_AcknowledgeEvents/VMMDevEvents and version 1.3 of
 * VMMDevMemory.
 *
 * @{
 */
/** Host mouse capabilities has been changed. */
00075 #define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED             RT_BIT(0)
/** HGCM event. */
00077 #define VMMDEV_EVENT_HGCM                                   RT_BIT(1)
/** A display change request has been issued. */
00079 #define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST                 RT_BIT(2)
/** Credentials are available for judgement. */
00081 #define VMMDEV_EVENT_JUDGE_CREDENTIALS                      RT_BIT(3)
/** The guest has been restored. */
00083 #define VMMDEV_EVENT_RESTORED                               RT_BIT(4)
/** Seamless mode state changed. */
00085 #define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST           RT_BIT(5)
/** Memory balloon size changed. */
00087 #define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST                 RT_BIT(6)
/** Statistics interval changed. */
00089 #define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST     RT_BIT(7)
/** VRDP status changed. */
00091 #define VMMDEV_EVENT_VRDP                                   RT_BIT(8)
/** New mouse position data available. */
00093 #define VMMDEV_EVENT_MOUSE_POSITION_CHANGED                 RT_BIT(9)
/** The mask of valid events, for sanity checking. */
00095 #define VMMDEV_EVENT_VALID_EVENT_MASK                       UINT32_C(0x000003ff)
/** @} */


/** @defgroup grp_vmmdev_req    VMMDev Generic Request Interface
 * @{
 */

/** @name Current version of the VMMDev interface.
 *
 * Additions are allowed to work only if
 * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
 * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
 *
 * @remarks These defines also live in the 16-bit and assembly versions of this
 *          header.
 */
#define VMMDEV_VERSION                      0x00010004
#define VMMDEV_VERSION_MAJOR                (VMMDEV_VERSION >> 16)
#define VMMDEV_VERSION_MINOR                (VMMDEV_VERSION & 0xffff)
/** @} */

/** Maximum request packet size. */
00118 #define VMMDEV_MAX_VMMDEVREQ_SIZE           _1M

/**
 * VMMDev request types.
 * @note when updating this, adjust vmmdevGetRequestSize() as well
 */
00124 typedef enum
{
    VMMDevReq_InvalidRequest             =  0,
    VMMDevReq_GetMouseStatus             =  1,
    VMMDevReq_SetMouseStatus             =  2,
    VMMDevReq_SetPointerShape            =  3,
    VMMDevReq_GetHostVersion             =  4,
    VMMDevReq_Idle                       =  5,
    VMMDevReq_GetHostTime                = 10,
    VMMDevReq_GetHypervisorInfo          = 20,
    VMMDevReq_SetHypervisorInfo          = 21,
    VMMDevReq_RegisterPatchMemory             = 22,
    VMMDevReq_DeregisterPatchMemory           = 23,
    VMMDevReq_SetPowerStatus             = 30,
    VMMDevReq_AcknowledgeEvents          = 41,
    VMMDevReq_CtlGuestFilterMask         = 42,
    VMMDevReq_ReportGuestInfo            = 50,
    VMMDevReq_GetDisplayChangeRequest    = 51,
    VMMDevReq_VideoModeSupported         = 52,
    VMMDevReq_GetHeightReduction         = 53,
    VMMDevReq_GetDisplayChangeRequest2   = 54,
    VMMDevReq_ReportGuestCapabilities    = 55,
    VMMDevReq_SetGuestCapabilities       = 56,
#ifdef VBOX_WITH_HGCM
    VMMDevReq_HGCMConnect                = 60,
    VMMDevReq_HGCMDisconnect             = 61,
#ifdef VBOX_WITH_64_BITS_GUESTS
    VMMDevReq_HGCMCall32                 = 62,
    VMMDevReq_HGCMCall64                 = 63,
#else
    VMMDevReq_HGCMCall                   = 62,
#endif /* VBOX_WITH_64_BITS_GUESTS */
    VMMDevReq_HGCMCancel                 = 64,
    VMMDevReq_HGCMCancel2                = 65,
#endif
    VMMDevReq_VideoAccelEnable           = 70,
    VMMDevReq_VideoAccelFlush            = 71,
    VMMDevReq_VideoSetVisibleRegion      = 72,
    VMMDevReq_GetSeamlessChangeRequest   = 73,
    VMMDevReq_QueryCredentials           = 100,
    VMMDevReq_ReportCredentialsJudgement = 101,
    VMMDevReq_ReportGuestStats           = 110,
    VMMDevReq_GetMemBalloonChangeRequest = 111,
    VMMDevReq_GetStatisticsChangeRequest = 112,
    VMMDevReq_ChangeMemBalloon           = 113,
    VMMDevReq_GetVRDPChangeRequest       = 150,
    VMMDevReq_LogString                  = 200,
    VMMDevReq_SizeHack                   = 0x7fffffff
} VMMDevRequestType;

#ifdef VBOX_WITH_64_BITS_GUESTS
/*
 * Constants and structures are redefined for the guest.
 *
 * Host code MUST always use either *32 or *64 variant explicitely.
 * Host source code will use VBOX_HGCM_HOST_CODE define to catch undefined
 * data types and constants.
 *
 * This redefinition means that the new additions builds will use
 * the *64 or *32 variants depending on the current architecture bit count (ARCH_BITS).
 */
# ifndef VBOX_HGCM_HOST_CODE
#  if ARCH_BITS == 64
#   define VMMDevReq_HGCMCall VMMDevReq_HGCMCall64
#  elif ARCH_BITS == 32
#   define VMMDevReq_HGCMCall VMMDevReq_HGCMCall32
#  else
#   error "Unsupported ARCH_BITS"
#  endif
# endif /* !VBOX_HGCM_HOST_CODE */
#endif /* VBOX_WITH_64_BITS_GUESTS */

/** Version of VMMDevRequestHeader structure. */
00197 #define VMMDEV_REQUEST_HEADER_VERSION (0x10001)

#pragma pack(4) /* force structure dword packing here. */

/**
 * Generic VMMDev request header.
 */
00204 typedef struct
{
    /** IN: Size of the structure in bytes (including body). */
00207     uint32_t size;
    /** IN: Version of the structure.  */
00209     uint32_t version;
    /** IN: Type of the request. */
00211     VMMDevRequestType requestType;
    /** OUT: Return code. */
00213     int32_t  rc;
    /** Reserved field no.1. MBZ. */
00215     uint32_t reserved1;
    /** Reserved field no.2. MBZ. */
00217     uint32_t reserved2;
} VMMDevRequestHeader;
AssertCompileSize(VMMDevRequestHeader, 24);


/**
 * Mouse status request structure.
 *
 * Used by VMMDevReq_GetMouseStatus and VMMDevReq_SetMouseStatus.
 */
00227 typedef struct
{
    /** header */
00230     VMMDevRequestHeader header;
    /** Mouse feature mask. See VMMDEV_MOUSE_*. */
00232     uint32_t mouseFeatures;
    /** Mouse x position. */
00234     uint32_t pointerXPos;
    /** Mouse y position. */
00236     uint32_t pointerYPos;
} VMMDevReqMouseStatus;
AssertCompileSize(VMMDevReqMouseStatus, 24+12);

/** @name Mouse capability bits (VMMDevReqMouseStatus::mouseFeatures).
 * @{ */
/** The guest can (== wants to) handle absolute coordinates.  */
00243 #define VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE                     RT_BIT(0)
/** The host can (== wants to) send absolute coordinates.
 * (Input not captured.) */
00246 #define VMMDEV_MOUSE_HOST_CAN_ABSOLUTE                      RT_BIT(1)
/** The guest can *NOT* switch to software cursor and therefore depends on the
 * host cursor.
 *
 * When guest additions are installed and the host has promised to display the
 * cursor itself, the guest installs a hardware mouse driver. Don't ask the
 * guest to switch to a software cursor then. */
00253 #define VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR                RT_BIT(2)
/** The host does NOT provide support for drawing the cursor itself.
 * This is for instance the case for the L4 console. */
00256 #define VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER                  RT_BIT(3)
/** The guest can read VMMDev events to find out about pointer movement */
00258 #define VMMDEV_MOUSE_GUEST_USES_VMMDEV                      RT_BIT(4)
/** If the guest changes the status of the
 * VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR bit, the host will honour this */
00261 #define VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR        RT_BIT(5)
/** The mask of all VMMDEV_MOUSE_* flags */
00263 #define VMMDEV_MOUSE_MASK                                   UINT32_C(0x0000003f)
/** The mask of guest capability changes for which notification events should
 * be sent */
00266 #define VMMDEV_MOUSE_NOTIFY_HOST_MASK \
      (VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR)
/** The mask of all capabilities which the guest can legitimately change */
00269 #define VMMDEV_MOUSE_GUEST_MASK \
      (VMMDEV_MOUSE_NOTIFY_HOST_MASK | VMMDEV_MOUSE_GUEST_USES_VMMDEV)
/** @} */


/**
 * Mouse pointer shape/visibility change request.
 *
 * Used by VMMDevReq_SetPointerShape. The size is variable.
 */
00279 typedef struct VMMDevReqMousePointer
{
    /** Header. */
00282     VMMDevRequestHeader header;
    /** VBOX_MOUSE_POINTER_* bit flags. */
00284     uint32_t fFlags;
    /** x coordinate of hot spot. */
00286     uint32_t xHot;
    /** y coordinate of hot spot. */
00288     uint32_t yHot;
    /** Width of the pointer in pixels. */
00290     uint32_t width;
    /** Height of the pointer in scanlines. */
00292     uint32_t height;
    /** Pointer data.
     *
     ****
     * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
     *
     * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
     * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
     *
     * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
     * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
     * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
     *
     * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
     * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
     * end of any scanline are undefined.
     *
     * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
     * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
     * Bytes in the gap between the AND and the XOR mask are undefined.
     * XOR mask scanlines have no gap between them and size of XOR mask is:
     * cXor = width * 4 * height.
     ****
     *
     * Preallocate 4 bytes for accessing actual data as p->pointerData.
     */
00318     char pointerData[4];
} VMMDevReqMousePointer;
AssertCompileSize(VMMDevReqMousePointer, 24+24);

/** @name VMMDevReqMousePointer::fFlags
 * @note The VBOX_MOUSE_POINTER_* flags are used in the guest video driver,
 *       values must be <= 0x8000 and must not be changed. (try make more sense
 *       of this, please).
 * @{
 */
/** pointer is visible */
00329 #define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
/** pointer has alpha channel */
00331 #define VBOX_MOUSE_POINTER_ALPHA   (0x0002)
/** pointerData contains new pointer shape */
00333 #define VBOX_MOUSE_POINTER_SHAPE   (0x0004)
/** @} */


/**
 * String log request structure.
 *
 * Used by VMMDevReq_LogString.
 * @deprecated  Use the IPRT logger or VbglR3WriteLog instead.
 */
00343 typedef struct
{
    /** header */
00346     VMMDevRequestHeader header;
    /** variable length string data */
00348     char szString[1];
} VMMDevReqLogString;
AssertCompileSize(VMMDevReqLogString, 24+4);


/**
 * VirtualBox host version request structure.
 *
 * Used by VMMDevReq_GetHostVersion.
 *
 * @remarks VBGL uses this to detect the precense of new features in the
 *          interface.
 */
00361 typedef struct
{
    /** Header. */
00364     VMMDevRequestHeader header;
    /** Major version. */
00366     uint16_t major;
    /** Minor version. */
00368     uint16_t minor;
    /** Build number. */
00370     uint32_t build;
    /** SVN revision. */
00372     uint32_t revision;
    /** Feature mask. */
00374     uint32_t features;
} VMMDevReqHostVersion;
AssertCompileSize(VMMDevReqHostVersion, 24+16);

/** @name VMMDevReqHostVersion::features
 * @{ */
/** Physical page lists are supported by HGCM. */
00381 #define VMMDEV_HVF_HGCM_PHYS_PAGE_LIST  RT_BIT(0)
/** @} */


/**
 * Guest capabilites structure.
 *
 * Used by VMMDevReq_ReportGuestCapabilities.
 */
00390 typedef struct
{
    /** Header. */
00393     VMMDevRequestHeader header;
    /** Capabilities (VMMDEV_GUEST_*). */
00395     uint32_t caps;
} VMMDevReqGuestCapabilities;
AssertCompileSize(VMMDevReqGuestCapabilities, 24+4);

/**
 * Guest capabilites structure, version 2.
 *
 * Used by VMMDevReq_SetGuestCapabilities.
 */
00404 typedef struct
{
    /** Header. */
00407     VMMDevRequestHeader header;
    /** Mask of capabilities to be added. */
00409     uint32_t u32OrMask;
    /** Mask of capabilities to be removed. */
00411     uint32_t u32NotMask;
} VMMDevReqGuestCapabilities2;
AssertCompileSize(VMMDevReqGuestCapabilities2, 24+8);

/** @name Guest capability bits .
 * Used by VMMDevReq_ReportGuestCapabilities and VMMDevReq_SetGuestCapabilities.
 * @{ */
/** The guest supports seamless display rendering. */
00419 #define VMMDEV_GUEST_SUPPORTS_SEAMLESS                      RT_BIT_32(0)
/** The guest supports mapping guest to host windows. */
00421 #define VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING     RT_BIT_32(1)
/** The guest graphical additions are active.
 * Used for fast activation and deactivation of certain graphical operations
 * (e.g. resizing & seamless). The legacy VMMDevReq_ReportGuestCapabilities
 * request sets this automatically, but VMMDevReq_SetGuestCapabilities does
 * not. */
00427 #define VMMDEV_GUEST_SUPPORTS_GRAPHICS                      RT_BIT_32(2)
/** @} */


/**
 * Idle request structure.
 *
 * Used by VMMDevReq_Idle.
 */
00436 typedef struct
{
    /** Header. */
00439     VMMDevRequestHeader header;
} VMMDevReqIdle;
AssertCompileSize(VMMDevReqIdle, 24);


/**
 * Host time request structure.
 *
 * Used by VMMDevReq_GetHostTime.
 */
00449 typedef struct
{
    /** Header */
00452     VMMDevRequestHeader header;
    /** OUT: Time in milliseconds since unix epoch. */
00454     uint64_t time;
} VMMDevReqHostTime;
AssertCompileSize(VMMDevReqHostTime, 24+8);


/**
 * Hypervisor info structure.
 *
 * Used by VMMDevReq_GetHypervisorInfo and VMMDevReq_SetHypervisorInfo.
 */
00464 typedef struct
{
    /** Header. */
00467     VMMDevRequestHeader header;
    /** Guest virtual address of proposed hypervisor start.
     * Not used by VMMDevReq_GetHypervisorInfo.
     * @todo Make this 64-bit compatible? */
00471     RTGCPTR32 hypervisorStart;
    /** Hypervisor size in bytes. */
00473     uint32_t hypervisorSize;
} VMMDevReqHypervisorInfo;
AssertCompileSize(VMMDevReqHypervisorInfo, 24+8);

/** @name Default patch memory size .
 * Used by VMMDevReq_RegisterPatchMemory and VMMDevReq_DeregisterPatchMemory.
 * @{ */
#define VMMDEV_GUEST_DEFAULT_PATCHMEM_SIZE          8192
/** @} */

/**
 * Patching memory structure. (locked executable & read-only page from the guest's perspective)
 *
 * Used by VMMDevReq_RegisterPatchMemory and VMMDevReq_DeregisterPatchMemory
 */
00488 typedef struct
{
    /** Header. */
00491     VMMDevRequestHeader header;
    /** Guest virtual address of the patching page(s). */
00493     RTGCPTR64           pPatchMem;
    /** Patch page size in bytes. */
00495     uint32_t            cbPatchMem;
} VMMDevReqPatchMemory;
AssertCompileSize(VMMDevReqPatchMemory, 24+12);


/**
 * Guest power requests.
 *
 * See VMMDevReq_SetPowerStatus and VMMDevPowerStateRequest.
 */
00505 typedef enum
{
    VMMDevPowerState_Invalid   = 0,
    VMMDevPowerState_Pause     = 1,
    VMMDevPowerState_PowerOff  = 2,
    VMMDevPowerState_SaveState = 3,
    VMMDevPowerState_SizeHack = 0x7fffffff
} VMMDevPowerState;
AssertCompileSize(VMMDevPowerState, 4);

/**
 * VM power status structure.
 *
 * Used by VMMDevReq_SetPowerStatus.
 */
00520 typedef struct
{
    /** Header. */
00523     VMMDevRequestHeader header;
    /** Power state request. */
00525     VMMDevPowerState powerState;
} VMMDevPowerStateRequest;
AssertCompileSize(VMMDevPowerStateRequest, 24+4);


/**
 * Pending events structure.
 *
 * Used by VMMDevReq_AcknowledgeEvents.
 */
00535 typedef struct
{
    /** Header. */
00538     VMMDevRequestHeader header;
    /** OUT: Pending event mask. */
00540     uint32_t events;
} VMMDevEvents;
AssertCompileSize(VMMDevEvents, 24+4);


/**
 * Guest event filter mask control.
 *
 * Used by VMMDevReq_CtlGuestFilterMask.
 */
00550 typedef struct
{
    /** Header. */
00553     VMMDevRequestHeader header;
    /** Mask of events to be added to the filter. */
00555     uint32_t u32OrMask;
    /** Mask of events to be removed from the filter. */
00557     uint32_t u32NotMask;
} VMMDevCtlGuestFilterMask;
AssertCompileSize(VMMDevCtlGuestFilterMask, 24+8);


/**
 * Guest information structure.
 *
 * Used by VMMDevReportGuestInfo and PDMIVMMDEVCONNECTOR::pfnUpdateGuestVersion.
 */
00567 typedef struct VBoxGuestInfo
{
    /** The VMMDev interface version expected by additions. */
00570     uint32_t additionsVersion;
    /** Guest OS type. */
00572     VBOXOSTYPE osType;
} VBoxGuestInfo;
AssertCompileSize(VBoxGuestInfo, 8);

/**
 * Guest information report.
 *
 * Used by VMMDevReq_ReportGuestInfo.
 */
00581 typedef struct
{
    /** Header. */
00584     VMMDevRequestHeader header;
    /** Guest information. */
00586     VBoxGuestInfo guestInfo;
} VMMDevReportGuestInfo;
AssertCompileSize(VMMDevReportGuestInfo, 24+8);


/**
 * Guest statistics structure.
 *
 * Used by VMMDevReportGuestStats and PDMIVMMDEVCONNECTOR::pfnReportStatistics.
 */
00596 typedef struct VBoxGuestStatistics
{
    /** Virtual CPU ID. */
00599     uint32_t        u32CpuId;
    /** Reported statistics. */
00601     uint32_t        u32StatCaps;
    /** Idle CPU load (0-100) for last interval. */
00603     uint32_t        u32CpuLoad_Idle;
    /** Kernel CPU load (0-100) for last interval. */
00605     uint32_t        u32CpuLoad_Kernel;
    /** User CPU load (0-100) for last interval. */
00607     uint32_t        u32CpuLoad_User;
    /** Nr of threads. */
00609     uint32_t        u32Threads;
    /** Nr of processes. */
00611     uint32_t        u32Processes;
    /** Nr of handles. */
00613     uint32_t        u32Handles;
    /** Memory load (0-100). */
00615     uint32_t        u32MemoryLoad;
    /** Page size of guest system. */
00617     uint32_t        u32PageSize;
    /** Total physical memory (in 4KB pages). */
00619     uint32_t        u32PhysMemTotal;
    /** Available physical memory (in 4KB pages). */
00621     uint32_t        u32PhysMemAvail;
    /** Ballooned physical memory (in 4KB pages). */
00623     uint32_t        u32PhysMemBalloon;
    /** Total number of committed memory (which is not necessarily in-use) (in 4KB pages). */
00625     uint32_t        u32MemCommitTotal;
    /** Total amount of memory used by the kernel (in 4KB pages). */
00627     uint32_t        u32MemKernelTotal;
    /** Total amount of paged memory used by the kernel (in 4KB pages). */
00629     uint32_t        u32MemKernelPaged;
    /** Total amount of nonpaged memory used by the kernel (in 4KB pages). */
00631     uint32_t        u32MemKernelNonPaged;
    /** Total amount of memory used for the system cache (in 4KB pages). */
00633     uint32_t        u32MemSystemCache;
    /** Pagefile size (in 4KB pages). */
00635     uint32_t        u32PageFileSize;
} VBoxGuestStatistics;
AssertCompileSize(VBoxGuestStatistics, 19*4);

/** @name Guest statistics values (VBoxGuestStatistics::u32StatCaps).
 * @{ */
#define VBOX_GUEST_STAT_CPU_LOAD_IDLE       RT_BIT(0)
#define VBOX_GUEST_STAT_CPU_LOAD_KERNEL     RT_BIT(1)
#define VBOX_GUEST_STAT_CPU_LOAD_USER       RT_BIT(2)
#define VBOX_GUEST_STAT_THREADS             RT_BIT(3)
#define VBOX_GUEST_STAT_PROCESSES           RT_BIT(4)
#define VBOX_GUEST_STAT_HANDLES             RT_BIT(5)
#define VBOX_GUEST_STAT_MEMORY_LOAD         RT_BIT(6)
#define VBOX_GUEST_STAT_PHYS_MEM_TOTAL      RT_BIT(7)
#define VBOX_GUEST_STAT_PHYS_MEM_AVAIL      RT_BIT(8)
#define VBOX_GUEST_STAT_PHYS_MEM_BALLOON    RT_BIT(9)
#define VBOX_GUEST_STAT_MEM_COMMIT_TOTAL    RT_BIT(10)
#define VBOX_GUEST_STAT_MEM_KERNEL_TOTAL    RT_BIT(11)
#define VBOX_GUEST_STAT_MEM_KERNEL_PAGED    RT_BIT(12)
#define VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED RT_BIT(13)
#define VBOX_GUEST_STAT_MEM_SYSTEM_CACHE    RT_BIT(14)
#define VBOX_GUEST_STAT_PAGE_FILE_SIZE      RT_BIT(15)
/** @} */

/**
 * Guest statistics command structure.
 *
 * Used by VMMDevReq_ReportGuestStats.
 */
00664 typedef struct
{
    /** Header. */
00667     VMMDevRequestHeader header;
    /** Guest information. */
00669     VBoxGuestStatistics guestStats;
} VMMDevReportGuestStats;
AssertCompileSize(VMMDevReportGuestStats, 24+19*4);


/** Memory balloon change request structure. */
00675 #define VMMDEV_MAX_MEMORY_BALLOON(PhysMemTotal)     ( (9 * (PhysMemTotal)) / 10 )

/**
 * Poll for ballooning change request.
 *
 * Used by VMMDevReq_GetMemBalloonChangeRequest.
 */
00682 typedef struct
{
    /** Header. */
00685     VMMDevRequestHeader header;
    /** Balloon size in megabytes. */
00687     uint32_t            u32BalloonSize;
    /** Guest ram size in megabytes. */
00689     uint32_t            u32PhysMemSize;
    /** Setting this to VMMDEV_EVENT_BALLOON_CHANGE_REQUEST indicates that the
     * request is a response to that event.
     * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
00693     uint32_t            eventAck;
} VMMDevGetMemBalloonChangeRequest;
AssertCompileSize(VMMDevGetMemBalloonChangeRequest, 24+12);


/**
 * Change the size of the balloon.
 *
 * Used by VMMDevReq_ChangeMemBalloon.
 */
00703 typedef struct
{
    /** Header. */
00706     VMMDevRequestHeader header;
    /** The number of pages in the array. */
00708     uint32_t            cPages;
    /** true = inflate, false = deflate.  */
00710     uint32_t            fInflate;
    /** Physical address (RTGCPHYS) of each page, variable size. */
00712     RTGCPHYS            aPhysPage[1];
} VMMDevChangeMemBalloon;
AssertCompileSize(VMMDevChangeMemBalloon, 24+16);

/** @name The ballooning chunk size which VMMDev works at.
 * @{ */
#define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES            (_1M/4096)
#define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE             (VMMDEV_MEMORY_BALLOON_CHUNK_PAGES*4096)
/** @} */


/**
 * Guest statistics interval change request structure.
 *
 * Used by VMMDevReq_GetStatisticsChangeRequest.
 */
00728 typedef struct
{
    /** Header. */
00731     VMMDevRequestHeader header;
    /** The interval in seconds. */
00733     uint32_t            u32StatInterval;
    /** Setting this to VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST indicates
     * that the request is a response to that event.
     * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
00737     uint32_t            eventAck;
} VMMDevGetStatisticsChangeRequest;
AssertCompileSize(VMMDevGetStatisticsChangeRequest, 24+8);


/** The length of a string field in the credentials request.
 * @see VMMDevCredentials  */
00744 #define VMMDEV_CREDENTIALS_STRLEN           128

/**
 * Credentials request structure.
 *
 * Used by VMMDevReq_QueryCredentials.
 */
#pragma pack(4)
00752 typedef struct
{
    /** Header. */
00755     VMMDevRequestHeader header;
    /** IN/OUT: Request flags. */
00757     uint32_t u32Flags;
    /** OUT: User name (UTF-8). */
00759     char szUserName[VMMDEV_CREDENTIALS_STRLEN];
    /** OUT: Password (UTF-8). */
00761     char szPassword[VMMDEV_CREDENTIALS_STRLEN];
    /** OUT: Domain name (UTF-8). */
00763     char szDomain[VMMDEV_CREDENTIALS_STRLEN];
} VMMDevCredentials;
AssertCompileSize(VMMDevCredentials, 24+4+3*128);
#pragma pack()

/** @name Credentials request flag (VMMDevCredentials::u32Flags)
 * @{ */
/** query from host whether credentials are present */
00771 #define VMMDEV_CREDENTIALS_QUERYPRESENCE     RT_BIT(1)
/** read credentials from host (can be combined with clear) */
00773 #define VMMDEV_CREDENTIALS_READ              RT_BIT(2)
/** clear credentials on host (can be combined with read) */
00775 #define VMMDEV_CREDENTIALS_CLEAR             RT_BIT(3)
/** read credentials for judgement in the guest */
00777 #define VMMDEV_CREDENTIALS_READJUDGE         RT_BIT(8)
/** clear credentials for judegement on the host */
00779 #define VMMDEV_CREDENTIALS_CLEARJUDGE        RT_BIT(9)
/** report credentials acceptance by guest */
00781 #define VMMDEV_CREDENTIALS_JUDGE_OK          RT_BIT(10)
/** report credentials denial by guest */
00783 #define VMMDEV_CREDENTIALS_JUDGE_DENY        RT_BIT(11)
/** report that no judgement could be made by guest */
00785 #define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT RT_BIT(12)

/** flag telling the guest that credentials are present */
00788 #define VMMDEV_CREDENTIALS_PRESENT           RT_BIT(16)
/** flag telling guest that local logons should be prohibited */
00790 #define VMMDEV_CREDENTIALS_NOLOCALLOGON      RT_BIT(17)
/** @} */


/**
 * Seamless mode change request structure.
 *
 * Used by VMMDevReq_GetSeamlessChangeRequest.
 */
00799 typedef struct
{
    /** Header. */
00802     VMMDevRequestHeader header;

    /** New seamless mode. */
00805     VMMDevSeamlessMode mode;
    /** Setting this to VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST indicates
     * that the request is a response to that event.
     * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
00809     uint32_t eventAck;
} VMMDevSeamlessChangeRequest;
AssertCompileSize(VMMDevSeamlessChangeRequest, 24+8);
AssertCompileMemberOffset(VMMDevSeamlessChangeRequest, eventAck, 24+4);


/**
 * Display change request structure.
 *
 * Used by VMMDevReq_GetDisplayChangeRequest.
 */
00820 typedef struct
{
    /** Header. */
00823     VMMDevRequestHeader header;
    /** Horizontal pixel resolution (0 = do not change). */
00825     uint32_t xres;
    /** Vertical pixel resolution (0 = do not change). */
00827     uint32_t yres;
    /** Bits per pixel (0 = do not change). */
00829     uint32_t bpp;
    /** Setting this to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST indicates
     * that the request is a response to that event.
     * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
00833     uint32_t eventAck;
} VMMDevDisplayChangeRequest;
AssertCompileSize(VMMDevDisplayChangeRequest, 24+16);


/**
 * Display change request structure, version 2.
 *
 * Used by VMMDevReq_GetDisplayChangeRequest2.
 */
00843 typedef struct
{
    /** Header. */
00846     VMMDevRequestHeader header;
    /** Horizontal pixel resolution (0 = do not change). */
00848     uint32_t xres;
    /** Vertical pixel resolution (0 = do not change). */
00850     uint32_t yres;
    /** Bits per pixel (0 = do not change). */
00852     uint32_t bpp;
    /** Setting this to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST indicates
     * that the request is a response to that event.
     * (Don't confuse this with VMMDevReq_AcknowledgeEvents.) */
00856     uint32_t eventAck;
    /** 0 for primary display, 1 for the first secondary, etc. */
00858     uint32_t display;
} VMMDevDisplayChangeRequest2;
AssertCompileSize(VMMDevDisplayChangeRequest2, 24+20);


/**
 * Video mode supported request structure.
 *
 * Used by VMMDevReq_VideoModeSupported.
 */
00868 typedef struct
{
    /** Header. */
00871     VMMDevRequestHeader header;
    /** IN: Horizontal pixel resolution. */
00873     uint32_t width;
    /** IN: Vertical pixel resolution. */
00875     uint32_t height;
    /** IN: Bits per pixel. */
00877     uint32_t bpp;
    /** OUT: Support indicator. */
00879     bool fSupported;
} VMMDevVideoModeSupportedRequest;
AssertCompileSize(VMMDevVideoModeSupportedRequest, 24+16);


/**
 * Video modes height reduction request structure.
 *
 * Used by VMMDevReq_GetHeightReduction.
 */
00889 typedef struct
{
    /** Header. */
00892     VMMDevRequestHeader header;
    /** OUT: Height reduction in pixels. */
00894     uint32_t heightReduction;
} VMMDevGetHeightReductionRequest;
AssertCompileSize(VMMDevGetHeightReductionRequest, 24+4);


/**
 * VRDP change request structure.
 *
 * Used by VMMDevReq_GetVRDPChangeRequest.
 */
00904 typedef struct
{
    /** Header */
00907     VMMDevRequestHeader header;
    /** Whether VRDP is active or not. */
00909     uint8_t u8VRDPActive;
    /** The configured experience level for active VRDP. */
00911     uint32_t u32VRDPExperienceLevel;
} VMMDevVRDPChangeRequest;
AssertCompileSize(VMMDevVRDPChangeRequest, 24+8);
AssertCompileMemberOffset(VMMDevVRDPChangeRequest, u8VRDPActive, 24);
AssertCompileMemberOffset(VMMDevVRDPChangeRequest, u32VRDPExperienceLevel, 24+4);

/** @name VRDP Experience level (VMMDevVRDPChangeRequest::u32VRDPExperienceLevel)
 * @{ */
00919 #define VRDP_EXPERIENCE_LEVEL_ZERO     0 /**< Theming disabled. */
00920 #define VRDP_EXPERIENCE_LEVEL_LOW      1 /**< Full window dragging and desktop wallpaper disabled. */
00921 #define VRDP_EXPERIENCE_LEVEL_MEDIUM   2 /**< Font smoothing, gradients. */
00922 #define VRDP_EXPERIENCE_LEVEL_HIGH     3 /**< Animation effects disabled. */
00923 #define VRDP_EXPERIENCE_LEVEL_FULL     4 /**< Everything enabled. */
/** @} */


/**
 * VBVA enable request structure.
 *
 * Used by VMMDevReq_VideoAccelEnable.
 */
00932 typedef struct
{
    /** Header. */
00935     VMMDevRequestHeader header;
    /** 0 - disable, !0 - enable. */
00937     uint32_t u32Enable;
    /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
     *  The host will refuse to enable VBVA if the size is not equal to
     *  VBVA_RING_BUFFER_SIZE.
     */
00942     uint32_t cbRingBuffer;
    /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
00944     uint32_t fu32Status;
} VMMDevVideoAccelEnable;
AssertCompileSize(VMMDevVideoAccelEnable, 24+12);

/** @name VMMDevVideoAccelEnable::fu32Status.
 * @{ */
#define VBVA_F_STATUS_ACCEPTED (0x01)
#define VBVA_F_STATUS_ENABLED  (0x02)
/** @} */


/**
 * VBVA flush request structure.
 *
 * Used by VMMDevReq_VideoAccelFlush.
 */
00960 typedef struct
{
    /** Header. */
00963     VMMDevRequestHeader header;
} VMMDevVideoAccelFlush;
AssertCompileSize(VMMDevVideoAccelFlush, 24);


/**
 * VBVA set visible region request structure.
 *
 * Used by VMMDevReq_VideoSetVisibleRegion.
 */
00973 typedef struct
{
    /** Header. */
00976     VMMDevRequestHeader header;
    /** Number of rectangles */
00978     uint32_t cRect;
    /** Rectangle array.
     * @todo array is spelled aRects[1].  */
00981     RTRECT Rect;
} VMMDevVideoSetVisibleRegion;
AssertCompileSize(RTRECT, 16);
AssertCompileSize(VMMDevVideoSetVisibleRegion, 24+4+16);

#pragma pack()


#ifdef VBOX_WITH_HGCM

/** @name HGCM flags.
 * @{
 */
# define VBOX_HGCM_REQ_DONE      RT_BIT_32(VBOX_HGCM_REQ_DONE_BIT)
# define VBOX_HGCM_REQ_DONE_BIT  0
# define VBOX_HGCM_REQ_CANCELLED (0x2)
/** @} */

# pragma pack(4)

/**
 * HGCM request header.
 */
typedef struct VMMDevHGCMRequestHeader
{
    /** Request header. */
    VMMDevRequestHeader header;

    /** HGCM flags. */
    uint32_t fu32Flags;

    /** Result code. */
    int32_t result;
} VMMDevHGCMRequestHeader;
AssertCompileSize(VMMDevHGCMRequestHeader, 24+8);

/**
 * HGCM connect request structure.
 *
 * Used by VMMDevReq_HGCMConnect.
 */
typedef struct
{
    /** HGCM request header. */
    VMMDevHGCMRequestHeader header;

    /** IN: Description of service to connect to. */
    HGCMServiceLocation loc;

    /** OUT: Client identifier assigned by local instance of HGCM. */
    uint32_t u32ClientID;
} VMMDevHGCMConnect;
AssertCompileSize(VMMDevHGCMConnect, 32+132+4);


/**
 * HGCM disconnect request structure.
 *
 * Used by VMMDevReq_HGCMDisconnect.
 */
typedef struct
{
    /** HGCM request header. */
    VMMDevHGCMRequestHeader header;

    /** IN: Client identifier. */
    uint32_t u32ClientID;
} VMMDevHGCMDisconnect;
AssertCompileSize(VMMDevHGCMDisconnect, 32+4);

/**
 * HGCM parameter type.
 */
typedef enum
{
    VMMDevHGCMParmType_Invalid            = 0,
    VMMDevHGCMParmType_32bit              = 1,
    VMMDevHGCMParmType_64bit              = 2,
    VMMDevHGCMParmType_PhysAddr           = 3,  /**< @deprecated Doesn't work, use PageList. */
    VMMDevHGCMParmType_LinAddr            = 4,  /**< In and Out */
    VMMDevHGCMParmType_LinAddr_In         = 5,  /**< In  (read;  host<-guest) */
    VMMDevHGCMParmType_LinAddr_Out        = 6,  /**< Out (write; host->guest) */
    VMMDevHGCMParmType_LinAddr_Locked     = 7,  /**< Locked In and Out */
    VMMDevHGCMParmType_LinAddr_Locked_In  = 8,  /**< Locked In  (read;  host<-guest) */
    VMMDevHGCMParmType_LinAddr_Locked_Out = 9,  /**< Locked Out (write; host->guest) */
    VMMDevHGCMParmType_PageList           = 10, /**< Physical addresses of locked pages for a buffer. */
    VMMDevHGCMParmType_SizeHack           = 0x7fffffff
} HGCMFunctionParameterType;
AssertCompileSize(HGCMFunctionParameterType, 4);

# ifdef VBOX_WITH_64_BITS_GUESTS
/**
 * HGCM function parameter, 32-bit client.
 */
typedef struct
{
    HGCMFunctionParameterType type;
    union
    {
        uint32_t   value32;
        uint64_t   value64;
        struct
        {
            uint32_t size;

            union
            {
                RTGCPHYS32 physAddr;
                RTGCPTR32  linearAddr;
            } u;
        } Pointer;
        struct
        {
            uint32_t size;   /**< Size of the buffer described by the page list. */
            uint32_t offset; /**< Relative to the request header, valid if size != 0. */
        } PageList;
    } u;
#  ifdef __cplusplus
    void SetUInt32(uint32_t u32)
    {
        type = VMMDevHGCMParmType_32bit;
        u.value64 = 0; /* init unused bits to 0 */
        u.value32 = u32;
    }

    int GetUInt32(uint32_t *pu32)
    {
        if (type == VMMDevHGCMParmType_32bit)
        {
            *pu32 = u.value32;
            return VINF_SUCCESS;
        }
        return VERR_INVALID_PARAMETER;
    }

    void SetUInt64(uint64_t u64)
    {
        type      = VMMDevHGCMParmType_64bit;
        u.value64 = u64;
    }

    int GetUInt64(uint64_t *pu64)
    {
        if (type == VMMDevHGCMParmType_64bit)
        {
            *pu64 = u.value64;
            return VINF_SUCCESS;
        }
        return VERR_INVALID_PARAMETER;
    }

    void SetPtr(void *pv, uint32_t cb)
    {
        type                    = VMMDevHGCMParmType_LinAddr;
        u.Pointer.size          = cb;
        u.Pointer.u.linearAddr  = (RTGCPTR32)(uintptr_t)pv;
    }
#  endif /* __cplusplus */
} HGCMFunctionParameter32;
AssertCompileSize(HGCMFunctionParameter32, 4+8);

/**
 * HGCM function parameter, 64-bit client.
 */
typedef struct
{
    HGCMFunctionParameterType type;
    union
    {
        uint32_t   value32;
        uint64_t   value64;
        struct
        {
            uint32_t size;

            union
            {
                RTGCPHYS64 physAddr;
                RTGCPTR64  linearAddr;
            } u;
        } Pointer;
        struct
        {
            uint32_t size;   /**< Size of the buffer described by the page list. */
            uint32_t offset; /**< Relative to the request header, valid if size != 0. */
        } PageList;
    } u;
#  ifdef __cplusplus
    void SetUInt32(uint32_t u32)
    {
        type = VMMDevHGCMParmType_32bit;
        u.value64 = 0; /* init unused bits to 0 */
        u.value32 = u32;
    }

    int GetUInt32(uint32_t *pu32)
    {
        if (type == VMMDevHGCMParmType_32bit)
        {
            *pu32 = u.value32;
            return VINF_SUCCESS;
        }
        return VERR_INVALID_PARAMETER;
    }

    void SetUInt64(uint64_t u64)
    {
        type      = VMMDevHGCMParmType_64bit;
        u.value64 = u64;
    }

    int GetUInt64(uint64_t *pu64)
    {
        if (type == VMMDevHGCMParmType_64bit)
        {
            *pu64 = u.value64;
            return VINF_SUCCESS;
        }
        return VERR_INVALID_PARAMETER;
    }

    void SetPtr(void *pv, uint32_t cb)
    {
        type                    = VMMDevHGCMParmType_LinAddr;
        u.Pointer.size          = cb;
        u.Pointer.u.linearAddr  = (uintptr_t)pv;
    }
#  endif /** __cplusplus */
} HGCMFunctionParameter64;
AssertCompileSize(HGCMFunctionParameter64, 4+12);

/* Redefine the structure type for the guest code. */
#  ifndef VBOX_HGCM_HOST_CODE
#   if ARCH_BITS == 64
#     define HGCMFunctionParameter  HGCMFunctionParameter64
#   elif ARCH_BITS == 32
#     define HGCMFunctionParameter  HGCMFunctionParameter32
#   else
#    error "Unsupported sizeof (void *)"
#   endif
#  endif /* !VBOX_HGCM_HOST_CODE */

# else /* !VBOX_WITH_64_BITS_GUESTS */

/**
 * HGCM function parameter, 32-bit client.
 *
 * @todo If this is the same as HGCMFunctionParameter32, why the duplication?
 */
typedef struct
{
    HGCMFunctionParameterType type;
    union
    {
        uint32_t   value32;
        uint64_t   value64;
        struct
        {
            uint32_t size;

            union
            {
                RTGCPHYS32 physAddr;
                RTGCPTR32  linearAddr;
            } u;
        } Pointer;
        struct
        {
            uint32_t size;   /**< Size of the buffer described by the page list. */
            uint32_t offset; /**< Relative to the request header, valid if size != 0. */
        } PageList;
    } u;
#  ifdef __cplusplus
    void SetUInt32(uint32_t u32)
    {
        type = VMMDevHGCMParmType_32bit;
        u.value64 = 0; /* init unused bits to 0 */
        u.value32 = u32;
    }

    int GetUInt32(uint32_t *pu32)
    {
        if (type == VMMDevHGCMParmType_32bit)
        {
            *pu32 = u.value32;
            return VINF_SUCCESS;
        }
        return VERR_INVALID_PARAMETER;
    }

    void SetUInt64(uint64_t u64)
    {
        type      = VMMDevHGCMParmType_64bit;
        u.value64 = u64;
    }

    int GetUInt64(uint64_t *pu64)
    {
        if (type == VMMDevHGCMParmType_64bit)
        {
            *pu64 = u.value64;
            return VINF_SUCCESS;
        }
        return VERR_INVALID_PARAMETER;
    }

    void SetPtr(void *pv, uint32_t cb)
    {
        type                    = VMMDevHGCMParmType_LinAddr;
        u.Pointer.size          = cb;
        u.Pointer.u.linearAddr  = (uintptr_t)pv;
    }
#  endif /* __cplusplus */
} HGCMFunctionParameter;
AssertCompileSize(HGCMFunctionParameter, 4+8);
# endif /* !VBOX_WITH_64_BITS_GUESTS */

/**
 * HGCM call request structure.
 *
 * Used by VMMDevReq_HGCMCall, VMMDevReq_HGCMCall32 and VMMDevReq_HGCMCall64.
 */
typedef struct
{
    /* request header */
    VMMDevHGCMRequestHeader header;

    /** IN: Client identifier. */
    uint32_t u32ClientID;
    /** IN: Service function number. */
    uint32_t u32Function;
    /** IN: Number of parameters. */
    uint32_t cParms;
    /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
} VMMDevHGCMCall;
AssertCompileSize(VMMDevHGCMCall, 32+12);

/** @name Direction of data transfer (HGCMPageListInfo::flags). Bit flags.
 * @{ */
#define VBOX_HGCM_F_PARM_DIRECTION_NONE      UINT32_C(0x00000000)
#define VBOX_HGCM_F_PARM_DIRECTION_TO_HOST   UINT32_C(0x00000001)
#define VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST UINT32_C(0x00000002)
#define VBOX_HGCM_F_PARM_DIRECTION_BOTH      UINT32_C(0x00000003)
/** Macro for validating that the specified flags are valid. */
#define VBOX_HGCM_F_PARM_ARE_VALID(fFlags) \
    (   (fFlags) > VBOX_HGCM_F_PARM_DIRECTION_NONE \
     && (fFlags) < VBOX_HGCM_F_PARM_DIRECTION_BOTH )
/** @} */

/**
 * VMMDevHGCMParmType_PageList points to this structure to actually describe the
 * buffer.
 */
typedef struct
{
    uint32_t flags;        /**< VBOX_HGCM_F_PARM_*. */
    uint16_t offFirstPage; /**< Offset in the first page where data begins. */
    uint16_t cPages;       /**< Number of pages. */
    RTGCPHYS64 aPages[1];  /**< Page addesses. */
} HGCMPageListInfo;
AssertCompileSize(HGCMPageListInfo, 4+2+2+8);

# pragma pack()

/** Get the pointer to the first parmater of a HGCM call request.  */
# define VMMDEV_HGCM_CALL_PARMS(a)   ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
/** Get the pointer to the first parmater of a 32-bit HGCM call request.  */
# define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))

# ifdef VBOX_WITH_64_BITS_GUESTS
/* Explicit defines for the host code. */
#  ifdef VBOX_HGCM_HOST_CODE
#   define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
#   define VMMDEV_HGCM_CALL_PARMS64(a) ((HGCMFunctionParameter64 *)((uint8_t *)(a) + sizeof (VMMDevHGCMCall)))
#  endif /* VBOX_HGCM_HOST_CODE */
# endif /* VBOX_WITH_64_BITS_GUESTS */

# define VBOX_HGCM_MAX_PARMS 32

/**
 * HGCM cancel request structure.
 *
 * The Cancel request is issued using the same physical memory address as was
 * used for the corresponding initial HGCMCall.
 *
 * Used by VMMDevReq_HGCMCancel.
 */
typedef struct
{
    /** Header. */
    VMMDevHGCMRequestHeader header;
} VMMDevHGCMCancel;
AssertCompileSize(VMMDevHGCMCancel, 32);

/**
 * HGCM cancel request structure, version 2.
 *
 * Used by VMMDevReq_HGCMCancel2.
 *
 * VINF_SUCCESS when cancelled.
 * VERR_NOT_FOUND if the specified request cannot be found.
 * VERR_INVALID_PARAMETER if the address is invalid valid.
 */
typedef struct
{
    /** Header. */
    VMMDevRequestHeader header;
    /** The physical address of the request to cancel. */
    RTGCPHYS32 physReqToCancel;
} VMMDevHGCMCancel2;
AssertCompileSize(VMMDevHGCMCancel2, 24+4);

#endif /* VBOX_WITH_HGCM */


/**
 * Inline helper to determine the request size for the given operation.
 *
 * @returns Size.
 * @param   requestType     The VMMDev request type.
 */
01402 DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
{
    switch (requestType)
    {
        case VMMDevReq_GetMouseStatus:
        case VMMDevReq_SetMouseStatus:
            return sizeof(VMMDevReqMouseStatus);
        case VMMDevReq_SetPointerShape:
            return sizeof(VMMDevReqMousePointer);
        case VMMDevReq_GetHostVersion:
            return sizeof(VMMDevReqHostVersion);
        case VMMDevReq_Idle:
            return sizeof(VMMDevReqIdle);
        case VMMDevReq_GetHostTime:
            return sizeof(VMMDevReqHostTime);
        case VMMDevReq_GetHypervisorInfo:
        case VMMDevReq_SetHypervisorInfo:
            return sizeof(VMMDevReqHypervisorInfo);
        case VMMDevReq_RegisterPatchMemory:
        case VMMDevReq_DeregisterPatchMemory:
            return sizeof(VMMDevReqPatchMemory);
        case VMMDevReq_SetPowerStatus:
            return sizeof(VMMDevPowerStateRequest);
        case VMMDevReq_AcknowledgeEvents:
            return sizeof(VMMDevEvents);
        case VMMDevReq_ReportGuestInfo:
            return sizeof(VMMDevReportGuestInfo);
        case VMMDevReq_GetDisplayChangeRequest:
            return sizeof(VMMDevDisplayChangeRequest);
        case VMMDevReq_GetDisplayChangeRequest2:
            return sizeof(VMMDevDisplayChangeRequest2);
        case VMMDevReq_VideoModeSupported:
            return sizeof(VMMDevVideoModeSupportedRequest);
        case VMMDevReq_GetHeightReduction:
            return sizeof(VMMDevGetHeightReductionRequest);
        case VMMDevReq_ReportGuestCapabilities:
            return sizeof(VMMDevReqGuestCapabilities);
        case VMMDevReq_SetGuestCapabilities:
            return sizeof(VMMDevReqGuestCapabilities2);
#ifdef VBOX_WITH_HGCM
        case VMMDevReq_HGCMConnect:
            return sizeof(VMMDevHGCMConnect);
        case VMMDevReq_HGCMDisconnect:
            return sizeof(VMMDevHGCMDisconnect);
#ifdef VBOX_WITH_64_BITS_GUESTS
        case VMMDevReq_HGCMCall32:
            return sizeof(VMMDevHGCMCall);
        case VMMDevReq_HGCMCall64:
            return sizeof(VMMDevHGCMCall);
#else
        case VMMDevReq_HGCMCall:
            return sizeof(VMMDevHGCMCall);
#endif /* VBOX_WITH_64_BITS_GUESTS */
        case VMMDevReq_HGCMCancel:
            return sizeof(VMMDevHGCMCancel);
#endif /* VBOX_WITH_HGCM */
        case VMMDevReq_VideoAccelEnable:
            return sizeof(VMMDevVideoAccelEnable);
        case VMMDevReq_VideoAccelFlush:
            return sizeof(VMMDevVideoAccelFlush);
        case VMMDevReq_VideoSetVisibleRegion:
            return sizeof(VMMDevVideoSetVisibleRegion);
        case VMMDevReq_GetSeamlessChangeRequest:
            return sizeof(VMMDevSeamlessChangeRequest);
        case VMMDevReq_QueryCredentials:
            return sizeof(VMMDevCredentials);
        case VMMDevReq_ReportGuestStats:
            return sizeof(VMMDevReportGuestStats);
        case VMMDevReq_GetMemBalloonChangeRequest:
            return sizeof(VMMDevGetMemBalloonChangeRequest);
        case VMMDevReq_GetStatisticsChangeRequest:
            return sizeof(VMMDevGetStatisticsChangeRequest);
        case VMMDevReq_ChangeMemBalloon:
            return sizeof(VMMDevChangeMemBalloon);
        case VMMDevReq_GetVRDPChangeRequest:
            return sizeof(VMMDevVRDPChangeRequest);
        case VMMDevReq_LogString:
            return sizeof(VMMDevReqLogString);
        case VMMDevReq_CtlGuestFilterMask:
            return sizeof(VMMDevCtlGuestFilterMask);
        default:
            return 0;
    }
}


/**
 * Initializes a request structure.
 *
 * @returns VBox status code.
 * @param   req             The request structure to initialize.
 * @param   type            The request type.
 */
DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
{
    uint32_t requestSize;
    if (!req)
        return VERR_INVALID_PARAMETER;
    requestSize = (uint32_t)vmmdevGetRequestSize(type);
    if (!requestSize)
        return VERR_INVALID_PARAMETER;
    req->size        = requestSize;
    req->version     = VMMDEV_REQUEST_HEADER_VERSION;
    req->requestType = type;
    req->rc          = VERR_GENERAL_FAILURE;
    req->reserved1   = 0;
    req->reserved2   = 0;
    return VINF_SUCCESS;
}

/** @} */


/**
 * VBVA command header.
 *
 * @todo Where does this fit in?
 */
#pragma pack(1) /* unnecessary */
typedef struct VBVACMDHDR
{
   /** Coordinates of affected rectangle. */
   int16_t x;
   int16_t y;
   uint16_t w;
   uint16_t h;
} VBVACMDHDR;
#pragma pack()

/** @name VBVA ring defines.
 *
 * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of
 * data. For example big bitmaps which do not fit to the buffer.
 *
 * Guest starts writing to the buffer by initializing a record entry in the
 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
 * written. As data is written to the ring buffer, the guest increases off32End
 * for the record.
 *
 * The host reads the aRecords on flushes and processes all completed records.
 * When host encounters situation when only a partial record presents and
 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE -
 * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates
 * off32Head. After that on each flush the host continues fetching the data
 * until the record is completed.
 *
 */
#define VBVA_RING_BUFFER_SIZE        (_4M - _1K)
#define VBVA_RING_BUFFER_THRESHOLD   (4 * _1K)

#define VBVA_MAX_RECORDS (64)

#define VBVA_F_MODE_ENABLED         (0x00000001)
#define VBVA_F_MODE_VRDP            (0x00000002)
#define VBVA_F_MODE_VRDP_RESET      (0x00000004)
#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)

#define VBVA_F_RECORD_PARTIAL       (0x80000000)
/** @} */

/**
 * VBVA record.
 */
01565 typedef struct
{
    /** The length of the record. Changed by guest. */
01568     uint32_t cbRecord;
} VBVARECORD;
AssertCompileSize(VBVARECORD, 4);


/**
 * VBVA memory layout.
 *
 * This is a subsection of the VMMDevMemory structure.
 */
#pragma pack(1) /* paranoia */
01579 typedef struct VBVAMEMORY
{
    /** VBVA_F_MODE_*. */
01582     uint32_t fu32ModeFlags;

    /** The offset where the data start in the buffer. */
01585     uint32_t off32Data;
    /** The offset where next data must be placed in the buffer. */
01587     uint32_t off32Free;

    /** The ring buffer for data. */
01590     uint8_t  au8RingBuffer[VBVA_RING_BUFFER_SIZE];

    /** The queue of record descriptions. */
01593     VBVARECORD aRecords[VBVA_MAX_RECORDS];
    uint32_t indexRecordFirst;
    uint32_t indexRecordFree;

    /** RDP orders supported by the client. The guest reports only them
     * and falls back to DIRTY rects for not supported ones.
     *
     * (1 << VBVA_VRDP_*)
     */
01602     uint32_t fu32SupportedOrders;

} VBVAMEMORY;
#pragma pack()
AssertCompileSize(VBVAMEMORY, 12 + (_4M-_1K) + 4*64 + 12);


/**
 * The layout of VMMDEV RAM region that contains information for guest.
 */
#pragma pack(1) /* paranoia */
01613 typedef struct VMMDevMemory
{
    /** The size of this structure. */
01616     uint32_t u32Size;
    /** The structure version. (VMMDEV_MEMORY_VERSION) */
01618     uint32_t u32Version;

    union
    {
        struct
        {
            /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
01625             bool fHaveEvents;
        } V1_04;

        struct
        {
            /** Pending events flags, set by host. */
01631             uint32_t u32HostEvents;
            /** Mask of events the guest wants to see, set by guest. */
01633             uint32_t u32GuestEventMask;
        } V1_03;
    } V;

    VBVAMEMORY vbvaMemory;

} VMMDevMemory;
AssertCompileSize(VMMDevMemory, 8+8 + (12 + (_4M-_1K) + 4*64 + 12) );
#pragma pack()

/** Version of VMMDevMemory structure (VMMDevMemory::u32Version). */
01644 #define VMMDEV_MEMORY_VERSION   (1)


/** @} */
RT_C_DECLS_END

#endif


Generated by  Doxygen 1.6.0   Back to index