VirtualBox

source: vbox/trunk/include/VBox/VBoxGuest.h@ 9552

Last change on this file since 9552 was 9435, checked in by vboxsync, 17 years ago

Extend HGCM interface to support 64 bit pointers.

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

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