~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to include/VBox/VBoxGuest.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/** @file
2
 
 * VBoxGuest - VirtualBox Guest Additions interface
 
2
 * VBoxGuest - VirtualBox Guest Additions Driver Interface. (ADD,DEV)
 
3
 *
 
4
 * @remarks This is in the process of being split up and usage cleaned up.
3
5
 */
4
6
 
5
7
/*
6
 
 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
 
8
 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
7
9
 *
8
10
 * This file is part of VirtualBox Open Source Edition (OSE), as
9
11
 * available from http://www.virtualbox.org. This file is free software;
30
32
#ifndef ___VBox_VBoxGuest_h
31
33
#define ___VBox_VBoxGuest_h
32
34
 
33
 
#include <iprt/cdefs.h>
34
 
#include <iprt/types.h>
35
 
#ifdef IN_RING3
36
 
# include <iprt/stdarg.h>
37
 
#endif
 
35
#include <VBox/cdefs.h>
 
36
#include <VBox/types.h>
38
37
#include <iprt/assert.h>
39
 
#include <VBox/err.h>
40
 
#include <VBox/ostypes.h>
41
 
 
42
 
/*******************************************************************************
43
 
*   Defined Constants And Macros                                               *
44
 
*******************************************************************************/
45
 
 
46
 
/** @todo The following is a temporary fix for the problem of accessing
47
 
    hypervisor pointers from within guest additions */
48
 
 
49
 
/** Hypervisor linear pointer size type */
50
 
typedef RTGCPTR32 VMMDEVHYPPTR32;
51
 
typedef RTGCPTR64 VMMDEVHYPPTR64;
52
 
/** Hypervisor physical pointer size type */
53
 
typedef RTGCPHYS32 VMMDEVHYPPHYS32;
54
 
typedef RTGCPHYS64 VMMDEVHYPPHYS64;
55
 
 
56
 
#if defined(VBOX_WITH_64_BITS_GUESTS) && ARCH_BITS == 64
57
 
# define VMMDEVHYPPTR  VMMDEVHYPPTR64
58
 
# define VMMDEVHYPPHYS VMMDEVHYPPHYS64
59
 
# else
60
 
# define VMMDEVHYPPTR  VMMDEVHYPPTR32
61
 
# define VMMDEVHYPPHYS VMMDEVHYPPHYS32
62
 
#endif
63
 
 
64
 
#if defined(RT_OS_LINUX)
65
 
/** The support device name. */
66
 
# define VBOXGUEST_DEVICE_NAME        "/dev/vboxadd"
67
 
/** The support device name of the user accessible device node. */
68
 
# define VBOXGUEST_USER_DEVICE_NAME   "/dev/vboxuser"
69
 
 
70
 
#elif defined(RT_OS_OS2)
71
 
/** The support device name. */
72
 
# define VBOXGUEST_DEVICE_NAME        "\\Dev\\VBoxGst$"
73
 
/** The support device name of the user accessible device node. */
74
 
# define VBOXGUEST_USER_DEVICE_NAME   "\\Dev\\VBoxGst$"
75
 
 
76
 
#elif defined(RT_OS_SOLARIS)
77
 
/** The support device name. */
78
 
# define VBOXGUEST_DEVICE_NAME        "/dev/vboxguest"
79
 
/** The support device name of the user accessible device node. */
80
 
# define VBOXGUEST_USER_DEVICE_NAME   "/dev/vboxguest"
 
38
#include <VBox/VMMDev2.h>
 
39
#include <VBox/VBoxGuest2.h>
 
40
 
 
41
 
 
42
/** @defgroup grp_vboxguest     VirtualBox Guest Additions Driver Interface
 
43
 * @{
 
44
 */
 
45
 
 
46
/** @todo it would be nice if we could have two define without paths. */
 
47
 
 
48
/** @def VBOXGUEST_DEVICE_NAME
 
49
 * The support device name. */
 
50
/** @def VBOXGUEST_USER_DEVICE_NAME
 
51
 * The support device name of the user accessible device node. */
 
52
 
 
53
#if defined(RT_OS_OS2)
 
54
# define VBOXGUEST_DEVICE_NAME          "\\Dev\\VBoxGst$"
81
55
 
82
56
#elif defined(RT_OS_WINDOWS)
 
57
# define VBOXGUEST_DEVICE_NAME          "\\\\.\\VBoxGuest"
 
58
 
83
59
/** The support service name. */
84
 
# define VBOXGUEST_SERVICE_NAME       "VBoxGuest"
85
 
/** Win32 device name. */
86
 
# define VBOXGUEST_DEVICE_NAME        "\\\\.\\VBoxGuest"
87
 
/** The support device name of the user accessible device node. */
88
 
# define VBOXGUEST_USER_DEVICE_NAME   "\\\\.\\VBoxGuest"
 
60
# define VBOXGUEST_SERVICE_NAME         "VBoxGuest"
89
61
/** Global name for Win2k+ */
90
 
# define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
 
62
# define VBOXGUEST_DEVICE_NAME_GLOBAL   "\\\\.\\Global\\VBoxGuest"
91
63
/** Win32 driver name */
92
 
# define VBOXGUEST_DEVICE_NAME_NT     L"\\Device\\VBoxGuest"
93
 
/** device name */
94
 
# define VBOXGUEST_DEVICE_NAME_DOS    L"\\DosDevices\\VBoxGuest"
95
 
 
96
 
#elif defined(RT_OS_FREEBSD)
97
 
/** The support device name. */
98
 
# define VBOXGUEST_DEVICE_NAME        "/dev/vboxguest"
99
 
/** The support device name of the user accessible device node. */
100
 
# define VBOXGUEST_USER_DEVICE_NAME   "/dev/vboxguest"
101
 
 
102
 
#else
103
 
/* PORTME */
104
 
#endif
105
 
 
106
 
/** VirtualBox vendor ID */
107
 
#define VBOX_PCI_VENDORID (0x80ee)
108
 
 
109
 
/** VMMDev PCI card identifiers */
110
 
#define VMMDEV_VENDORID VBOX_PCI_VENDORID
111
 
#define VMMDEV_DEVICEID (0xcafe)
112
 
 
113
 
/** VirtualBox graphics card identifiers */
114
 
#define VBOX_VENDORID VBOX_PCI_VENDORID
115
 
#define VBOX_VESA_VENDORID VBOX_PCI_VENDORID
116
 
#define VBOX_DEVICEID (0xbeef)
117
 
#define VBOX_VESA_DEVICEID (0xbeef)
118
 
 
119
 
/**
120
 
 * VBoxGuest port definitions
121
 
 * @{
122
 
 */
123
 
 
124
 
/** guest can (== wants to) handle absolute coordinates */
125
 
#define VBOXGUEST_MOUSE_GUEST_CAN_ABSOLUTE      RT_BIT(0)
126
 
/** host can (== wants to) send absolute coordinates */
127
 
#define VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE       RT_BIT(1)
128
 
/** guest can *NOT* switch to software cursor and therefore depends on the host cursor */
129
 
#define VBOXGUEST_MOUSE_GUEST_NEEDS_HOST_CURSOR RT_BIT(2)
130
 
/** host does NOT provide support for drawing the cursor itself (e.g. L4 console) */
131
 
#define VBOXGUEST_MOUSE_HOST_CANNOT_HWPOINTER   RT_BIT(3)
132
 
/** The guest can read VMMDev events to find out about pointer movement */
133
 
#define VBOXGUEST_MOUSE_GUEST_USES_VMMDEV       RT_BIT(4)
134
 
 
135
 
/** fictive start address of the hypervisor physical memory for MmMapIoSpace */
136
 
#define HYPERVISOR_PHYSICAL_START  0xf8000000
137
 
 
138
 
/*
139
 
 * VMMDev Generic Request Interface
140
 
 */
141
 
 
142
 
/** port for generic request interface */
143
 
#define PORT_VMMDEV_REQUEST_OFFSET 0
144
 
 
145
 
/** Current version of the VMMDev interface.
146
 
 *
147
 
 * Additions are allowed to work only if
148
 
 * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
149
 
 * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
150
 
 *
151
 
 * @remark  These defines also live in the 16-bit and assembly versions of this header.
152
 
 */
153
 
#define VMMDEV_VERSION       0x00010004
154
 
#define VMMDEV_VERSION_MAJOR (VMMDEV_VERSION >> 16)
155
 
#define VMMDEV_VERSION_MINOR (VMMDEV_VERSION & 0xffff)
156
 
 
157
 
/* Maximum request packet size */
158
 
#define VMMDEV_MAX_VMMDEVREQ_SIZE           _1M
159
 
 
160
 
/**
161
 
 * VMMDev request types.
162
 
 * @note when updating this, adjust vmmdevGetRequestSize() as well
163
 
 */
164
 
typedef enum
165
 
{
166
 
    VMMDevReq_InvalidRequest             =  0,
167
 
    VMMDevReq_GetMouseStatus             =  1,
168
 
    VMMDevReq_SetMouseStatus             =  2,
169
 
    VMMDevReq_SetPointerShape            =  3,
170
 
    /** @todo implement on host side */
171
 
    VMMDevReq_GetHostVersion             =  4,
172
 
    VMMDevReq_Idle                       =  5,
173
 
    VMMDevReq_GetHostTime                = 10,
174
 
    VMMDevReq_GetHypervisorInfo          = 20,
175
 
    VMMDevReq_SetHypervisorInfo          = 21,
176
 
    VMMDevReq_RegisterPatchMemory        = 22,
177
 
    VMMDevReq_DeregisterPatchMemory      = 23,
178
 
    VMMDevReq_SetPowerStatus             = 30,
179
 
    VMMDevReq_AcknowledgeEvents          = 41,
180
 
    VMMDevReq_CtlGuestFilterMask         = 42,
181
 
    VMMDevReq_ReportGuestInfo            = 50,
182
 
    VMMDevReq_GetDisplayChangeRequest    = 51,
183
 
    VMMDevReq_VideoModeSupported         = 52,
184
 
    VMMDevReq_GetHeightReduction         = 53,
185
 
    VMMDevReq_GetDisplayChangeRequest2   = 54,
186
 
    VMMDevReq_ReportGuestCapabilities    = 55,
187
 
    VMMDevReq_SetGuestCapabilities       = 56,
188
 
#ifdef VBOX_WITH_HGCM
189
 
    VMMDevReq_HGCMConnect                = 60,
190
 
    VMMDevReq_HGCMDisconnect             = 61,
191
 
#ifdef VBOX_WITH_64_BITS_GUESTS
192
 
    VMMDevReq_HGCMCall32                 = 62,
193
 
    VMMDevReq_HGCMCall64                 = 63,
194
 
#else
195
 
    VMMDevReq_HGCMCall                   = 62,
196
 
#endif /* VBOX_WITH_64_BITS_GUESTS */
197
 
    VMMDevReq_HGCMCancel                 = 64,
198
 
#endif
199
 
    VMMDevReq_VideoAccelEnable           = 70,
200
 
    VMMDevReq_VideoAccelFlush            = 71,
201
 
    VMMDevReq_VideoSetVisibleRegion      = 72,
202
 
    VMMDevReq_GetSeamlessChangeRequest   = 73,
203
 
    VMMDevReq_QueryCredentials           = 100,
204
 
    VMMDevReq_ReportCredentialsJudgement = 101,
205
 
    VMMDevReq_ReportGuestStats           = 110,
206
 
    VMMDevReq_GetMemBalloonChangeRequest = 111,
207
 
    VMMDevReq_GetStatisticsChangeRequest = 112,
208
 
    VMMDevReq_ChangeMemBalloon           = 113,
209
 
    VMMDevReq_GetVRDPChangeRequest       = 150,
210
 
    VMMDevReq_LogString                  = 200,
211
 
    VMMDevReq_SizeHack                   = 0x7fffffff
212
 
} VMMDevRequestType;
213
 
 
214
 
#ifdef VBOX_WITH_64_BITS_GUESTS
215
 
/*
216
 
 * Constants and structures are redefined for the guest.
217
 
 *
218
 
 * Host code MUST always use either *32 or *64 variant explicitely.
219
 
 * Host source code will use VBOX_HGCM_HOST_CODE define to catch undefined
220
 
 * data types and constants.
221
 
 *
222
 
 * This redefinition means that the new additions builds will use
223
 
 * the *64 or *32 variants depending on the current architecture bit count (ARCH_BITS).
224
 
 */
225
 
# ifndef VBOX_HGCM_HOST_CODE
226
 
#  if ARCH_BITS == 64
227
 
#   define VMMDevReq_HGCMCall VMMDevReq_HGCMCall64
228
 
#  elif ARCH_BITS == 32
229
 
#   define VMMDevReq_HGCMCall VMMDevReq_HGCMCall32
230
 
#  else
231
 
#   error "Unsupported ARCH_BITS"
232
 
#  endif
233
 
# endif /* !VBOX_HGCM_HOST_CODE */
234
 
#endif /* VBOX_WITH_64_BITS_GUESTS */
235
 
 
236
 
/** Version of VMMDevRequestHeader structure. */
237
 
#define VMMDEV_REQUEST_HEADER_VERSION (0x10001)
238
 
 
239
 
#pragma pack(4)
240
 
/** generic VMMDev request header */
241
 
typedef struct
242
 
{
243
 
    /** size of the structure in bytes (including body). Filled by caller */
244
 
    uint32_t size;
245
 
    /** version of the structure. Filled by caller */
246
 
    uint32_t version;
247
 
    /** type of the request */
248
 
    VMMDevRequestType requestType;
249
 
    /** return code. Filled by VMMDev */
250
 
    int32_t  rc;
251
 
    /** reserved fields */
252
 
    uint32_t reserved1;
253
 
    uint32_t reserved2;
254
 
} VMMDevRequestHeader;
255
 
AssertCompileSize(VMMDevRequestHeader, 24);
256
 
 
257
 
/** mouse status request structure */
258
 
typedef struct
259
 
{
260
 
    /** header */
261
 
    VMMDevRequestHeader header;
262
 
    /** mouse feature mask */
263
 
    uint32_t mouseFeatures;
264
 
    /** mouse x position */
265
 
    uint32_t pointerXPos;
266
 
    /** mouse y position */
267
 
    uint32_t pointerYPos;
268
 
} VMMDevReqMouseStatus;
269
 
 
270
 
/** Note VBOX_MOUSE_POINTER_* flags are used in guest video driver,
271
 
 *  values must be <= 0x8000 and must not be changed.
272
 
 */
273
 
 
274
 
/** pointer is visible */
275
 
#define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
276
 
/** pointer has alpha channel */
277
 
#define VBOX_MOUSE_POINTER_ALPHA   (0x0002)
278
 
/** pointerData contains new pointer shape */
279
 
#define VBOX_MOUSE_POINTER_SHAPE   (0x0004)
280
 
 
281
 
/** mouse pointer shape/visibility change request */
282
 
typedef struct
283
 
{
284
 
    /** header */
285
 
    VMMDevRequestHeader header;
286
 
    /** VBOX_MOUSE_POINTER_* bit flags */
287
 
    uint32_t fFlags;
288
 
    /** x coordinate of hot spot */
289
 
    uint32_t xHot;
290
 
    /** y coordinate of hot spot */
291
 
    uint32_t yHot;
292
 
    /** width of the pointer in pixels */
293
 
    uint32_t width;
294
 
    /** height of the pointer in scanlines */
295
 
    uint32_t height;
296
 
    /** Pointer data.
297
 
     *
298
 
     ****
299
 
     * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
300
 
     *
301
 
     * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
302
 
     * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
303
 
     *
304
 
     * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
305
 
     * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
306
 
     * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
307
 
     *
308
 
     * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
309
 
     * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
310
 
     * end of any scanline are undefined.
311
 
     *
312
 
     * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
313
 
     * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
314
 
     * Bytes in the gap between the AND and the XOR mask are undefined.
315
 
     * XOR mask scanlines have no gap between them and size of XOR mask is:
316
 
     * cXor = width * 4 * height.
317
 
     ****
318
 
     *
319
 
     * Preallocate 4 bytes for accessing actual data as p->pointerData
320
 
     */
321
 
    char pointerData[4];
322
 
} VMMDevReqMousePointer;
323
 
 
324
 
/** string log request structure */
325
 
typedef struct
326
 
{
327
 
    /** header */
328
 
    VMMDevRequestHeader header;
329
 
    /** variable length string data */
330
 
    char szString[1];
331
 
} VMMDevReqLogString;
332
 
 
333
 
/** host version request structure */
334
 
typedef struct
335
 
{
336
 
    /** header */
337
 
    VMMDevRequestHeader header;
338
 
    /** major version */
339
 
    uint32_t major;
340
 
    /** minor version */
341
 
    uint32_t minor;
342
 
    /** build number */
343
 
    uint32_t build;
344
 
} VMMDevReqHostVersion;
345
 
 
346
 
/** guest capabilites structure */
347
 
typedef struct
348
 
{
349
 
    /** header */
350
 
    VMMDevRequestHeader header;
351
 
    /** capabilities (VMMDEV_GUEST_*) */
352
 
    uint32_t    caps;
353
 
} VMMDevReqGuestCapabilities;
354
 
 
355
 
/** guest capabilites structure */
356
 
typedef struct
357
 
{
358
 
    /** header */
359
 
    VMMDevRequestHeader header;
360
 
    /** mask of capabilities to be added */
361
 
    uint32_t    u32OrMask;
362
 
    /** mask of capabilities to be removed */
363
 
    uint32_t    u32NotMask;
364
 
} VMMDevReqGuestCapabilities2;
365
 
 
366
 
/** idle request structure */
367
 
typedef struct
368
 
{
369
 
    /** header */
370
 
    VMMDevRequestHeader header;
371
 
} VMMDevReqIdle;
372
 
 
373
 
/** host time request structure */
374
 
typedef struct
375
 
{
376
 
    /** header */
377
 
    VMMDevRequestHeader header;
378
 
    /** time in milliseconds since unix epoch. Filled by VMMDev. */
379
 
    uint64_t time;
380
 
} VMMDevReqHostTime;
381
 
 
382
 
/** hypervisor info structure */
383
 
typedef struct
384
 
{
385
 
    /** header */
386
 
    VMMDevRequestHeader header;
387
 
    /** guest virtual address of proposed hypervisor start */
388
 
    /** TODO: Make this 64-bit compatible */
389
 
    VMMDEVHYPPTR32 hypervisorStart;
390
 
    /** hypervisor size in bytes */
391
 
    uint32_t hypervisorSize;
392
 
} VMMDevReqHypervisorInfo;
393
 
 
394
 
/** @name Default patch memory size .
395
 
 * Used by VMMDevReq_RegisterPatchMemory and VMMDevReq_DeregisterPatchMemory.
396
 
 * @{ */
397
 
#define VMMDEV_GUEST_DEFAULT_PATCHMEM_SIZE          8192
398
 
/** @} */
399
 
 
400
 
/**
401
 
 * Patching memory structure. (locked executable & read-only page from the guest's perspective)
402
 
 *
403
 
 * Used by VMMDevReq_RegisterPatchMemory and VMMDevReq_DeregisterPatchMemory
404
 
 */
405
 
typedef struct
406
 
{
407
 
    /** Header. */
408
 
    VMMDevRequestHeader header;
409
 
    /** Guest virtual address of the patching page(s). */
410
 
    RTGCPTR64           pPatchMem;
411
 
    /** Patch page size in bytes. */
412
 
    uint32_t            cbPatchMem;
413
 
} VMMDevReqPatchMemory;
414
 
AssertCompileSize(VMMDevReqPatchMemory, 24+12);
415
 
 
416
 
/** system power requests */
417
 
typedef enum
418
 
{
419
 
    VMMDevPowerState_Invalid   = 0,
420
 
    VMMDevPowerState_Pause     = 1,
421
 
    VMMDevPowerState_PowerOff  = 2,
422
 
    VMMDevPowerState_SaveState = 3,
423
 
    VMMDevPowerState_SizeHack = 0x7fffffff
424
 
} VMMDevPowerState;
425
 
 
426
 
/** system power status structure */
427
 
typedef struct
428
 
{
429
 
    /** header */
430
 
    VMMDevRequestHeader header;
431
 
    /** power state request */
432
 
    VMMDevPowerState powerState;
433
 
} VMMDevPowerStateRequest;
434
 
 
435
 
/** pending events structure */
436
 
typedef struct
437
 
{
438
 
    /** header */
439
 
    VMMDevRequestHeader header;
440
 
    /** pending event bitmap */
441
 
    uint32_t events;
442
 
} VMMDevEvents;
443
 
 
444
 
/** guest filter mask control */
445
 
typedef struct
446
 
{
447
 
    /** header */
448
 
    VMMDevRequestHeader header;
449
 
    /** mask of events to be added to filter */
450
 
    uint32_t u32OrMask;
451
 
    /** mask of events to be removed from filter */
452
 
    uint32_t u32NotMask;
453
 
} VMMDevCtlGuestFilterMask;
454
 
 
455
 
/** guest information structure */
456
 
typedef struct VBoxGuestInfo
457
 
{
458
 
    /** The VMMDev interface version expected by additions. */
459
 
    uint32_t additionsVersion;
460
 
    /** guest OS type */
461
 
    VBOXOSTYPE osType;
462
 
    /** @todo */
463
 
} VBoxGuestInfo;
464
 
 
465
 
/** guest information structure */
466
 
typedef struct
467
 
{
468
 
    /** header */
469
 
    VMMDevRequestHeader header;
470
 
    /** Guest information. */
471
 
    VBoxGuestInfo guestInfo;
472
 
} VMMDevReportGuestInfo;
473
 
 
474
 
/** guest statistics values */
475
 
#define VBOX_GUEST_STAT_CPU_LOAD_IDLE       RT_BIT(0)
476
 
#define VBOX_GUEST_STAT_CPU_LOAD_KERNEL     RT_BIT(1)
477
 
#define VBOX_GUEST_STAT_CPU_LOAD_USER       RT_BIT(2)
478
 
#define VBOX_GUEST_STAT_THREADS             RT_BIT(3)
479
 
#define VBOX_GUEST_STAT_PROCESSES           RT_BIT(4)
480
 
#define VBOX_GUEST_STAT_HANDLES             RT_BIT(5)
481
 
#define VBOX_GUEST_STAT_MEMORY_LOAD         RT_BIT(6)
482
 
#define VBOX_GUEST_STAT_PHYS_MEM_TOTAL      RT_BIT(7)
483
 
#define VBOX_GUEST_STAT_PHYS_MEM_AVAIL      RT_BIT(8)
484
 
#define VBOX_GUEST_STAT_PHYS_MEM_BALLOON    RT_BIT(9)
485
 
#define VBOX_GUEST_STAT_MEM_COMMIT_TOTAL    RT_BIT(10)
486
 
#define VBOX_GUEST_STAT_MEM_KERNEL_TOTAL    RT_BIT(11)
487
 
#define VBOX_GUEST_STAT_MEM_KERNEL_PAGED    RT_BIT(12)
488
 
#define VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED RT_BIT(13)
489
 
#define VBOX_GUEST_STAT_MEM_SYSTEM_CACHE    RT_BIT(14)
490
 
#define VBOX_GUEST_STAT_PAGE_FILE_SIZE      RT_BIT(15)
491
 
 
492
 
 
493
 
/** guest statistics structure */
494
 
typedef struct VBoxGuestStatistics
495
 
{
496
 
    /** Virtual CPU id */
497
 
    uint32_t        u32CpuId;
498
 
    /** Reported statistics */
499
 
    uint32_t        u32StatCaps;
500
 
    /** Idle CPU load (0-100) for last interval */
501
 
    uint32_t        u32CpuLoad_Idle;
502
 
    /** Kernel CPU load (0-100) for last interval */
503
 
    uint32_t        u32CpuLoad_Kernel;
504
 
    /** User CPU load (0-100) for last interval */
505
 
    uint32_t        u32CpuLoad_User;
506
 
    /** Nr of threads */
507
 
    uint32_t        u32Threads;
508
 
    /** Nr of processes */
509
 
    uint32_t        u32Processes;
510
 
    /** Nr of handles */
511
 
    uint32_t        u32Handles;
512
 
    /** Memory load (0-100) */
513
 
    uint32_t        u32MemoryLoad;
514
 
    /** Page size of guest system */
515
 
    uint32_t        u32PageSize;
516
 
    /** Total physical memory (in 4kb pages) */
517
 
    uint32_t        u32PhysMemTotal;
518
 
    /** Available physical memory (in 4kb pages) */
519
 
    uint32_t        u32PhysMemAvail;
520
 
    /** Ballooned physical memory (in 4kb pages) */
521
 
    uint32_t        u32PhysMemBalloon;
522
 
    /** Total number of committed memory (which is not necessarily in-use) (in 4kb pages) */
523
 
    uint32_t        u32MemCommitTotal;
524
 
    /** Total amount of memory used by the kernel (in 4kb pages) */
525
 
    uint32_t        u32MemKernelTotal;
526
 
    /** Total amount of paged memory used by the kernel (in 4kb pages) */
527
 
    uint32_t        u32MemKernelPaged;
528
 
    /** Total amount of nonpaged memory used by the kernel (in 4kb pages) */
529
 
    uint32_t        u32MemKernelNonPaged;
530
 
    /** Total amount of memory used for the system cache (in 4kb pages) */
531
 
    uint32_t        u32MemSystemCache;
532
 
    /** Pagefile size (in 4kb pages) */
533
 
    uint32_t        u32PageFileSize;
534
 
} VBoxGuestStatistics;
535
 
 
536
 
/** guest statistics command structure */
537
 
typedef struct
538
 
{
539
 
    /** header */
540
 
    VMMDevRequestHeader header;
541
 
    /** Guest information. */
542
 
    VBoxGuestStatistics guestStats;
543
 
} VMMDevReportGuestStats;
544
 
 
545
 
/** memory balloon change request structure */
546
 
#define VMMDEV_MAX_MEMORY_BALLOON(PhysMemTotal)     ((90*PhysMemTotal)/100)
547
 
 
548
 
typedef struct
549
 
{
550
 
    /** header */
551
 
    VMMDevRequestHeader header;
552
 
    uint32_t            u32BalloonSize;     /* balloon size in megabytes */
553
 
    uint32_t            u32PhysMemSize;     /* guest ram size in megabytes */
554
 
    uint32_t            eventAck;
555
 
} VMMDevGetMemBalloonChangeRequest;
556
 
 
557
 
/** inflate/deflate memory balloon structure */
558
 
#define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES            (_1M/4096)
559
 
#define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE             (VMMDEV_MEMORY_BALLOON_CHUNK_PAGES*4096)
560
 
 
561
 
typedef struct
562
 
{
563
 
    /** header */
564
 
    VMMDevRequestHeader header;
565
 
    uint32_t            cPages;
566
 
    uint32_t            fInflate;       /* true = inflate, false = defalte */
567
 
    /** Physical address (RTGCPHYS) of each page, variable size. */
568
 
    RTGCPHYS            aPhysPage[1];
569
 
} VMMDevChangeMemBalloon;
570
 
 
571
 
/** guest statistics interval change request structure */
572
 
typedef struct
573
 
{
574
 
    /** header */
575
 
    VMMDevRequestHeader header;
576
 
    uint32_t            u32StatInterval; /* interval in seconds */
577
 
    uint32_t            eventAck;
578
 
} VMMDevGetStatisticsChangeRequest;
579
 
 
580
 
/** display change request structure */
581
 
typedef struct
582
 
{
583
 
    /** header */
584
 
    VMMDevRequestHeader header;
585
 
    /** horizontal pixel resolution (0 = do not change) */
586
 
    uint32_t xres;
587
 
    /** vertical pixel resolution (0 = do not change) */
588
 
    uint32_t yres;
589
 
    /** bits per pixel (0 = do not change) */
590
 
    uint32_t bpp;
591
 
    /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
592
 
     *  Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
593
 
     */
594
 
    uint32_t eventAck;
595
 
} VMMDevDisplayChangeRequest;
596
 
 
597
 
typedef struct
598
 
{
599
 
    /** header */
600
 
    VMMDevRequestHeader header;
601
 
    /** horizontal pixel resolution (0 = do not change) */
602
 
    uint32_t xres;
603
 
    /** vertical pixel resolution (0 = do not change) */
604
 
    uint32_t yres;
605
 
    /** bits per pixel (0 = do not change) */
606
 
    uint32_t bpp;
607
 
    /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
608
 
     *  Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
609
 
     */
610
 
    uint32_t eventAck;
611
 
    /** 0 for primary display, 1 for the first secondary, etc. */
612
 
    uint32_t display;
613
 
} VMMDevDisplayChangeRequest2;
614
 
 
615
 
/** video mode supported request structure */
616
 
typedef struct
617
 
{
618
 
    /** header */
619
 
    VMMDevRequestHeader header;
620
 
    /** horizontal pixel resolution (input) */
621
 
    uint32_t width;
622
 
    /** vertical pixel resolution (input) */
623
 
    uint32_t height;
624
 
    /** bits per pixel (input) */
625
 
    uint32_t bpp;
626
 
    /** supported flag (output) */
627
 
    bool fSupported;
628
 
} VMMDevVideoModeSupportedRequest;
629
 
 
630
 
/** video modes height reduction request structure */
631
 
typedef struct
632
 
{
633
 
    /** header */
634
 
    VMMDevRequestHeader header;
635
 
    /** height reduction in pixels (output) */
636
 
    uint32_t heightReduction;
637
 
} VMMDevGetHeightReductionRequest;
638
 
 
639
 
#define VRDP_EXPERIENCE_LEVEL_ZERO     0 /* Theming disabled. */
640
 
#define VRDP_EXPERIENCE_LEVEL_LOW      1 /* Full window dragging and desktop wallpaper disabled. */
641
 
#define VRDP_EXPERIENCE_LEVEL_MEDIUM   2 /* Font smoothing, gradients. */
642
 
#define VRDP_EXPERIENCE_LEVEL_HIGH     3 /* Animation effects disabled. */
643
 
#define VRDP_EXPERIENCE_LEVEL_FULL     4 /* Everything enabled. */
644
 
 
645
 
typedef struct
646
 
{
647
 
    /** header */
648
 
    VMMDevRequestHeader header;
649
 
    /** Whether VRDP is active or not */
650
 
    uint8_t u8VRDPActive;
651
 
    /** The configured experience level for active VRDP. */
652
 
    uint32_t u32VRDPExperienceLevel;
653
 
} VMMDevVRDPChangeRequest;
654
 
 
655
 
 
656
 
 
657
 
#pragma pack()
658
 
 
659
 
#ifdef VBOX_WITH_HGCM
660
 
 
661
 
/** HGCM flags.
662
 
 *  @{
663
 
 */
664
 
#define VBOX_HGCM_REQ_DONE      (0x1)
665
 
#define VBOX_HGCM_REQ_CANCELLED (0x2)
666
 
/** @} */
667
 
 
668
 
#pragma pack(4)
669
 
typedef struct _VMMDevHGCMRequestHeader
670
 
{
671
 
    /** Request header. */
672
 
    VMMDevRequestHeader header;
673
 
 
674
 
    /** HGCM flags. */
675
 
    uint32_t fu32Flags;
676
 
 
677
 
    /** Result code. */
678
 
    int32_t result;
679
 
} VMMDevHGCMRequestHeader;
680
 
AssertCompileSize(VMMDevHGCMRequestHeader, 24+8);
681
 
 
682
 
/** HGCM service location types. */
683
 
typedef enum
684
 
{
685
 
    VMMDevHGCMLoc_Invalid    = 0,
686
 
    VMMDevHGCMLoc_LocalHost  = 1,
687
 
    VMMDevHGCMLoc_LocalHost_Existing = 2,
688
 
    VMMDevHGCMLoc_SizeHack   = 0x7fffffff
689
 
} HGCMServiceLocationType;
690
 
 
691
 
typedef struct
692
 
{
693
 
    char achName[128]; /**< This is really szName. */
694
 
} HGCMServiceLocationHost;
695
 
 
696
 
typedef struct HGCMSERVICELOCATION
697
 
{
698
 
    /** Type of the location. */
699
 
    HGCMServiceLocationType type;
700
 
 
701
 
    union
702
 
    {
703
 
        HGCMServiceLocationHost host;
704
 
    } u;
705
 
} HGCMServiceLocation;
706
 
 
707
 
typedef struct
708
 
{
709
 
    /* request header */
710
 
    VMMDevHGCMRequestHeader header;
711
 
 
712
 
    /** IN: Description of service to connect to. */
713
 
    HGCMServiceLocation loc;
714
 
 
715
 
    /** OUT: Client identifier assigned by local instance of HGCM. */
716
 
    uint32_t u32ClientID;
717
 
} VMMDevHGCMConnect;
718
 
 
719
 
typedef struct
720
 
{
721
 
    /* request header */
722
 
    VMMDevHGCMRequestHeader header;
723
 
 
724
 
    /** IN: Client identifier. */
725
 
    uint32_t u32ClientID;
726
 
} VMMDevHGCMDisconnect;
727
 
 
728
 
typedef enum
729
 
{
730
 
    VMMDevHGCMParmType_Invalid            = 0,
731
 
    VMMDevHGCMParmType_32bit              = 1,
732
 
    VMMDevHGCMParmType_64bit              = 2,
733
 
    VMMDevHGCMParmType_PhysAddr           = 3,
734
 
    VMMDevHGCMParmType_LinAddr            = 4, /**< In and Out */
735
 
    VMMDevHGCMParmType_LinAddr_In         = 5, /**< In  (read;  host<-guest) */
736
 
    VMMDevHGCMParmType_LinAddr_Out        = 6, /**< Out (write; host->guest) */
737
 
    VMMDevHGCMParmType_LinAddr_Locked     = 7, /**< Locked In and Out */
738
 
    VMMDevHGCMParmType_LinAddr_Locked_In  = 8, /**< Locked In  (read;  host<-guest) */
739
 
    VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */
740
 
    VMMDevHGCMParmType_SizeHack           = 0x7fffffff
741
 
} HGCMFunctionParameterType;
742
 
 
743
 
#ifdef VBOX_WITH_64_BITS_GUESTS
744
 
typedef struct _HGCMFUNCTIONPARAMETER32
745
 
{
746
 
    HGCMFunctionParameterType type;
747
 
    union
748
 
    {
749
 
        uint32_t   value32;
750
 
        uint64_t   value64;
751
 
        struct
752
 
        {
753
 
            uint32_t size;
754
 
 
755
 
            union
756
 
            {
757
 
                VMMDEVHYPPHYS32 physAddr;
758
 
                VMMDEVHYPPTR32  linearAddr;
759
 
            } u;
760
 
        } Pointer;
761
 
    } u;
762
 
#ifdef __cplusplus
763
 
    void SetUInt32(uint32_t u32)
764
 
    {
765
 
        type = VMMDevHGCMParmType_32bit;
766
 
        u.value64 = 0; /* init unused bits to 0 */
767
 
        u.value32 = u32;
768
 
    }
769
 
 
770
 
    int GetUInt32(uint32_t *pu32)
771
 
    {
772
 
        if (type == VMMDevHGCMParmType_32bit)
773
 
        {
774
 
            *pu32 = u.value32;
775
 
            return VINF_SUCCESS;
776
 
        }
777
 
        return VERR_INVALID_PARAMETER;
778
 
    }
779
 
 
780
 
    void SetUInt64(uint64_t u64)
781
 
    {
782
 
        type      = VMMDevHGCMParmType_64bit;
783
 
        u.value64 = u64;
784
 
    }
785
 
 
786
 
    int GetUInt64(uint64_t *pu64)
787
 
    {
788
 
        if (type == VMMDevHGCMParmType_64bit)
789
 
        {
790
 
            *pu64 = u.value64;
791
 
            return VINF_SUCCESS;
792
 
        }
793
 
        return VERR_INVALID_PARAMETER;
794
 
    }
795
 
 
796
 
    void SetPtr(void *pv, uint32_t cb)
797
 
    {
798
 
        type                    = VMMDevHGCMParmType_LinAddr;
799
 
        u.Pointer.size          = cb;
800
 
        u.Pointer.u.linearAddr  = (VMMDEVHYPPTR32)(uintptr_t)pv;
801
 
    }
802
 
#endif
803
 
} HGCMFunctionParameter32;
804
 
 
805
 
typedef struct _HGCMFUNCTIONPARAMETER64
806
 
{
807
 
    HGCMFunctionParameterType type;
808
 
    union
809
 
    {
810
 
        uint32_t   value32;
811
 
        uint64_t   value64;
812
 
        struct
813
 
        {
814
 
            uint32_t size;
815
 
 
816
 
            union
817
 
            {
818
 
                VMMDEVHYPPHYS64 physAddr;
819
 
                VMMDEVHYPPTR64  linearAddr;
820
 
            } u;
821
 
        } Pointer;
822
 
    } u;
823
 
#ifdef __cplusplus
824
 
    void SetUInt32(uint32_t u32)
825
 
    {
826
 
        type = VMMDevHGCMParmType_32bit;
827
 
        u.value64 = 0; /* init unused bits to 0 */
828
 
        u.value32 = u32;
829
 
    }
830
 
 
831
 
    int GetUInt32(uint32_t *pu32)
832
 
    {
833
 
        if (type == VMMDevHGCMParmType_32bit)
834
 
        {
835
 
            *pu32 = u.value32;
836
 
            return VINF_SUCCESS;
837
 
        }
838
 
        return VERR_INVALID_PARAMETER;
839
 
    }
840
 
 
841
 
    void SetUInt64(uint64_t u64)
842
 
    {
843
 
        type      = VMMDevHGCMParmType_64bit;
844
 
        u.value64 = u64;
845
 
    }
846
 
 
847
 
    int GetUInt64(uint64_t *pu64)
848
 
    {
849
 
        if (type == VMMDevHGCMParmType_64bit)
850
 
        {
851
 
            *pu64 = u.value64;
852
 
            return VINF_SUCCESS;
853
 
        }
854
 
        return VERR_INVALID_PARAMETER;
855
 
    }
856
 
 
857
 
    void SetPtr(void *pv, uint32_t cb)
858
 
    {
859
 
        type                    = VMMDevHGCMParmType_LinAddr;
860
 
        u.Pointer.size          = cb;
861
 
        u.Pointer.u.linearAddr  = (uintptr_t)pv;
862
 
    }
863
 
#endif
864
 
} HGCMFunctionParameter64;
865
 
#else /* !VBOX_WITH_64_BITS_GUESTS */
866
 
typedef struct _HGCMFUNCTIONPARAMETER
867
 
{
868
 
    HGCMFunctionParameterType type;
869
 
    union
870
 
    {
871
 
        uint32_t   value32;
872
 
        uint64_t   value64;
873
 
        struct
874
 
        {
875
 
            uint32_t size;
876
 
 
877
 
            union
878
 
            {
879
 
                VMMDEVHYPPHYS32 physAddr;
880
 
                VMMDEVHYPPTR32  linearAddr;
881
 
            } u;
882
 
        } Pointer;
883
 
    } u;
884
 
#ifdef __cplusplus
885
 
    void SetUInt32(uint32_t u32)
886
 
    {
887
 
        type = VMMDevHGCMParmType_32bit;
888
 
        u.value64 = 0; /* init unused bits to 0 */
889
 
        u.value32 = u32;
890
 
    }
891
 
 
892
 
    int GetUInt32(uint32_t *pu32)
893
 
    {
894
 
        if (type == VMMDevHGCMParmType_32bit)
895
 
        {
896
 
            *pu32 = u.value32;
897
 
            return VINF_SUCCESS;
898
 
        }
899
 
        return VERR_INVALID_PARAMETER;
900
 
    }
901
 
 
902
 
    void SetUInt64(uint64_t u64)
903
 
    {
904
 
        type      = VMMDevHGCMParmType_64bit;
905
 
        u.value64 = u64;
906
 
    }
907
 
 
908
 
    int GetUInt64(uint64_t *pu64)
909
 
    {
910
 
        if (type == VMMDevHGCMParmType_64bit)
911
 
        {
912
 
            *pu64 = u.value64;
913
 
            return VINF_SUCCESS;
914
 
        }
915
 
        return VERR_INVALID_PARAMETER;
916
 
    }
917
 
 
918
 
    void SetPtr(void *pv, uint32_t cb)
919
 
    {
920
 
        type                    = VMMDevHGCMParmType_LinAddr;
921
 
        u.Pointer.size          = cb;
922
 
        u.Pointer.u.linearAddr  = (uintptr_t)pv;
923
 
    }
924
 
#endif
925
 
} HGCMFunctionParameter;
926
 
#endif /* !VBOX_WITH_64_BITS_GUESTS */
927
 
 
928
 
 
929
 
#ifdef VBOX_WITH_64_BITS_GUESTS
930
 
/* Redefine the structure type for the guest code. */
931
 
# ifndef VBOX_HGCM_HOST_CODE
932
 
#  if ARCH_BITS == 64
933
 
#    define HGCMFunctionParameter HGCMFunctionParameter64
934
 
#  elif ARCH_BITS == 32
935
 
#    define HGCMFunctionParameter HGCMFunctionParameter32
936
 
#  else
937
 
#   error "Unsupported sizeof (void *)"
938
 
#  endif
939
 
# endif /* !VBOX_HGCM_HOST_CODE */
940
 
#endif /* VBOX_WITH_64_BITS_GUESTS */
941
 
 
942
 
typedef struct
943
 
{
944
 
    /* request header */
945
 
    VMMDevHGCMRequestHeader header;
946
 
 
947
 
    /** IN: Client identifier. */
948
 
    uint32_t u32ClientID;
949
 
    /** IN: Service function number. */
950
 
    uint32_t u32Function;
951
 
    /** IN: Number of parameters. */
952
 
    uint32_t cParms;
953
 
    /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
954
 
} VMMDevHGCMCall;
955
 
#pragma pack()
956
 
 
957
 
#define VMMDEV_HGCM_CALL_PARMS(a)   ((HGCMFunctionParameter *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
958
 
#define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
959
 
 
960
 
#ifdef VBOX_WITH_64_BITS_GUESTS
961
 
/* Explicit defines for the host code. */
962
 
# ifdef VBOX_HGCM_HOST_CODE
963
 
#  define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
964
 
#  define VMMDEV_HGCM_CALL_PARMS64(a) ((HGCMFunctionParameter64 *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
965
 
# endif /* VBOX_HGCM_HOST_CODE */
966
 
#endif /* VBOX_WITH_64_BITS_GUESTS */
967
 
 
968
 
#define VBOX_HGCM_MAX_PARMS 32
969
 
 
970
 
/* The Cancel request is issued using the same physical memory address
971
 
 * as was used for the corresponding initial HGCMCall.
972
 
 */
973
 
typedef struct
974
 
{
975
 
    /* request header */
976
 
    VMMDevHGCMRequestHeader header;
977
 
} VMMDevHGCMCancel;
978
 
 
979
 
#endif /* VBOX_WITH_HGCM */
980
 
 
981
 
 
982
 
#define VBVA_F_STATUS_ACCEPTED (0x01)
983
 
#define VBVA_F_STATUS_ENABLED  (0x02)
984
 
 
985
 
#pragma pack(4)
986
 
 
987
 
typedef struct _VMMDevVideoAccelEnable
988
 
{
989
 
    /* request header */
990
 
    VMMDevRequestHeader header;
991
 
 
992
 
    /** 0 - disable, !0 - enable. */
993
 
    uint32_t u32Enable;
994
 
 
995
 
    /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
996
 
     *  The host will refuse to enable VBVA if the size is not equal to
997
 
     *  VBVA_RING_BUFFER_SIZE.
998
 
     */
999
 
    uint32_t cbRingBuffer;
1000
 
 
1001
 
    /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
1002
 
    uint32_t fu32Status;
1003
 
 
1004
 
} VMMDevVideoAccelEnable;
1005
 
 
1006
 
typedef struct _VMMDevVideoAccelFlush
1007
 
{
1008
 
    /* request header */
1009
 
    VMMDevRequestHeader header;
1010
 
 
1011
 
} VMMDevVideoAccelFlush;
1012
 
 
1013
 
 
1014
 
typedef struct _VMMDevVideoSetVisibleRegion
1015
 
{
1016
 
    /* request header */
1017
 
    VMMDevRequestHeader header;
1018
 
 
1019
 
    /** Number of rectangles */
1020
 
    uint32_t cRect;
1021
 
 
1022
 
    /** Rectangle array */
1023
 
    RTRECT   Rect;
1024
 
} VMMDevVideoSetVisibleRegion;
1025
 
 
1026
 
 
1027
 
/** Seamless mode */
1028
 
typedef enum
1029
 
{
1030
 
    VMMDev_Seamless_Disabled         = 0,     /* normal mode; entire guest desktop displayed */
1031
 
    VMMDev_Seamless_Visible_Region   = 1,     /* visible region mode; only top-level guest windows displayed */
1032
 
    VMMDev_Seamless_Host_Window      = 2      /* windowed mode; each top-level guest window is represented in a host window */
1033
 
} VMMDevSeamlessMode;
1034
 
 
1035
 
typedef struct
1036
 
{
1037
 
    /** header */
1038
 
    VMMDevRequestHeader header;
1039
 
 
1040
 
    /** New seamless mode */
1041
 
    VMMDevSeamlessMode  mode;
1042
 
    /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST.
1043
 
     *  Values: 0 - just querying, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST - event acknowledged.
1044
 
     */
1045
 
    uint32_t eventAck;
1046
 
} VMMDevSeamlessChangeRequest;
1047
 
 
1048
 
#pragma pack()
1049
 
 
1050
 
#pragma pack(1)
1051
 
/** VBVA command header. */
1052
 
typedef struct _VBVACMDHDR
1053
 
{
1054
 
   /** Coordinates of affected rectangle. */
1055
 
   int16_t x;
1056
 
   int16_t y;
1057
 
   uint16_t w;
1058
 
   uint16_t h;
1059
 
} VBVACMDHDR;
1060
 
#pragma pack()
1061
 
 
1062
 
/* The VBVA ring buffer is suitable for transferring large (< 2gb) amount of data.
1063
 
 * For example big bitmaps which do not fit to the buffer.
1064
 
 *
1065
 
 * Guest starts writing to the buffer by initializing a record entry in the
1066
 
 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
1067
 
 * written. As data is written to the ring buffer, the guest increases off32End
1068
 
 * for the record.
1069
 
 *
1070
 
 * The host reads the aRecords on flushes and processes all completed records.
1071
 
 * When host encounters situation when only a partial record presents and
1072
 
 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE - VBVA_RING_BUFFER_THRESHOLD,
1073
 
 * the host fetched all record data and updates off32Head. After that on each flush
1074
 
 * the host continues fetching the data until the record is completed.
1075
 
 *
1076
 
 */
1077
 
 
1078
 
#define VBVA_RING_BUFFER_SIZE        (_4M - _1K)
1079
 
#define VBVA_RING_BUFFER_THRESHOLD   (4 * _1K)
1080
 
 
1081
 
#define VBVA_MAX_RECORDS (64)
1082
 
 
1083
 
#define VBVA_F_MODE_ENABLED         (0x00000001)
1084
 
#define VBVA_F_MODE_VRDP            (0x00000002)
1085
 
#define VBVA_F_MODE_VRDP_RESET      (0x00000004)
1086
 
#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
1087
 
 
1088
 
#define VBVA_F_RECORD_PARTIAL   (0x80000000)
1089
 
 
1090
 
#pragma pack(1)
1091
 
typedef struct _VBVARECORD
1092
 
{
1093
 
    /** The length of the record. Changed by guest. */
1094
 
    uint32_t cbRecord;
1095
 
} VBVARECORD;
1096
 
 
1097
 
typedef struct _VBVAMEMORY
1098
 
{
1099
 
    /** VBVA_F_MODE_* */
1100
 
    uint32_t fu32ModeFlags;
1101
 
 
1102
 
    /** The offset where the data start in the buffer. */
1103
 
    uint32_t off32Data;
1104
 
    /** The offset where next data must be placed in the buffer. */
1105
 
    uint32_t off32Free;
1106
 
 
1107
 
    /** The ring buffer for data. */
1108
 
    uint8_t  au8RingBuffer[VBVA_RING_BUFFER_SIZE];
1109
 
 
1110
 
    /** The queue of record descriptions. */
1111
 
    VBVARECORD aRecords[VBVA_MAX_RECORDS];
1112
 
    uint32_t indexRecordFirst;
1113
 
    uint32_t indexRecordFree;
1114
 
 
1115
 
    /* RDP orders supported by the client. The guest reports only them
1116
 
     * and falls back to DIRTY rects for not supported ones.
1117
 
     *
1118
 
     * (1 << VBVA_VRDP_*)
1119
 
     */
1120
 
    uint32_t fu32SupportedOrders;
1121
 
 
1122
 
} VBVAMEMORY;
1123
 
#pragma pack()
1124
 
 
1125
 
/** @} */
1126
 
 
1127
 
 
1128
 
/**
1129
 
 * VMMDev RAM
1130
 
 * @{
1131
 
 */
1132
 
 
1133
 
#pragma pack(1)
1134
 
/** Layout of VMMDEV RAM region that contains information for guest */
1135
 
typedef struct
1136
 
{
1137
 
    /** size */
1138
 
    uint32_t u32Size;
1139
 
    /** version */
1140
 
    uint32_t u32Version;
1141
 
 
1142
 
    union {
1143
 
        /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
1144
 
        struct {
1145
 
            bool fHaveEvents;
1146
 
        } V1_04;
1147
 
 
1148
 
        struct {
1149
 
            /** Pending events flags, set by host. */
1150
 
            uint32_t u32HostEvents;
1151
 
            /** Mask of events the guest wants to see, set by guest. */
1152
 
            uint32_t u32GuestEventMask;
1153
 
        } V1_03;
1154
 
    } V;
1155
 
 
1156
 
    VBVAMEMORY vbvaMemory;
1157
 
 
1158
 
} VMMDevMemory;
1159
 
#pragma pack()
1160
 
 
1161
 
/** Version of VMMDevMemory structure. */
1162
 
#define VMMDEV_MEMORY_VERSION (1)
1163
 
 
1164
 
/** @} */
1165
 
 
1166
 
 
1167
 
/**
1168
 
 * VMMDev events.
1169
 
 * @{
1170
 
 */
1171
 
 
1172
 
/** Host mouse capabilities has been changed. */
1173
 
#define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED             RT_BIT(0)
1174
 
/** HGCM event. */
1175
 
#define VMMDEV_EVENT_HGCM                                   RT_BIT(1)
1176
 
/** A display change request has been issued. */
1177
 
#define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST                 RT_BIT(2)
1178
 
/** Credentials are available for judgement. */
1179
 
#define VMMDEV_EVENT_JUDGE_CREDENTIALS                      RT_BIT(3)
1180
 
/** The guest has been restored. */
1181
 
#define VMMDEV_EVENT_RESTORED                               RT_BIT(4)
1182
 
/** Seamless mode state changed */
1183
 
#define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST           RT_BIT(5)
1184
 
/** Memory balloon size changed */
1185
 
#define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST                 RT_BIT(6)
1186
 
/** Statistics interval changed */
1187
 
#define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST     RT_BIT(7)
1188
 
/** VRDP status changed. */
1189
 
#define VMMDEV_EVENT_VRDP                                   RT_BIT(8)
1190
 
/** New mouse position data available */
1191
 
#define VMMDEV_EVENT_MOUSE_POSITION_CHANGED                 RT_BIT(9)
1192
 
 
1193
 
/** @} */
 
64
# define VBOXGUEST_DEVICE_NAME_NT       L"\\Device\\VBoxGuest"
 
65
/** Device name. */
 
66
# define VBOXGUEST_DEVICE_NAME_DOS      L"\\DosDevices\\VBoxGuest"
 
67
 
 
68
#else /* (PORTME) */
 
69
# define VBOXGUEST_DEVICE_NAME          "/dev/vboxguest"
 
70
# if defined(RT_OS_LINUX)
 
71
#  define VBOXGUEST_USER_DEVICE_NAME    "/dev/vboxuser"
 
72
# endif
 
73
#endif
 
74
 
 
75
#ifndef VBOXGUEST_USER_DEVICE_NAME
 
76
# define VBOXGUEST_USER_DEVICE_NAME     VBOXGUEST_DEVICE_NAME
 
77
#endif
 
78
 
 
79
/** Fictive start address of the hypervisor physical memory for MmMapIoSpace. */
 
80
#define VBOXGUEST_HYPERVISOR_PHYSICAL_START     UINT32_C(0xf8000000)
1194
81
 
1195
82
 
1196
83
#if !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT)
1204
91
 * The 8th bit is reserved for distinguishing between 32-bit and 64-bit
1205
92
 * processes in future 64-bit guest additions.
1206
93
 *
1207
 
 * While windows IOCTL function number has to start at 2048 and stop at 4096 there
1208
 
 * never was any need to do this for everyone. A simple ((Function) | 0x800) would
1209
 
 * have sufficed. On Linux we're now intruding upon the type field. Fortunately
1210
 
 * this hasn't caused any trouble because the FILE_DEVICE_UNKNOWN value was set
1211
 
 * to 0x22 (if it were 0x2C it would not have worked soo smoothly). The situation
1212
 
 * would've been the same for *BSD and Darwin since they seems to share common
1213
 
 * _IOC() heritage.
1214
 
 *
1215
 
 * However, on good old OS/2 we only have 8-bit handy for the function number. The
1216
 
 * result from using the old IOCTL function numbers her would've been overlapping
1217
 
 * between the two ranges.
1218
 
 *
1219
 
 * To fix this problem and get rid of all the unnecessary windowsy crap that I
1220
 
 * bet was copied from my SUPDRVIOC.h once upon a time (although the concept of
1221
 
 * prefixing macros with the purpose of avoid clashes with system stuff and
1222
 
 * to indicate exactly how owns them seems to have been lost somewhere along
1223
 
 * the way), I've introduced a VBOXGUEST_IOCTL_CODE for defining generic IN/OUT
1224
 
 * IOCtls on new ports of the additions.
1225
 
 *
1226
94
 * @remarks When creating new IOCtl interfaces keep in mind that not all OSes supports
1227
95
 *          reporting back the output size. (This got messed up a little bit in VBoxDrv.)
1228
96
 *
1268
136
#if HC_ARCH_BITS == 32
1269
137
    uint32_t    u32Padding;
1270
138
#endif
 
139
/** @todo r=bird: We need a 'rc' field for passing VBox status codes. Reused
 
140
 *        some input field as rc on output. */
1271
141
} VBGLBIGREQ;
1272
142
/** Pointer to a request wrapper for solaris guests. */
1273
143
typedef VBGLBIGREQ *PVBGLBIGREQ;
1275
145
typedef const VBGLBIGREQ *PCVBGLBIGREQ;
1276
146
 
1277
147
/** The VBGLBIGREQ::u32Magic value (Ryuu Murakami). */
1278
 
#define VBGLBIGREQ_MAGIC                        0x19520219
 
148
#define VBGLBIGREQ_MAGIC                            0x19520219
1279
149
 
1280
150
 
1281
151
#if defined(RT_OS_WINDOWS)
1283
153
/** @todo r=bird: IOCTL_CODE is supposedly defined in some header included by Windows.h or ntddk.h, which is why it wasn't in the #if 0 earlier. See HostDrivers/Support/SUPDrvIOC.h... */
1284
154
# define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
1285
155
  ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1286
 
# define VBOXGUEST_IOCTL_CODE_(Function, Size)  IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
1287
 
# define VBOXGUEST_IOCTL_STRIP_SIZE_(Code)      (Code)
 
156
# define VBOXGUEST_IOCTL_CODE_(Function, Size)      IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
 
157
# define VBOXGUEST_IOCTL_STRIP_SIZE_(Code)          (Code)
1288
158
 
1289
159
#elif defined(RT_OS_OS2)
1290
160
  /* No automatic buffering, size not encoded. */
1291
 
# define VBOXGUEST_IOCTL_CATEGORY               0xc2
1292
 
# define VBOXGUEST_IOCTL_CODE_(Function, Size)  ((unsigned char)(Function))
1293
 
# define VBOXGUEST_IOCTL_CATEGORY_FAST          0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
1294
 
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)   ((unsigned char)(Function))
1295
 
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)       (Code)
 
161
# define VBOXGUEST_IOCTL_CATEGORY                   0xc2
 
162
# define VBOXGUEST_IOCTL_CODE_(Function, Size)      ((unsigned char)(Function))
 
163
# define VBOXGUEST_IOCTL_CATEGORY_FAST              0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
 
164
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)       ((unsigned char)(Function))
 
165
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)           (Code)
1296
166
 
1297
167
#elif defined(RT_OS_SOLARIS)
1298
168
  /* No automatic buffering, size limited to 255 bytes => use VBGLBIGREQ for everything. */
1299
169
# include <sys/ioccom.h>
1300
 
# define VBOXGUEST_IOCTL_CODE_(Function, Size)  _IOWRN('V', (Function), sizeof(VBGLBIGREQ))
1301
 
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)   _IO(  'V', (Function))
1302
 
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)       (Code)
 
170
# define VBOXGUEST_IOCTL_CODE_(Function, Size)      _IOWRN('V', (Function), sizeof(VBGLBIGREQ))
 
171
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)       _IO(  'V', (Function))
 
172
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)           (Code)
1303
173
 
1304
174
#elif defined(RT_OS_LINUX)
1305
175
  /* No automatic buffering, size limited to 16KB. */
1306
176
# include <linux/ioctl.h>
1307
 
# define VBOXGUEST_IOCTL_CODE_(Function, Size)  _IOC(_IOC_READ|_IOC_WRITE, 'V', (Function), (Size))
1308
 
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)   _IO(  'V', (Function))
1309
 
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)       VBOXGUEST_IOCTL_CODE_(_IOC_NR((Code)), 0)
 
177
# define VBOXGUEST_IOCTL_CODE_(Function, Size)      _IOC(_IOC_READ|_IOC_WRITE, 'V', (Function), (Size))
 
178
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)       _IO(  'V', (Function))
 
179
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)           VBOXGUEST_IOCTL_CODE_(_IOC_NR((Code)), 0)
1310
180
 
1311
181
#elif defined(RT_OS_FREEBSD) /** @todo r=bird: Please do it like SUPDRVIOC to keep it as similar as possible. */
1312
182
# include <sys/ioccom.h>
1313
183
 
1314
 
# define VBOXGUEST_IOCTL_CODE_(Function, Size)  _IOWR('V', (Function), VBGLBIGREQ)
1315
 
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)   _IO(  'V', (Function))
1316
 
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)       IOCBASECMD(Code)
 
184
# define VBOXGUEST_IOCTL_CODE_(Function, Size)      _IOWR('V', (Function), VBGLBIGREQ)
 
185
# define VBOXGUEST_IOCTL_CODE_FAST_(Function)       _IO(  'V', (Function))
 
186
# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)           IOCBASECMD(Code)
1317
187
 
1318
188
#else
1319
189
/* PORTME */
1320
190
#endif
1321
191
 
1322
 
#define VBOXGUEST_IOCTL_CODE(Function, Size)     VBOXGUEST_IOCTL_CODE_((Function) | VBOXGUEST_IOCTL_FLAG, Size)
1323
 
#define VBOXGUEST_IOCTL_CODE_FAST(Function)      VBOXGUEST_IOCTL_CODE_FAST_((Function) | VBOXGUEST_IOCTL_FLAG)
 
192
#define VBOXGUEST_IOCTL_CODE(Function, Size)        VBOXGUEST_IOCTL_CODE_((Function) | VBOXGUEST_IOCTL_FLAG, Size)
 
193
#define VBOXGUEST_IOCTL_CODE_FAST(Function)         VBOXGUEST_IOCTL_CODE_FAST_((Function) | VBOXGUEST_IOCTL_FLAG)
1324
194
 
1325
195
/* Define 32 bit codes to support 32 bit applications requests in the 64 bit guest driver. */
1326
196
#ifdef RT_ARCH_AMD64
1327
 
# define VBOXGUEST_IOCTL_CODE_32(Function, Size) VBOXGUEST_IOCTL_CODE_(Function, Size)
1328
 
# define VBOXGUEST_IOCTL_CODE_FAST_32(Function)  VBOXGUEST_IOCTL_CODE_FAST_(Function)
 
197
# define VBOXGUEST_IOCTL_CODE_32(Function, Size)    VBOXGUEST_IOCTL_CODE_(Function, Size)
 
198
# define VBOXGUEST_IOCTL_CODE_FAST_32(Function)     VBOXGUEST_IOCTL_CODE_FAST_(Function)
1329
199
#endif /* RT_ARCH_AMD64 */
1330
200
 
 
201
 
 
202
 
1331
203
/** IOCTL to VBoxGuest to query the VMMDev IO port region start.
1332
204
 * @remarks Ring-0 only. */
1333
 
#define VBOXGUEST_IOCTL_GETVMMDEVPORT   VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
 
205
#define VBOXGUEST_IOCTL_GETVMMDEVPORT               VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
1334
206
 
1335
207
#pragma pack(4)
1336
 
typedef struct _VBoxGuestPortInfo
 
208
typedef struct VBoxGuestPortInfo
1337
209
{
1338
210
    uint32_t portAddress;
1339
 
    VMMDevMemory *pVMMDevMemory;
 
211
    struct VMMDevMemory *pVMMDevMemory;
1340
212
} VBoxGuestPortInfo;
1341
213
 
 
214
 
1342
215
/** IOCTL to VBoxGuest to wait for a VMMDev host notification */
1343
 
#define VBOXGUEST_IOCTL_WAITEVENT       VBOXGUEST_IOCTL_CODE_(2, sizeof(VBoxGuestWaitEventInfo))
1344
 
 
1345
 
/** IOCTL to VBoxGuest to interrupt (cancel) any pending WAITEVENTs and return.
1346
 
 * Handled inside the guest additions and not seen by the host at all.
1347
 
 * @see VBOXGUEST_IOCTL_WAITEVENT */
1348
 
#define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS       VBOXGUEST_IOCTL_CODE_(5, 0)
 
216
#define VBOXGUEST_IOCTL_WAITEVENT                   VBOXGUEST_IOCTL_CODE_(2, sizeof(VBoxGuestWaitEventInfo))
1349
217
 
1350
218
/** @name Result codes for VBoxGuestWaitEventInfo::u32Result
1351
219
 * @{
1361
229
/** @} */
1362
230
 
1363
231
/** Input and output buffers layout of the IOCTL_VBOXGUEST_WAITEVENT */
1364
 
typedef struct _VBoxGuestWaitEventInfo
 
232
typedef struct VBoxGuestWaitEventInfo
1365
233
{
1366
234
    /** timeout in milliseconds */
1367
235
    uint32_t u32TimeoutIn;
1374
242
} VBoxGuestWaitEventInfo;
1375
243
AssertCompileSize(VBoxGuestWaitEventInfo, 16);
1376
244
 
 
245
 
 
246
/** IOCTL to VBoxGuest to interrupt (cancel) any pending WAITEVENTs and return.
 
247
 * Handled inside the guest additions and not seen by the host at all.
 
248
 * @see VBOXGUEST_IOCTL_WAITEVENT */
 
249
#define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS       VBOXGUEST_IOCTL_CODE_(5, 0)
 
250
 
 
251
 
 
252
 
1377
253
/** IOCTL to VBoxGuest to perform a VMM request
1378
254
 * @remark  The data buffer for this IOCtl has an variable size, keep this in mind
1379
255
 *          on systems where this matters. */
1380
256
#define VBOXGUEST_IOCTL_VMMREQUEST(Size)            VBOXGUEST_IOCTL_CODE_(3, (Size))
1381
257
 
 
258
 
 
259
/** IOCTL to VBoxGuest to control event filter mask. */
 
260
#define VBOXGUEST_IOCTL_CTL_FILTER_MASK             VBOXGUEST_IOCTL_CODE_(4, sizeof(VBoxGuestFilterMaskInfo))
 
261
 
1382
262
/** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
1383
 
typedef struct _VBoxGuestFilterMaskInfo
 
263
typedef struct VBoxGuestFilterMaskInfo
1384
264
{
1385
265
    uint32_t u32OrMask;
1386
266
    uint32_t u32NotMask;
1388
268
AssertCompileSize(VBoxGuestFilterMaskInfo, 8);
1389
269
#pragma pack()
1390
270
 
1391
 
/** IOCTL to VBoxGuest to control event filter mask. */
1392
 
#define VBOXGUEST_IOCTL_CTL_FILTER_MASK             VBOXGUEST_IOCTL_CODE_(4, sizeof(VBoxGuestFilterMaskInfo))
1393
271
 
1394
272
/** IOCTL to VBoxGuest to check memory ballooning. */
1395
273
#define VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK      VBOXGUEST_IOCTL_CODE_(7, 100)
1396
274
 
1397
 
/** IOCTL to VBoxGuest to perform backdoor logging. */
 
275
 
 
276
/** IOCTL to VBoxGuest to perform backdoor logging.
 
277
 * The argument is a string buffer of the specified size. */
1398
278
#define VBOXGUEST_IOCTL_LOG(Size)                   VBOXGUEST_IOCTL_CODE_(6, (Size))
1399
279
 
1400
280
 
1401
281
#ifdef VBOX_WITH_HGCM
1402
 
/* These structures are shared between the driver and other binaries,
1403
 
 * therefore packing must be defined explicitely.
1404
 
 */
1405
 
# pragma pack(1)
1406
 
typedef struct _VBoxGuestHGCMConnectInfo
1407
 
{
1408
 
    int32_t result;           /**< OUT */
1409
 
    HGCMServiceLocation Loc;  /**< IN */
1410
 
    uint32_t u32ClientID;     /**< OUT */
1411
 
} VBoxGuestHGCMConnectInfo;
1412
 
AssertCompileSize(VBoxGuestHGCMConnectInfo, 4+4+128+4);
1413
 
 
1414
 
typedef struct _VBoxGuestHGCMDisconnectInfo
1415
 
{
1416
 
    int32_t result;           /**< OUT */
1417
 
    uint32_t u32ClientID;     /**< IN */
1418
 
} VBoxGuestHGCMDisconnectInfo;
1419
 
AssertCompileSize(VBoxGuestHGCMDisconnectInfo, 8);
1420
 
 
1421
 
typedef struct _VBoxGuestHGCMCallInfo
1422
 
{
1423
 
    int32_t result;           /**< OUT Host HGCM return code.*/
1424
 
    uint32_t u32ClientID;     /**< IN  The id of the caller. */
1425
 
    uint32_t u32Function;     /**< IN  Function number. */
1426
 
    uint32_t cParms;          /**< IN  How many parms. */
1427
 
    /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
1428
 
} VBoxGuestHGCMCallInfo;
1429
 
AssertCompileSize(VBoxGuestHGCMCallInfo, 16);
1430
 
 
1431
 
typedef struct _VBoxGuestHGCMCallInfoTimed
1432
 
{
1433
 
    uint32_t u32Timeout;         /**< IN  How long to wait for completion before cancelling the call */
1434
 
    uint32_t fInterruptible;     /**< IN  Is this request interruptible? */
1435
 
    VBoxGuestHGCMCallInfo info;  /**< IN/OUT The rest of the call information.  Placed after the timeout
1436
 
                                  * so that the parameters follow as they would for a normal call. */
1437
 
    /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
1438
 
} VBoxGuestHGCMCallInfoTimed;
1439
 
AssertCompileSize(VBoxGuestHGCMCallInfoTimed, 8+16);
1440
 
# pragma pack()
1441
 
 
1442
 
# define VBOXGUEST_IOCTL_HGCM_CONNECT             VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
1443
 
# define VBOXGUEST_IOCTL_HGCM_DISCONNECT          VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
1444
 
# define VBOXGUEST_IOCTL_HGCM_CALL(Size)          VBOXGUEST_IOCTL_CODE(18, (Size))
1445
 
# define VBOXGUEST_IOCTL_HGCM_CALL_TIMED(Size)    VBOXGUEST_IOCTL_CODE(20, (Size))
1446
 
# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT        VBOXGUEST_IOCTL_CODE_(19, sizeof(uint32_t))
 
282
/** IOCTL to VBoxGuest to connect to a HGCM service. */
 
283
# define VBOXGUEST_IOCTL_HGCM_CONNECT               VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
 
284
 
 
285
/** IOCTL to VBoxGuest to disconnect from a HGCM service. */
 
286
# define VBOXGUEST_IOCTL_HGCM_DISCONNECT            VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
 
287
 
 
288
/** IOCTL to VBoxGuest to make a call to a HGCM service.
 
289
 * @see VBoxGuestHGCMCallInfo */
 
290
# define VBOXGUEST_IOCTL_HGCM_CALL(Size)            VBOXGUEST_IOCTL_CODE(18, (Size))
 
291
 
 
292
/** IOCTL to VBoxGuest to make a timed call to a HGCM service. */
 
293
# define VBOXGUEST_IOCTL_HGCM_CALL_TIMED(Size)      VBOXGUEST_IOCTL_CODE(20, (Size))
 
294
 
1447
295
# ifdef RT_ARCH_AMD64
1448
 
/* Following HGCM IOCtls can be used by a 32 bit application on a 64 bit guest (Windows OpenGL guest driver). */
1449
 
#  define VBOXGUEST_IOCTL_HGCM_CONNECT_32         VBOXGUEST_IOCTL_CODE_32(16, sizeof(VBoxGuestHGCMConnectInfo))
1450
 
#  define VBOXGUEST_IOCTL_HGCM_DISCONNECT_32      VBOXGUEST_IOCTL_CODE_32(17, sizeof(VBoxGuestHGCMDisconnectInfo))
1451
 
#  define VBOXGUEST_IOCTL_HGCM_CALL_32(Size)      VBOXGUEST_IOCTL_CODE_32(18, (Size))
1452
 
#  define VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(Size) VBOXGUEST_IOCTL_CODE_32(20, (Size))
 
296
/** @name IOCTL numbers that 32-bit clients, like the Windows OpenGL guest
 
297
 *        driver, will use when taking to a 64-bit driver.
 
298
 * @remarks These are only used by the driver implementation! */
 
299
#  define VBOXGUEST_IOCTL_HGCM_CONNECT_32           VBOXGUEST_IOCTL_CODE_32(16, sizeof(VBoxGuestHGCMConnectInfo))
 
300
#  define VBOXGUEST_IOCTL_HGCM_DISCONNECT_32        VBOXGUEST_IOCTL_CODE_32(17, sizeof(VBoxGuestHGCMDisconnectInfo))
 
301
#  define VBOXGUEST_IOCTL_HGCM_CALL_32(Size)        VBOXGUEST_IOCTL_CODE_32(18, (Size))
 
302
#  define VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(Size)  VBOXGUEST_IOCTL_CODE_32(20, (Size))
 
303
/** @} */
1453
304
# endif /* RT_ARCH_AMD64 */
1454
305
 
1455
 
# define VBOXGUEST_HGCM_CALL_PARMS(a)       ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
1456
 
# define VBOXGUEST_HGCM_CALL_PARMS32(a)     ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
1457
 
 
1458
 
#endif /* VBOX_WITH_HGCM */
1459
 
 
1460
 
/*
1461
 
 * Credentials request flags and structure
1462
 
 */
1463
 
 
1464
 
#define VMMDEV_CREDENTIALS_STRLEN           128
1465
 
 
1466
 
/** query from host whether credentials are present */
1467
 
#define VMMDEV_CREDENTIALS_QUERYPRESENCE     RT_BIT(1)
1468
 
/** read credentials from host (can be combined with clear) */
1469
 
#define VMMDEV_CREDENTIALS_READ              RT_BIT(2)
1470
 
/** clear credentials on host (can be combined with read) */
1471
 
#define VMMDEV_CREDENTIALS_CLEAR             RT_BIT(3)
1472
 
/** read credentials for judgement in the guest */
1473
 
#define VMMDEV_CREDENTIALS_READJUDGE         RT_BIT(8)
1474
 
/** clear credentials for judegement on the host */
1475
 
#define VMMDEV_CREDENTIALS_CLEARJUDGE        RT_BIT(9)
1476
 
/** report credentials acceptance by guest */
1477
 
#define VMMDEV_CREDENTIALS_JUDGE_OK          RT_BIT(10)
1478
 
/** report credentials denial by guest */
1479
 
#define VMMDEV_CREDENTIALS_JUDGE_DENY        RT_BIT(11)
1480
 
/** report that no judgement could be made by guest */
1481
 
#define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT RT_BIT(12)
1482
 
 
1483
 
/** flag telling the guest that credentials are present */
1484
 
#define VMMDEV_CREDENTIALS_PRESENT           RT_BIT(16)
1485
 
/** flag telling guest that local logons should be prohibited */
1486
 
#define VMMDEV_CREDENTIALS_NOLOCALLOGON      RT_BIT(17)
1487
 
 
1488
 
/** credentials request structure */
1489
 
#pragma pack(4)
1490
 
typedef struct _VMMDevCredentials
1491
 
{
1492
 
    /* request header */
1493
 
    VMMDevRequestHeader header;
1494
 
    /* request flags (in/out) */
1495
 
    uint32_t u32Flags;
1496
 
    /* user name (UTF-8) (out) */
1497
 
    char szUserName[VMMDEV_CREDENTIALS_STRLEN];
1498
 
    /* password (UTF-8) (out) */
1499
 
    char szPassword[VMMDEV_CREDENTIALS_STRLEN];
1500
 
    /* domain name (UTF-8) (out) */
1501
 
    char szDomain[VMMDEV_CREDENTIALS_STRLEN];
1502
 
} VMMDevCredentials;
1503
 
#pragma pack()
1504
 
 
1505
 
/** inline helper to determine the request size for the given operation */
1506
 
DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
1507
 
{
1508
 
    switch (requestType)
1509
 
    {
1510
 
        case VMMDevReq_GetMouseStatus:
1511
 
        case VMMDevReq_SetMouseStatus:
1512
 
            return sizeof(VMMDevReqMouseStatus);
1513
 
        case VMMDevReq_SetPointerShape:
1514
 
            return sizeof(VMMDevReqMousePointer);
1515
 
        case VMMDevReq_GetHostVersion:
1516
 
            return sizeof(VMMDevReqHostVersion);
1517
 
        case VMMDevReq_Idle:
1518
 
            return sizeof(VMMDevReqIdle);
1519
 
        case VMMDevReq_GetHostTime:
1520
 
            return sizeof(VMMDevReqHostTime);
1521
 
        case VMMDevReq_GetHypervisorInfo:
1522
 
        case VMMDevReq_SetHypervisorInfo:
1523
 
            return sizeof(VMMDevReqHypervisorInfo);
1524
 
        case VMMDevReq_RegisterPatchMemory:
1525
 
        case VMMDevReq_DeregisterPatchMemory:
1526
 
            return sizeof(VMMDevReqPatchMemory);
1527
 
        case VMMDevReq_SetPowerStatus:
1528
 
            return sizeof(VMMDevPowerStateRequest);
1529
 
        case VMMDevReq_AcknowledgeEvents:
1530
 
            return sizeof(VMMDevEvents);
1531
 
        case VMMDevReq_ReportGuestInfo:
1532
 
            return sizeof(VMMDevReportGuestInfo);
1533
 
        case VMMDevReq_GetDisplayChangeRequest:
1534
 
            return sizeof(VMMDevDisplayChangeRequest);
1535
 
        case VMMDevReq_GetDisplayChangeRequest2:
1536
 
            return sizeof(VMMDevDisplayChangeRequest2);
1537
 
        case VMMDevReq_VideoModeSupported:
1538
 
            return sizeof(VMMDevVideoModeSupportedRequest);
1539
 
        case VMMDevReq_GetHeightReduction:
1540
 
            return sizeof(VMMDevGetHeightReductionRequest);
1541
 
        case VMMDevReq_ReportGuestCapabilities:
1542
 
            return sizeof(VMMDevReqGuestCapabilities);
1543
 
        case VMMDevReq_SetGuestCapabilities:
1544
 
            return sizeof(VMMDevReqGuestCapabilities2);
1545
 
#ifdef VBOX_WITH_HGCM
1546
 
        case VMMDevReq_HGCMConnect:
1547
 
            return sizeof(VMMDevHGCMConnect);
1548
 
        case VMMDevReq_HGCMDisconnect:
1549
 
            return sizeof(VMMDevHGCMDisconnect);
1550
 
#ifdef VBOX_WITH_64_BITS_GUESTS
1551
 
        case VMMDevReq_HGCMCall32:
1552
 
            return sizeof(VMMDevHGCMCall);
1553
 
        case VMMDevReq_HGCMCall64:
1554
 
            return sizeof(VMMDevHGCMCall);
1555
 
#else
1556
 
        case VMMDevReq_HGCMCall:
1557
 
            return sizeof(VMMDevHGCMCall);
1558
 
#endif /* VBOX_WITH_64_BITS_GUESTS */
1559
 
        case VMMDevReq_HGCMCancel:
1560
 
            return sizeof(VMMDevHGCMCancel);
1561
 
#endif /* VBOX_WITH_HGCM */
1562
 
        case VMMDevReq_VideoAccelEnable:
1563
 
            return sizeof(VMMDevVideoAccelEnable);
1564
 
        case VMMDevReq_VideoAccelFlush:
1565
 
            return sizeof(VMMDevVideoAccelFlush);
1566
 
        case VMMDevReq_VideoSetVisibleRegion:
1567
 
            return sizeof(VMMDevVideoSetVisibleRegion);
1568
 
        case VMMDevReq_GetSeamlessChangeRequest:
1569
 
            return sizeof(VMMDevSeamlessChangeRequest);
1570
 
        case VMMDevReq_QueryCredentials:
1571
 
            return sizeof(VMMDevCredentials);
1572
 
        case VMMDevReq_ReportGuestStats:
1573
 
            return sizeof(VMMDevReportGuestStats);
1574
 
        case VMMDevReq_GetMemBalloonChangeRequest:
1575
 
            return sizeof(VMMDevGetMemBalloonChangeRequest);
1576
 
        case VMMDevReq_GetStatisticsChangeRequest:
1577
 
            return sizeof(VMMDevGetStatisticsChangeRequest);
1578
 
        case VMMDevReq_ChangeMemBalloon:
1579
 
            return sizeof(VMMDevChangeMemBalloon);
1580
 
        case VMMDevReq_GetVRDPChangeRequest:
1581
 
            return sizeof(VMMDevVRDPChangeRequest);
1582
 
        case VMMDevReq_LogString:
1583
 
            return sizeof(VMMDevReqLogString);
1584
 
        default:
1585
 
            return 0;
1586
 
    }
1587
 
}
1588
 
 
1589
 
/**
1590
 
 * Initializes a request structure.
1591
 
 *
1592
 
 */
1593
 
DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
1594
 
{
1595
 
    uint32_t requestSize;
1596
 
    if (!req)
1597
 
        return VERR_INVALID_PARAMETER;
1598
 
    requestSize = (uint32_t)vmmdevGetRequestSize(type);
1599
 
    if (!requestSize)
1600
 
        return VERR_INVALID_PARAMETER;
1601
 
    req->size        = requestSize;
1602
 
    req->version     = VMMDEV_REQUEST_HEADER_VERSION;
1603
 
    req->requestType = type;
1604
 
    req->rc          = VERR_GENERAL_FAILURE;
1605
 
    req->reserved1   = 0;
1606
 
    req->reserved2   = 0;
1607
 
    return VINF_SUCCESS;
1608
 
}
 
306
/** Get the pointer to the first HGCM parameter.  */
 
307
# define VBOXGUEST_HGCM_CALL_PARMS(a)             ( (HGCMFunctionParameter   *)((uint8_t *)(a) + sizeof(VBoxGuestHGCMCallInfo)) )
 
308
/** Get the pointer to the first HGCM parameter in a 32-bit request.  */
 
309
# define VBOXGUEST_HGCM_CALL_PARMS32(a)           ( (HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof(VBoxGuestHGCMCallInfo)) )
 
310
 
 
311
/** IOCTL to VBoxGuest to make a connect to the clipboard service.
 
312
 * @todo Seems this is no longer is use. Try remove it. */
 
313
# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT        VBOXGUEST_IOCTL_CODE_(19, sizeof(uint32_t))
 
314
 
 
315
#endif /* VBOX_WITH_HGCM */
1609
316
 
1610
317
 
1611
318
#ifdef RT_OS_OS2
1674
381
 * This takes no input and it doesn't return anything. Obviously this
1675
382
 * is only recognized if it arrives thru the IDC service EP.
1676
383
 */
1677
 
#define VBOXGUEST_IOCTL_OS2_IDC_DISCONNECT  VBOXGUEST_IOCTL_CODE(48, sizeof(uint32_t))
 
384
# define VBOXGUEST_IOCTL_OS2_IDC_DISCONNECT     VBOXGUEST_IOCTL_CODE(48, sizeof(uint32_t))
1678
385
 
1679
386
#endif /* RT_OS_OS2 */
1680
387
 
1681
388
/** @} */
1682
389
#endif /* !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT) */
1683
390
 
1684
 
 
1685
 
#ifdef IN_RING3
1686
 
 
1687
 
/** @def VBGLR3DECL
1688
 
 * Ring 3 VBGL declaration.
1689
 
 * @param   type    The return type of the function declaration.
1690
 
 */
1691
 
#define VBGLR3DECL(type) type VBOXCALL
1692
 
 
1693
 
/* General-purpose functions */
1694
 
 
1695
 
RT_C_DECLS_BEGIN
1696
 
VBGLR3DECL(int)     VbglR3Init(void);
1697
 
VBGLR3DECL(int)     VbglR3InitUser(void);
1698
 
VBGLR3DECL(void)    VbglR3Term(void);
1699
 
# ifdef ___iprt_time_h
1700
 
VBGLR3DECL(int)     VbglR3GetHostTime(PRTTIMESPEC pTime);
1701
 
# endif
1702
 
VBGLR3DECL(int)     VbglR3InterruptEventWaits(void);
1703
 
VBGLR3DECL(int)     VbglR3WriteLog(const char *pch, size_t cb);
1704
 
VBGLR3DECL(int)     VbglR3CtlFilterMask(uint32_t fOr, uint32_t fNot);
1705
 
VBGLR3DECL(int)     VbglR3Daemonize(bool fNoChDir, bool fNoClose);
1706
 
VBGLR3DECL(int)     VbglR3PidFile(const char *pszPath, PRTFILE phFile);
1707
 
VBGLR3DECL(void)    VbglR3ClosePidFile(const char *pszPath, RTFILE hFile);
1708
 
VBGLR3DECL(int)     VbglR3SetGuestCaps(uint32_t fOr, uint32_t fNot);
1709
 
 
1710
 
/** @name Shared clipboard
1711
 
 * @{ */
1712
 
VBGLR3DECL(int)     VbglR3ClipboardConnect(uint32_t *pu32ClientId);
1713
 
VBGLR3DECL(int)     VbglR3ClipboardDisconnect(uint32_t u32ClientId);
1714
 
VBGLR3DECL(int)     VbglR3ClipboardGetHostMsg(uint32_t u32ClientId, uint32_t *pMsg, uint32_t *pfFormats);
1715
 
VBGLR3DECL(int)     VbglR3ClipboardReadData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb);
1716
 
VBGLR3DECL(int)     VbglR3ClipboardReportFormats(uint32_t u32ClientId, uint32_t fFormats);
1717
 
VBGLR3DECL(int)     VbglR3ClipboardWriteData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb);
1718
 
/** @} */
1719
 
 
1720
 
/** @name Seamless mode
1721
 
 * @{ */
1722
 
VBGLR3DECL(int)     VbglR3SeamlessSetCap(bool fState);
1723
 
VBGLR3DECL(int)     VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode);
1724
 
VBGLR3DECL(int)     VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects);
1725
 
/** @}  */
1726
 
 
1727
 
/** @name Mouse
1728
 
 * @{ */
1729
 
VBGLR3DECL(int)     VbglR3GetMouseStatus(uint32_t *pfFeatures, uint32_t *px, uint32_t *py);
1730
 
VBGLR3DECL(int)     VbglR3SetMouseStatus(uint32_t fFeatures);
1731
 
/** @}  */
1732
 
 
1733
 
/** @name Video
1734
 
 * @{ */
1735
 
VBGLR3DECL(int)     VbglR3VideoAccelEnable(bool fEnable);
1736
 
VBGLR3DECL(int)     VbglR3VideoAccelFlush(void);
1737
 
VBGLR3DECL(int)     VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg);
1738
 
VBGLR3DECL(int)     VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq);
1739
 
/** @}  */
1740
 
 
1741
 
/** @name Display
1742
 
 * @{ */
1743
 
VBGLR3DECL(int)     VbglR3GetLastDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay);
1744
 
VBGLR3DECL(int)     VbglR3DisplayChangeWaitEvent(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay);
1745
 
VBGLR3DECL(bool)    VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits);
1746
 
VBGLR3DECL(int)     VbglR3SaveVideoMode(const char *pszName, uint32_t cx, uint32_t cy, uint32_t cBits);
1747
 
VBGLR3DECL(int)     VbglR3RetrieveVideoMode(const char *pszName, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits);
1748
 
/** @}  */
1749
 
 
1750
 
#ifdef VBOX_WITH_GUEST_PROPS
1751
 
/** @name Guest properties
1752
 
 * @{ */
1753
 
typedef struct VBGLR3GUESTPROPENUM VBGLR3GUESTPROPENUM, *PVBGLR3GUESTPROPENUM;
1754
 
VBGLR3DECL(int)     VbglR3GuestPropConnect(uint32_t *pu32ClientId);
1755
 
VBGLR3DECL(int)     VbglR3GuestPropDisconnect(uint32_t u32ClientId);
1756
 
VBGLR3DECL(int)     VbglR3GuestPropWrite(uint32_t u32ClientId, const char *pszName, const char *pszValue, const char *pszFlags);
1757
 
VBGLR3DECL(int)     VbglR3GuestPropWriteValue(uint32_t u32ClientId, const char *pszName, const char *pszValue);
1758
 
VBGLR3DECL(int)     VbglR3GuestPropWriteValueV(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, va_list va);
1759
 
VBGLR3DECL(int)     VbglR3GuestPropWriteValueF(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, ...);
1760
 
VBGLR3DECL(int)     VbglR3GuestPropRead(uint32_t u32ClientId, const char *pszName, void *pvBuf, uint32_t cbBuf, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
1761
 
VBGLR3DECL(int)     VbglR3GuestPropReadValue(uint32_t ClientId, const char *pszName, char *pszValue, uint32_t cchValue, uint32_t *pcchValueActual);
1762
 
VBGLR3DECL(int)     VbglR3GuestPropReadValueAlloc(uint32_t u32ClientId, const char *pszName, char **ppszValue);
1763
 
VBGLR3DECL(void)    VbglR3GuestPropReadValueFree(char *pszValue);
1764
 
VBGLR3DECL(int)     VbglR3GuestPropEnumRaw(uint32_t u32ClientId, const char *paszPatterns, char *pcBuf, uint32_t cbBuf, uint32_t *pcbBufActual);
1765
 
VBGLR3DECL(int)     VbglR3GuestPropEnum(uint32_t u32ClientId, char const * const *ppaszPatterns, uint32_t cPatterns, PVBGLR3GUESTPROPENUM *ppHandle,
1766
 
                                        char const **ppszName, char const **ppszValue, uint64_t *pu64Timestamp, char const **ppszFlags);
1767
 
VBGLR3DECL(int)     VbglR3GuestPropEnumNext(PVBGLR3GUESTPROPENUM pHandle, char const **ppszName, char const **ppszValue, uint64_t *pu64Timestamp,
1768
 
                                            char const **ppszFlags);
1769
 
VBGLR3DECL(void)    VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle);
1770
 
VBGLR3DECL(int)     VbglR3GuestPropDelSet(uint32_t u32ClientId, char const * const *papszPatterns, uint32_t cPatterns);
1771
 
VBGLR3DECL(int)     VbglR3GuestPropWait(uint32_t u32ClientId, const char *pszPatterns, void *pvBuf, uint32_t cbBuf, uint64_t u64Timestamp, uint32_t u32Timeout, char ** ppszName, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
1772
 
/** @}  */
1773
 
#endif /* VBOX_WITH_GUEST_PROPS defined */
1774
 
 
1775
 
 
1776
 
RT_C_DECLS_END
1777
 
 
1778
 
#endif /* IN_RING3 */
1779
 
 
1780
391
#endif
 
392