2 * VBoxGuest - VirtualBox Guest Additions Driver Interface. (ADD,DEV)
4 * @note This file is used by 16-bit compilers too (OpenWatcom).
8 * Copyright (C) 2006-2017 Oracle Corporation
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
28 #ifndef ___VBox_VBoxGuest_h
29 #define ___VBox_VBoxGuest_h
31 #include <VBox/types.h>
32 #include <iprt/assertcompile.h>
33 #include <VBox/VMMDevCoreTypes.h>
34 #include <VBox/VBoxGuestCoreTypes.h>
38 /** @defgroup grp_vboxguest VirtualBox Guest Additions Device Driver
40 * Also know as VBoxGuest.
45 /** @defgroup grp_vboxguest_ioc VirtualBox Guest Additions Driver Interface
47 * @note This is considered internal in ring-3, please use the VbglR3 functions.
49 * - I/O controls for user and/or kernel mode starts at 0.
50 * - IDC specific requests descends from 127.
51 * - Bits 7 and 6 are currently reserved for future hacks.
53 * @remarks When creating new IOCtl interfaces keep in mind that not all OSes supports
54 * reporting back the output size. (This got messed up a little bit in VBoxDrv.)
56 * The request size is also a little bit tricky as it's passed as part of the
57 * request code on unix. The size field is 14 bits on Linux, 12 bits on *BSD,
58 * 13 bits Darwin, and 8-bits on Solaris. All the BSDs and Darwin kernels
59 * will make use of the size field, while Linux and Solaris will not. We're of
60 * course using the size to validate and/or map/lock the request, so it has
63 * For Solaris we will have to do something special though, 255 isn't
64 * sufficient for all we need. A 4KB restriction (BSD) is probably not
65 * too problematic (yet) as a general one.
67 * More info can be found in SUPDRVIOC.h and related sources.
69 * @remarks If adding interfaces that only has input or only has output, some new macros
70 * needs to be created so the most efficient IOCtl data buffering method can be
75 #if !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT)
77 /** Fictive start address of the hypervisor physical memory for MmMapIoSpace. */
78 #define VBOXGUEST_HYPERVISOR_PHYSICAL_START UINT32_C(0xf8000000)
81 /** Cookie used to fend off some unwanted clients to the IOService. */
82 # define VBOXGUEST_DARWIN_IOSERVICE_COOKIE UINT32_C(0x56426f78) /* 'VBox' */
86 #if defined(RT_OS_WINDOWS)
88 # include <iprt/win/windows.h>
90 /* Automatic buffering, size not encoded. */
91 # define VBGL_IOCTL_CODE_SIZE(Function, Size) CTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS)
92 # define VBGL_IOCTL_CODE_BIG(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS)
93 # define VBGL_IOCTL_CODE_FAST(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_NEITHER, FILE_WRITE_ACCESS)
94 # define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) (a_uIOCtl)
95 # define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
96 /** The support service name. */
97 # define VBOXGUEST_SERVICE_NAME "VBoxGuest"
98 /** Global name for Win2k+ */
99 # define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
100 /** Win32 driver name */
101 # define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
103 # define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
105 #elif defined(RT_OS_OS2)
106 /* No automatic buffering, size not encoded. */
107 # define VBGL_IOCTL_CATEGORY 0xc2
108 # define VBGL_IOCTL_CODE_SIZE(Function, Size) ((unsigned char)(Function))
109 # define VBGL_IOCTL_CODE_BIG(Function) ((unsigned char)(Function))
110 # define VBGL_IOCTL_CATEGORY_FAST 0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
111 # define VBGL_IOCTL_CODE_FAST(Function) ((unsigned char)(Function))
112 # define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) (a_uIOCtl)
113 # define VBOXGUEST_DEVICE_NAME "\\Dev\\VBoxGst$"
114 /** Short device name for AttachDD.
115 * @note Case sensitive. Must match what VBoxGuestA-os2.asm says! */
116 # define VBOXGUEST_DEVICE_NAME_SHORT "vboxgst$"
118 #elif defined(RT_OS_SOLARIS)
119 /* No automatic buffering, size limited to 255 bytes => use VBGLBIGREQ for everything. */
120 # include <sys/ioccom.h>
121 # define VBGL_IOCTL_CODE_SIZE(Function, Size) _IOWRN('V', (Function), sizeof(VBGLREQHDR))
122 # define VBGL_IOCTL_CODE_BIG(Function) _IOWRN('V', (Function), sizeof(VBGLREQHDR))
123 # define VBGL_IOCTL_CODE_FAST(Function) _IO( 'F', (Function))
124 # define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) (a_uIOCtl)
125 # define VBGL_IOCTL_IS_FAST(a_uIOCtl) ( ((a_uIOCtl) & 0x0000ff00) == ('F' << 8) )
127 #elif defined(RT_OS_LINUX)
128 /* No automatic buffering, size limited to 16KB. */
129 # include <linux/ioctl.h>
130 # define VBGL_IOCTL_CODE_SIZE(Function, Size) _IOC(_IOC_READ | _IOC_WRITE, 'V', (Function), (Size))
131 # define VBGL_IOCTL_CODE_BIG(Function) _IO('V', (Function))
132 # define VBGL_IOCTL_CODE_FAST(Function) _IO('F', (Function))
133 # define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) _IOC_NR((a_uIOCtl))
134 # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxuser"
136 #elif defined(RT_OS_HAIKU)
137 /* No automatic buffering, size not encoded. */
138 /** @todo do something better */
139 # define VBGL_IOCTL_CODE_SIZE(Function, Size) (0x56420000 | (Function))
140 # define VBGL_IOCTL_CODE_BIG(Function) (0x56420000 | (Function))
141 # define VBGL_IOCTL_CODE_FAST(Function) (0x56420000 | (Function))
142 # define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) (a_uIOCtl)
143 # define VBOXGUEST_DEVICE_NAME "/dev/misc/vboxguest"
146 /* Automatic buffering, size limited to 4KB on *BSD and 8KB on Darwin - commands the limit, 4KB. */
147 # include <sys/ioccom.h>
148 # define VBGL_IOCTL_CODE_SIZE(Function, Size) _IOC(IOC_INOUT, 'V', (Function), (Size))
149 # define VBGL_IOCTL_CODE_BIG(Function) _IO('V', (Function))
150 # define VBGL_IOCTL_CODE_FAST(Function) _IO('F', (Function))
151 # define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) ((a_uIOCtl) & ~(_IOC(0,0,0,IOCPARM_MASK)))
152 # define VBGL_IOCTL_IS_FAST(a_uIOCtl) ( IOCGROUP(a_uIOCtl) == 'F' )
156 /** @todo It would be nice if we could have two defines without paths. */
158 /** @def VBOXGUEST_DEVICE_NAME
159 * The support device name. */
160 #ifndef VBOXGUEST_DEVICE_NAME /* PORTME */
161 # define VBOXGUEST_DEVICE_NAME "/dev/vboxguest"
164 /** @def VBOXGUEST_USER_DEVICE_NAME
165 * The support device name of the user accessible device node. */
166 #ifndef VBOXGUEST_USER_DEVICE_NAME
167 # define VBOXGUEST_USER_DEVICE_NAME VBOXGUEST_DEVICE_NAME
172 * The VBoxGuest I/O control version.
174 * As usual, the high word contains the major version and changes to it
175 * signifies incompatible changes.
177 * The lower word is the minor version number, it is increased when new
178 * functions are added or existing changed in a backwards compatible manner.
180 #define VBGL_IOC_VERSION UINT32_C(0x00010000)
184 /** @name VBGL_IOCTL_DRIVER_INFO
185 * Adjust and get driver information.
187 * @note May switch the session to a backwards compatible interface version if
188 * uClientVersion indicates older client code.
192 #define VBGL_IOCTL_DRIVER_VERSION_INFO VBGL_IOCTL_CODE_SIZE(0, VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE)
193 #define VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE sizeof(VBGLIOCDRIVERVERSIONINFO)
194 #define VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE_IN RT_UOFFSET_AFTER(VBGLIOCDRIVERVERSIONINFO, u.In)
195 #define VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE_OUT sizeof(VBGLIOCDRIVERVERSIONINFO)
196 typedef struct VBGLIOCDRIVERVERSIONINFO
204 /** The requested interface version number (VBGL_IOC_VERSION). */
205 uint32_t uReqVersion
;
206 /** The minimum interface version number
207 * (typically the major version part of VBGL_IOC_VERSION). */
208 uint32_t uMinVersion
;
209 /** Reserved, MBZ. */
211 /** Reserved, MBZ. */
216 /** Interface version for this session (typically VBGL_IOC_VERSION). */
217 uint32_t uSessionVersion
;
218 /** The version of the IDC interface (VBGL_IOC_VERSION). */
219 uint32_t uDriverVersion
;
220 /** The SVN revision of the driver.
221 * This will be set to 0 if not compiled into the driver. */
222 uint32_t uDriverRevision
;
223 /** Reserved \#1 (will be returned as zero until defined). */
225 /** Reserved \#2 (will be returned as zero until defined). */
229 } VBGLIOCDRIVERVERSIONINFO
, RT_FAR
*PVBGLIOCDRIVERVERSIONINFO
;
230 AssertCompileSize(VBGLIOCDRIVERVERSIONINFO
, 24 + 20);
231 #if !defined(__GNUC__) /* Some GCC versions can't handle the complicated RT_UOFFSET_AFTER macro, it seems. */ \
232 && (!defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__) && (!defined(__WATCOMC__) || !defined(__cplusplus))))
233 AssertCompile(VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE_IN
== 24 + 16);
238 /** @name VBGL_IOCTL_GET_PORT_INFO
239 * Query VMMDev I/O port region and MMIO mapping address.
240 * @remarks Ring-0 only.
243 #define VBGL_IOCTL_GET_VMMDEV_IO_INFO VBGL_IOCTL_CODE_SIZE(1, VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE)
244 #define VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE sizeof(VBGLIOCGETVMMDEVIOINFO)
245 #define VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE_IN sizeof(VBGLREQHDR)
246 #define VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE_OUT sizeof(VBGLIOCGETVMMDEVIOINFO)
247 typedef struct VBGLIOCGETVMMDEVIOINFO
255 /** The MMIO mapping. NULL if no MMIO region. */
256 struct VMMDevMemory
volatile RT_FAR
*pvVmmDevMapping
;
257 /** The I/O port address. */
259 /** Padding, ignore. */
260 RTIOPORT auPadding
[HC_ARCH_BITS
== 64 ? 3 : 1];
263 } VBGLIOCGETVMMDEVIOINFO
, RT_FAR
*PVBGLIOCGETVMMDEVIOINFO
;
264 AssertCompileSize(VBGLIOCGETVMMDEVIOINFO
, 24 + (HC_ARCH_BITS
== 64 ? 16 : 8));
268 /** @name VBGL_IOCTL_VMMDEV_REQUEST
269 * IOCTL to VBoxGuest to perform a VMM Device request less than 1KB in size.
272 #define VBGL_IOCTL_VMMDEV_REQUEST(a_cb) VBGL_IOCTL_CODE_SIZE(2, (a_cb))
276 /** @name VBGL_IOCTL_VMMDEV_REQUEST_BIG
277 * IOCTL to VBoxGuest to perform a VMM Device request that can 1KB or larger.
280 #define VBGL_IOCTL_VMMDEV_REQUEST_BIG VBGL_IOCTL_CODE_BIG(3)
284 #ifdef VBOX_WITH_HGCM
285 /** @name VBGL_IOCTL_HGCM_CONNECT
286 * Connect to a HGCM service.
288 # define VBGL_IOCTL_HGCM_CONNECT VBGL_IOCTL_CODE_SIZE(4, VBGL_IOCTL_HGCM_CONNECT_SIZE)
289 # define VBGL_IOCTL_HGCM_CONNECT_SIZE sizeof(VBGLIOCHGCMCONNECT)
290 # define VBGL_IOCTL_HGCM_CONNECT_SIZE_IN sizeof(VBGLIOCHGCMCONNECT)
291 # define VBGL_IOCTL_HGCM_CONNECT_SIZE_OUT RT_UOFFSET_AFTER(VBGLIOCHGCMCONNECT, u.Out)
292 typedef struct VBGLIOCHGCMCONNECT
300 HGCMServiceLocation Loc
;
307 } VBGLIOCHGCMCONNECT
, RT_FAR
*PVBGLIOCHGCMCONNECT
;
308 AssertCompileSize(VBGLIOCHGCMCONNECT
, 24 + 132);
309 #if !defined(__GNUC__) /* Some GCC versions can't handle the complicated RT_UOFFSET_AFTER macro, it seems. */ \
310 && (!defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__) && (!defined(__WATCOMC__) || !defined(__cplusplus))))
311 AssertCompile(VBGL_IOCTL_HGCM_CONNECT_SIZE_OUT
== 24 + 4);
316 /** @name VBGL_IOCTL_HGCM_DISCONNECT
317 * Disconnect from a HGCM service.
319 # define VBGL_IOCTL_HGCM_DISCONNECT VBGL_IOCTL_CODE_SIZE(5, VBGL_IOCTL_HGCM_DISCONNECT_SIZE)
320 # define VBGL_IOCTL_HGCM_DISCONNECT_SIZE sizeof(VBGLIOCHGCMDISCONNECT)
321 # define VBGL_IOCTL_HGCM_DISCONNECT_SIZE_IN sizeof(VBGLIOCHGCMDISCONNECT)
322 # define VBGL_IOCTL_HGCM_DISCONNECT_SIZE_OUT sizeof(VBGLREQHDR)
323 /** @note This is also used by a VbglR0 API. */
324 typedef struct VBGLIOCHGCMDISCONNECT
335 } VBGLIOCHGCMDISCONNECT
, RT_FAR
*PVBGLIOCHGCMDISCONNECT
;
336 AssertCompileSize(VBGLIOCHGCMDISCONNECT
, 24 + 4);
340 /** @name VBGL_IOCTL_HGCM_CALL, VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA
342 * Make a call to a HGCM servicesure. There are several variations here.
344 * The VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA variation is for other drivers (like
345 * the graphics ones) passing on requests from user land that contains user
346 * data. These calls are always interruptible.
349 # define VBGL_IOCTL_HGCM_CALL_32(a_cb) VBGL_IOCTL_CODE_SIZE(6, (a_cb))
350 # define VBGL_IOCTL_HGCM_CALL_64(a_cb) VBGL_IOCTL_CODE_SIZE(7, (a_cb))
352 # define VBGL_IOCTL_HGCM_CALL(a_cb) VBGL_IOCTL_HGCM_CALL_64(a_cb)
354 # define VBGL_IOCTL_HGCM_CALL(a_cb) VBGL_IOCTL_HGCM_CALL_32(a_cb)
356 # define VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA(a_cb) VBGL_IOCTL_CODE_SIZE(8, (a_cb))
358 #endif /* VBOX_WITH_HGCM */
361 /** @name VBGL_IOCTL_LOG
362 * IOCTL to VBoxGuest to perform backdoor logging.
364 #define VBOXGUEST_IOCTL_LOG(Size)
365 #define VBGL_IOCTL_LOG(a_cchMsg) VBGL_IOCTL_CODE_BIG(9)
366 #define VBGL_IOCTL_LOG_SIZE(a_cchMsg) (sizeof(VBGLREQHDR) + (a_cchMsg) + 1)
367 #define VBGL_IOCTL_LOG_SIZE_IN(a_cchMsg) (sizeof(VBGLREQHDR) + (a_cchMsg) + 1)
368 #define VBGL_IOCTL_LOG_SIZE_OUT sizeof(VBGLREQHDR)
369 typedef struct VBGLIOCLOG
378 * The length is determined from the input size and zero termination. */
379 char szMsg
[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
];
382 } VBGLIOCLOG
, RT_FAR
*PVBGLIOCLOG
;
386 /** @name VBGL_IOCTL_WAIT_FOR_EVENTS
387 * Wait for a VMMDev host event notification.
390 #define VBGL_IOCTL_WAIT_FOR_EVENTS VBGL_IOCTL_CODE_SIZE(10, VBGL_IOCTL_WAIT_FOR_EVENTS_SIZE)
391 #define VBGL_IOCTL_WAIT_FOR_EVENTS_SIZE sizeof(VBGLIOCWAITFOREVENTS)
392 #define VBGL_IOCTL_WAIT_FOR_EVENTS_SIZE_IN sizeof(VBGLIOCWAITFOREVENTS)
393 #define VBGL_IOCTL_WAIT_FOR_EVENTS_SIZE_OUT RT_UOFFSET_AFTER(VBGLIOCWAITFOREVENTS, u.Out)
394 typedef struct VBGLIOCWAITFOREVENTS
402 /** Timeout in milliseconds. */
404 /** Events to wait for. */
409 /** Events that occurred. */
413 } VBGLIOCWAITFOREVENTS
, RT_FAR
*PVBGLIOCWAITFOREVENTS
;
414 AssertCompileSize(VBGLIOCWAITFOREVENTS
, 24 + 8);
418 /** @name VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS
419 * IOCTL to VBoxGuest to interrupt (cancel) any pending
420 * VBGL_IOCTL_WAIT_FOR_EVENTS and return.
422 * Handled inside the guest additions and not seen by the host at all.
423 * After calling this, VBGL_IOCTL_WAIT_FOR_EVENTS should no longer be called in
424 * the same session. At the time of writing this is not enforced; at the time
425 * of reading it may be.
426 * @see VBGL_IOCTL_WAIT_FOR_EVENTS
430 #define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS VBGL_IOCTL_CODE_SIZE(11, VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE)
431 #define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE sizeof(VBGLREQHDR)
432 #define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE_IN sizeof(VBGLREQHDR)
433 #define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE_OUT sizeof(VBGLREQHDR)
437 /** @name VBGL_IOCTL_CHANGE_FILTER_MASK
438 * IOCTL to VBoxGuest to control the event filter mask.
440 #define VBGL_IOCTL_CHANGE_FILTER_MASK VBGL_IOCTL_CODE_SIZE(12, VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE)
441 #define VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE sizeof(VBGLIOCCHANGEFILTERMASK)
442 #define VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE_IN sizeof(VBGLIOCCHANGEFILTERMASK)
443 #define VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE_OUT sizeof(VBGLREQHDR)
444 typedef struct VBGLIOCCHANGEFILTERMASK
454 /** Flags to remove. */
458 } VBGLIOCCHANGEFILTERMASK
, RT_FAR
*PVBGLIOCCHANGEFILTERMASK
;
459 AssertCompileSize(VBGLIOCCHANGEFILTERMASK
, 24 + 8);
463 /** @name VBGL_IOCTL_GUEST_CAPS_ACQUIRE
464 * IOCTL to for acquiring and releasing guest capabilities.
466 * This is used for multiple purposes:
467 * 1. By doing @a acquire r3 client application (e.g. VBoxTray) claims it will
468 * use the given session for performing operations like @a seamless or
469 * @a auto-resize, thus, if the application terminates, the driver will
470 * automatically cleanup the caps reported to host, so that host knows guest
471 * does not support them anymore
472 * 2. In a multy-user environment this will not allow r3 applications (like
473 * VBoxTray) running in different user sessions simultaneously to interfere
474 * with each other. An r3 client application (like VBoxTray) is responsible
475 * for Acquiring/Releasing caps properly as needed.
478 * VERR_RESOURCE_BUSY is returned if any capabilities in the fOrMask are
479 * currently acquired by some other VBoxGuest session.
483 #define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES VBGL_IOCTL_CODE_SIZE(13, VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE)
484 #define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE sizeof(VBGLIOCACQUIREGUESTCAPS)
485 #define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE_IN sizeof(VBGLIOCACQUIREGUESTCAPS)
486 #define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE_OUT sizeof(VBGLREQHDR)
488 /** Default operation (full acquire/release). */
489 #define VBGL_IOC_AGC_FLAGS_DEFAULT UINT32_C(0x00000000)
490 /** Configures VBoxGuest to use the specified caps in Acquire mode, w/o making
491 * any caps acquisition/release. This is only possible to set acquire mode for
492 * caps, but not clear it, so fNotMask is ignored when this flag is set. */
493 #define VBGL_IOC_AGC_FLAGS_CONFIG_ACQUIRE_MODE UINT32_C(0x00000001)
494 /** Valid flag mask. */
495 #define VBGL_IOC_AGC_FLAGS_VALID_MASK UINT32_C(0x00000001)
497 typedef struct VBGLIOCACQUIREGUESTCAPS
505 /** Acquire flags (VBGL_IOC_AGC_FLAGS_XXX). */
507 /** Guest capabilities to acquire (VMMDEV_GUEST_SUPPORTS_XXX). */
509 /** Guest capabilities to release (VMMDEV_GUEST_SUPPORTS_XXX). */
513 } VBGLIOCACQUIREGUESTCAPS
, RT_FAR
*PVBGLIOCACQUIREGUESTCAPS
;
514 AssertCompileSize(VBGLIOCACQUIREGUESTCAPS
, 24 + 12);
518 /** @name VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES
519 * IOCTL to VBoxGuest to set guest capabilities.
521 #define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES VBGL_IOCTL_CODE_SIZE(14, VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE)
522 #define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE sizeof(VBGLIOCSETGUESTCAPS)
523 #define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE_IN sizeof(VBGLIOCSETGUESTCAPS)
524 #define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE_OUT sizeof(VBGLIOCSETGUESTCAPS)
525 typedef struct VBGLIOCSETGUESTCAPS
533 /** The capabilities to set (VMMDEV_GUEST_SUPPORTS_XXX). */
535 /** The capabilities to drop (VMMDEV_GUEST_SUPPORTS_XXX). */
540 /** The capabilities held by the session after the call (VMMDEV_GUEST_SUPPORTS_XXX). */
541 uint32_t fSessionCaps
;
542 /** The capabilities for all the sessions after the call (VMMDEV_GUEST_SUPPORTS_XXX). */
543 uint32_t fGlobalCaps
;
546 } VBGLIOCSETGUESTCAPS
, RT_FAR
*PVBGLIOCSETGUESTCAPS
;
547 AssertCompileSize(VBGLIOCSETGUESTCAPS
, 24 + 8);
548 typedef VBGLIOCSETGUESTCAPS VBoxGuestSetCapabilitiesInfo
;
552 /** @name VBGL_IOCTL_SET_MOUSE_STATUS
553 * IOCTL to VBoxGuest to update the mouse status features.
555 #define VBGL_IOCTL_SET_MOUSE_STATUS VBGL_IOCTL_CODE_SIZE(15, VBGL_IOCTL_SET_MOUSE_STATUS_SIZE)
556 #define VBGL_IOCTL_SET_MOUSE_STATUS_SIZE sizeof(VBGLIOCSETMOUSESTATUS)
557 #define VBGL_IOCTL_SET_MOUSE_STATUS_SIZE_IN sizeof(VBGLIOCSETMOUSESTATUS)
558 #define VBGL_IOCTL_SET_MOUSE_STATUS_SIZE_OUT sizeof(VBGLREQHDR)
559 typedef struct VBGLIOCSETMOUSESTATUS
567 /** Mouse status flags (VMMDEV_MOUSE_XXX). */
571 } VBGLIOCSETMOUSESTATUS
, RT_FAR
*PVBGLIOCSETMOUSESTATUS
;
575 /** @name VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK
577 * IOCTL to for setting the mouse driver callback.
578 * @note The callback will be called in interrupt context with the VBoxGuest
579 * device event spinlock held.
583 #define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK VBGL_IOCTL_CODE_SIZE(16, VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE)
584 #define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE sizeof(VBGLIOCSETMOUSENOTIFYCALLBACK)
585 #define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE_IN sizeof(VBGLIOCSETMOUSENOTIFYCALLBACK)
586 #define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE_OUT sizeof(VBGLREQHDR)
587 typedef struct VBGLIOCSETMOUSENOTIFYCALLBACK
595 /** Mouse notification callback function. */
596 PFNVBOXGUESTMOUSENOTIFY pfnNotify
;
597 /** The callback argument. */
601 } VBGLIOCSETMOUSENOTIFYCALLBACK
, RT_FAR
*PVBGLIOCSETMOUSENOTIFYCALLBACK
;
605 /** @name VBGL_IOCTL_CHECK_BALLOON
606 * IOCTL to VBoxGuest to check memory ballooning.
608 * The guest kernel module / device driver will ask the host for the current size of
609 * the balloon and adjust the size. Or it will set fHandledInR0 = false and R3 is
610 * responsible for allocating memory and calling R0 (VBGL_IOCTL_CHANGE_BALLOON).
612 #define VBGL_IOCTL_CHECK_BALLOON VBGL_IOCTL_CODE_SIZE(17, VBGL_IOCTL_CHECK_BALLOON_SIZE)
613 #define VBGL_IOCTL_CHECK_BALLOON_SIZE sizeof(VBGLIOCCHECKBALLOON)
614 #define VBGL_IOCTL_CHECK_BALLOON_SIZE_IN sizeof(VBGLREQHDR)
615 #define VBGL_IOCTL_CHECK_BALLOON_SIZE_OUT sizeof(VBGLIOCCHECKBALLOON)
616 typedef struct VBGLIOCCHECKBALLOON
624 /** The size of the balloon in chunks of 1MB. */
625 uint32_t cBalloonChunks
;
626 /** false = handled in R0, no further action required.
627 * true = allocate balloon memory in R3. */
629 /** Explicit padding, please ignore. */
633 } VBGLIOCCHECKBALLOON
, RT_FAR
*PVBGLIOCCHECKBALLOON
;
634 AssertCompileSize(VBGLIOCCHECKBALLOON
, 24 + 8);
635 typedef VBGLIOCCHECKBALLOON VBoxGuestCheckBalloonInfo
;
639 /** @name VBGL_IOCTL_CHANGE_BALLOON
640 * IOCTL to VBoxGuest to supply or revoke one chunk for ballooning.
642 * The guest kernel module / device driver will lock down supplied memory or
643 * unlock reclaimed memory and then forward the physical addresses of the
644 * changed balloon chunk to the host.
647 #define VBGL_IOCTL_CHANGE_BALLOON VBGL_IOCTL_CODE_SIZE(18, VBGL_IOCTL_CHANGE_BALLOON_SIZE)
648 #define VBGL_IOCTL_CHANGE_BALLOON_SIZE sizeof(VBGLIOCCHANGEBALLOON)
649 #define VBGL_IOCTL_CHANGE_BALLOON_SIZE_IN sizeof(VBGLIOCCHANGEBALLOON)
650 #define VBGL_IOCTL_CHANGE_BALLOON_SIZE_OUT sizeof(VBGLREQHDR)
651 typedef struct VBGLIOCCHANGEBALLOON
659 /** Address of the chunk (user space address). */
661 /** Explicit alignment padding, MBZ. */
662 uint8_t abPadding
[ARCH_BITS
== 64 ? 0 + 7 : 4 + 7];
663 /** true = inflate, false = deflate. */
667 } VBGLIOCCHANGEBALLOON
, RT_FAR
*PVBGLIOCCHANGEBALLOON
;
668 AssertCompileSize(VBGLIOCCHANGEBALLOON
, 24+16);
672 /** @name VBGL_IOCTL_WRITE_CORE_DUMP
673 * IOCTL to VBoxGuest to write guest core.
675 #define VBGL_IOCTL_WRITE_CORE_DUMP VBGL_IOCTL_CODE_SIZE(19, VBGL_IOCTL_WRITE_CORE_DUMP_SIZE)
676 #define VBGL_IOCTL_WRITE_CORE_DUMP_SIZE sizeof(VBGLIOCWRITECOREDUMP)
677 #define VBGL_IOCTL_WRITE_CORE_DUMP_SIZE_IN sizeof(VBGLIOCWRITECOREDUMP)
678 #define VBGL_IOCTL_WRITE_CORE_DUMP_SIZE_OUT sizeof(VBGLREQHDR)
679 typedef struct VBGLIOCWRITECOREDUMP
687 /** Flags (reserved, MBZ). */
691 } VBGLIOCWRITECOREDUMP
, RT_FAR
*PVBGLIOCWRITECOREDUMP
;
692 AssertCompileSize(VBGLIOCWRITECOREDUMP
, 24 + 4);
693 typedef VBGLIOCWRITECOREDUMP VBoxGuestWriteCoreDump
;
697 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER
698 /** @name VBGL_IOCTL_DPC_LATENCY_CHECKER
699 * IOCTL to VBoxGuest to perform DPC latency tests, printing the result in
700 * the release log on the host. Takes no data, returns no data.
702 # define VBGL_IOCTL_DPC_LATENCY_CHECKER VBGL_IOCTL_CODE_SIZE(20, VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE)
703 # define VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE sizeof(VBGLREQHDR)
704 # define VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE_IN sizeof(VBGLREQHDR)
705 # define VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE_OUT sizeof(VBGLREQHDR)
712 * The data buffer layout for the IDC entry point (AttachDD).
714 * @remark This is defined in multiple 16-bit headers / sources.
715 * Some places it's called VBGOS2IDC to short things a bit.
717 typedef struct VBGLOS2ATTACHDD
719 /** VBGL_IOC_VERSION. */
721 /** Opaque session handle. */
725 * The 32-bit service entry point.
727 * @returns VBox status code.
728 * @param u32Session The session handle (PVBOXGUESTSESSION).
729 * @param iFunction The requested function.
730 * @param pReqHdr The input/output data buffer. The caller
731 * ensures that this cannot be swapped out, or that
732 * it's acceptable to take a page in fault in the
733 * current context. If the request doesn't take
734 * input or produces output, apssing NULL is okay.
735 * @param cbReq The size of the data buffer.
737 # if ARCH_BITS == 32 || defined(DOXYGEN_RUNNING)
738 DECLCALLBACKMEMBER(int, pfnServiceEP
)(uint32_t u32Session
, unsigned iFunction
, PVBGLREQHDR pReqHdr
, size_t cbReq
);
740 uint32_t pfnServiceEP
;
743 /** The 16-bit service entry point for C code (cdecl).
745 * It's the same as the 32-bit entry point, but the types has
746 * changed to 16-bit equivalents.
750 * VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction,
751 * PVBGLREQHDR fpvData, uint16_t cbData);
754 # if ARCH_BITS == 16 || defined(DOXYGEN_RUNNING)
755 DECLCALLBACKMEMBER(int, fpfnServiceEP
)(uint32_t u32Session
, uint16_t iFunction
, PVBGLREQHDR fpvData
, uint16_t cbData
);
757 RTFAR16 fpfnServiceEP
;
760 /** The 16-bit service entry point for Assembly code (register).
762 * This is just a wrapper around fpfnServiceEP to simplify calls
763 * from 16-bit assembly code.
765 * @returns (e)ax: VBox status code; cx: The amount of data returned.
767 * @param u32Session eax - The above session handle.
768 * @param iFunction dl - The requested function.
769 * @param pvData es:bx - The input/output data buffer.
770 * @param cbData cx - The size of the data buffer.
772 RTFAR16 fpfnServiceAsmEP
;
774 /** Pointer to VBOXGUESTOS2IDCCONNECT buffer. */
775 typedef VBGLOS2ATTACHDD RT_FAR
*PVBGLOS2ATTACHDD
;
778 * Prototype for the 16-bit callback returned by AttachDD on OS/2.
779 * @param pAttachInfo Pointer to structure to fill in.
781 # if defined(__IBMC__) || defined(__IBMCPP__)
782 typedef void (* __cdecl RT_FAR_CODE PFNVBGLOS2ATTACHDD
)(PVBGLOS2ATTACHDD pAttachInfo
);
784 typedef void (__cdecl RT_FAR_CODE
*PFNVBGLOS2ATTACHDD
)(PVBGLOS2ATTACHDD pAttachInfo
);
786 #endif /* RT_OS_OS2 */
789 /** @name VBGL_IOCL_IDC_CONNECT
790 * IDC client connect request.
792 * On platforms other than Windows and OS/2, this will also create a kernel
793 * session for the caller.
797 #define VBGL_IOCTL_IDC_CONNECT VBGL_IOCTL_CODE_SIZE(63, VBGL_IOCTL_IDC_CONNECT_SIZE)
798 #define VBGL_IOCTL_IDC_CONNECT_SIZE sizeof(VBGLIOCIDCCONNECT)
799 #define VBGL_IOCTL_IDC_CONNECT_SIZE_IN RT_UOFFSET_AFTER(VBGLIOCIDCCONNECT, u.In)
800 #define VBGL_IOCTL_IDC_CONNECT_SIZE_OUT sizeof(VBGLIOCIDCCONNECT)
801 typedef struct VBGLIOCIDCCONNECT
805 /** The payload union. */
810 /** VBGL_IOCTL_IDC_CONNECT_MAGIC_COOKIE. */
811 uint32_t u32MagicCookie
;
812 /** The desired version of the I/O control interface (VBGL_IOC_VERSION). */
813 uint32_t uReqVersion
;
814 /** The minimum version of the I/O control interface (VBGL_IOC_VERSION). */
815 uint32_t uMinVersion
;
816 /** Reserved, MBZ. */
821 /** The session handle (opaque). */
823 void RT_FAR
*pvSession
;
827 /** The version of the I/O control interface for this session
828 * (typically VBGL_IOC_VERSION). */
829 uint32_t uSessionVersion
;
830 /** The I/O control interface version for of the driver (VBGL_IOC_VERSION). */
831 uint32_t uDriverVersion
;
832 /** The SVN revision of the driver.
833 * This will be set to 0 if not compiled into the driver. */
834 uint32_t uDriverRevision
;
835 /** Reserved \#1 (will be returned as zero until defined). */
837 /** Reserved \#2 (will be returned as NULL until defined). */
838 void RT_FAR
*pvReserved2
;
841 } VBGLIOCIDCCONNECT
, RT_FAR
*PVBGLIOCIDCCONNECT
;
842 AssertCompileSize(VBGLIOCIDCCONNECT
, 24 + 16 + (ARCH_BITS
== 64 ? 8 : 4) * 2);
843 #if !defined(__GNUC__) /* Some GCC versions can't handle the complicated RT_UOFFSET_AFTER macro, it seems. */ \
844 && (!defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__) && (!defined(__WATCOMC__) || !defined(__cplusplus))))
845 AssertCompile(VBGL_IOCTL_IDC_CONNECT_SIZE_IN
== 24 + 16);
847 #define VBGL_IOCTL_IDC_CONNECT_MAGIC_COOKIE UINT32_C(0x55aa4d5a) /**< Magic value for doing an IDC connect. */
851 /** @name VBGL_IOCL_IDC_DISCONNECT
852 * IDC client disconnect request.
854 * This will destroy the kernel session associated with the IDC connection.
858 #define VBGL_IOCTL_IDC_DISCONNECT VBGL_IOCTL_CODE_SIZE(62, VBGL_IOCTL_IDC_DISCONNECT_SIZE)
859 #define VBGL_IOCTL_IDC_DISCONNECT_SIZE sizeof(VBGLIOCIDCDISCONNECT)
860 #define VBGL_IOCTL_IDC_DISCONNECT_SIZE_IN sizeof(VBGLIOCIDCDISCONNECT)
861 #define VBGL_IOCTL_IDC_DISCONNECT_SIZE_OUT sizeof(VBGLREQHDR)
862 typedef struct VBGLIOCIDCDISCONNECT
870 /** The session handle for platforms where this is needed. */
872 void RT_FAR
*pvSession
;
878 } VBGLIOCIDCDISCONNECT
, RT_FAR
*PVBGLIOCIDCDISCONNECT
;
879 AssertCompileSize(VBGLIOCIDCDISCONNECT
, 24 + (ARCH_BITS
== 64 ? 8 : 4));
883 #if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
886 * The VBoxGuest IDC entry point.
888 * @returns VBox status code.
889 * @param pvSession The session.
890 * @param uReq The request code.
891 * @param pReqHdr The request.
892 * @param cbReq The request size.
894 int VBOXCALL
VBoxGuestIDC(void RT_FAR
*pvSession
, uintptr_t uReq
, PVBGLREQHDR pReqHdr
, size_t cbReq
);
899 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
901 /* Private IOCtls between user space and the kernel video driver. DRM private
902 * IOCtls always have the type 'd' and a number between 0x40 and 0x99 (0x9F?) */
904 # define VBOX_DRM_IOCTL(a) (0x40 + DRM_VBOX_ ## a)
906 /** Stop using HGSMI in the kernel driver until it is re-enabled, so that a
907 * user-space driver can use it. It must be re-enabled before the kernel
908 * driver can be used again in a sensible way. */
909 /** @note These IOCtls was removed from the code, but are left here as
910 * templates as we may need similar ones in future. */
911 # define DRM_VBOX_DISABLE_HGSMI 0
912 # define DRM_IOCTL_VBOX_DISABLE_HGSMI VBOX_DRM_IOCTL(DISABLE_HGSMI)
913 # define VBOXVIDEO_IOCTL_DISABLE_HGSMI _IO('d', DRM_IOCTL_VBOX_DISABLE_HGSMI)
914 /** Enable HGSMI in the kernel driver after it was previously disabled. */
915 # define DRM_VBOX_ENABLE_HGSMI 1
916 # define DRM_IOCTL_VBOX_ENABLE_HGSMI VBOX_DRM_IOCTL(ENABLE_HGSMI)
917 # define VBOXVIDEO_IOCTL_ENABLE_HGSMI _IO('d', DRM_IOCTL_VBOX_ENABLE_HGSMI)
919 #endif /* RT_OS_LINUX || RT_OS_SOLARIS || RT_OS_FREEBSD */
921 #endif /* !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT) */