VirtualBox

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

Last change on this file since 68596 was 68596, checked in by vboxsync, 8 years ago

VBoxGuest.h: attachdd names are case sensitives, it seems

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.5 KB
Line 
1/** @file
2 * VBoxGuest - VirtualBox Guest Additions Driver Interface. (ADD,DEV)
3 *
4 * @note This file is used by 16-bit compilers too (OpenWatcom).
5 *
6 * @remarks This is in the process of being split up and usage cleaned up.
7 */
8
9/*
10 * Copyright (C) 2006-2016 Oracle Corporation
11 *
12 * This file is part of VirtualBox Open Source Edition (OSE), as
13 * available from http://www.virtualbox.org. This file is free software;
14 * you can redistribute it and/or modify it under the terms of the GNU
15 * General Public License (GPL) as published by the Free Software
16 * Foundation, in version 2 as it comes in the "COPYING" file of the
17 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19 *
20 * The contents of this file may alternatively be used under the terms
21 * of the Common Development and Distribution License Version 1.0
22 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
23 * VirtualBox OSE distribution, in which case the provisions of the
24 * CDDL are applicable instead of those of the GPL.
25 *
26 * You may elect to license modified versions of this file under the
27 * terms and conditions of either the GPL or the CDDL or both.
28 */
29
30#ifndef ___VBox_VBoxGuest_h
31#define ___VBox_VBoxGuest_h
32
33#include <VBox/types.h>
34#include <iprt/assert.h>
35#include <VBox/VMMDev2.h>
36
37
38
39/** @defgroup grp_vboxguest VirtualBox Guest Additions Device Driver
40 *
41 * Also know as VBoxGuest.
42 *
43 * @{
44 */
45
46/** @defgroup grp_vboxguest_ioc VirtualBox Guest Additions Driver Interface
47 *
48 * @note This is considered internal in ring-3, please use the VbglR3 functions.
49 *
50 * - The 7th bit (128) is reserved for distinguishing between 32-bit and 64-bit
51 * processes in future 64-bit guest additions, where it matters.
52 * - The 6th bit is reserved for future hacks.
53 * - IDC specific requests descends from 63.
54 *
55 * @remarks When creating new IOCtl interfaces keep in mind that not all OSes supports
56 * reporting back the output size. (This got messed up a little bit in VBoxDrv.)
57 *
58 * The request size is also a little bit tricky as it's passed as part of the
59 * request code on unix. The size field is 14 bits on Linux, 12 bits on *BSD,
60 * 13 bits Darwin, and 8-bits on Solaris. All the BSDs and Darwin kernels
61 * will make use of the size field, while Linux and Solaris will not. We're of
62 * course using the size to validate and/or map/lock the request, so it has
63 * to be valid.
64 *
65 * For Solaris we will have to do something special though, 255 isn't
66 * sufficient for all we need. A 4KB restriction (BSD) is probably not
67 * too problematic (yet) as a general one.
68 *
69 * More info can be found in SUPDRVIOC.h and related sources.
70 *
71 * @remarks If adding interfaces that only has input or only has output, some new macros
72 * needs to be created so the most efficient IOCtl data buffering method can be
73 * used.
74 *
75 * @{
76 */
77#if !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT)
78
79/** Fictive start address of the hypervisor physical memory for MmMapIoSpace. */
80#define VBOXGUEST_HYPERVISOR_PHYSICAL_START UINT32_C(0xf8000000)
81
82#ifdef RT_OS_DARWIN
83/** Cookie used to fend off some unwanted clients to the IOService. */
84# define VBOXGUEST_DARWIN_IOSERVICE_COOKIE UINT32_C(0x56426f78) /* 'VBox' */
85#endif
86
87/** The bit-count indicator mask. */
88#define VBGL_IOCTL_FLAG_BIT_MASK UINT32_C(128)
89/** 64-bit specific I/O control flag. */
90#define VBGL_IOCTL_FLAG_64BIT UINT32_C(128)
91/** 32-bit specific I/O control flag.
92 * @note Just for complementing VBGL_IOCTL_FLAG_64BIT. It is also the same
93 * value we use for bit-count agnostic requests, so don't ever use for
94 * testing!
95 * @internal */
96#define VBGL_IOCTL_FLAG_32BIT UINT32_C(0)
97/** 16-bit specific I/O control flag. */
98#define VBGL_IOCTL_FLAG_16BIT UINT32_C(64)
99/** Check if the I/O control is a 64-bit one. */
100#define VBGL_IOCTL_IS_64BIT(a_uIOCtl) RT_BOOL((a_uIOCtl) & VBGL_IOCTL_FLAG_64BIT)
101
102/** @def VBGL_IOCTL_FLAG_CC
103 * The context specific bit-count flag to include in the bit-count sensitive
104 * I/O controls. */
105#if ARCH_BITS == 64
106# define VBGL_IOCTL_FLAG_CC VBGL_IOCTL_FLAG_64BIT
107#elif ARCH_BITS == 32
108# define VBGL_IOCTL_FLAG_CC VBGL_IOCTL_FLAG_32BIT
109#elif ARCH_BITS == 16
110# define VBGL_IOCTL_FLAG_CC VBGL_IOCTL_FLAG_16BIT
111#else
112# error "dunno which arch this is!"
113#endif
114
115
116#if defined(RT_OS_WINDOWS)
117# ifndef CTL_CODE
118# include <iprt/win/windows.h>
119# endif
120 /* Automatic buffering, size not encoded. */
121# define VBGL_IOCTL_CODE_SIZE(Function, Size) CTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS)
122# define VBGL_IOCTL_CODE_BIG(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS)
123# define VBGL_IOCTL_CODE_FAST(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_NEITHER, FILE_WRITE_ACCESS)
124# define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) ((a_uIOCtl) & ~VBGL_IOCTL_FLAG_BIT_MASK)
125# define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
126/** The support service name. */
127# define VBOXGUEST_SERVICE_NAME "VBoxGuest"
128/** Global name for Win2k+ */
129# define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
130/** Win32 driver name */
131# define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
132/** Device name. */
133# define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
134
135#elif defined(RT_OS_OS2)
136 /* No automatic buffering, size not encoded. */
137# define VBGL_IOCTL_CATEGORY 0xc2
138# define VBGL_IOCTL_CODE_SIZE(Function, Size) ((unsigned char)(Function))
139# define VBGL_IOCTL_CODE_BIG(Function) ((unsigned char)(Function))
140# define VBGL_IOCTL_CATEGORY_FAST 0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
141# define VBGL_IOCTL_CODE_FAST(Function) ((unsigned char)(Function))
142# define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) ((a_uIOCtl) & ~VBGL_IOCTL_FLAG_BIT_MASK)
143# define VBOXGUEST_DEVICE_NAME "\\Dev\\VBoxGst$"
144/** Short device name for AttachDD.
145 * @note Case sensitive. Must match what VBoxGuestA-os2.asm says! */
146# define VBOXGUEST_DEVICE_NAME_SHORT "vboxgst$"
147
148#elif defined(RT_OS_SOLARIS)
149 /* No automatic buffering, size limited to 255 bytes => use VBGLBIGREQ for everything. */
150# include <sys/ioccom.h>
151# define VBGL_IOCTL_CODE_SIZE(Function, Size) _IOWRN('V', (Function), sizeof(VBGLREQHDR))
152# define VBGL_IOCTL_CODE_BIG(Function) _IOWRN('V', (Function), sizeof(VBGLREQHDR))
153# define VBGL_IOCTL_CODE_FAST(Function) _IO( 'F', (Function))
154# define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) ((a_uIOCtl) & ~VBGL_IOCTL_FLAG_BIT_MASK)
155# define VBGL_IOCTL_IS_FAST(a_uIOCtl) ( ((a_uIOCtl) & 0x0000ff00) == ('F' << 8) )
156
157#elif defined(RT_OS_LINUX)
158 /* No automatic buffering, size limited to 16KB. */
159# include <linux/ioctl.h>
160# define VBGL_IOCTL_CODE_SIZE(Function, Size) _IOC(_IOC_READ | _IOC_WRITE, 'V', (Function), (Size))
161# define VBGL_IOCTL_CODE_BIG(Function) _IO('V', (Function))
162# define VBGL_IOCTL_CODE_FAST(Function) _IO('F', (Function))
163# define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) (_IOC_NR((a_uIOCtl)) & ~VBGL_IOCTL_FLAG_BIT_MASK)
164# define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxuser"
165
166#elif defined(RT_OS_HAIKU)
167 /* No automatic buffering, size not encoded. */
168 /** @todo do something better */
169# define VBGL_IOCTL_CODE_SIZE(Function, Size) (0x56420000 | (Function))
170# define VBGL_IOCTL_CODE_BIG(Function) (0x56420000 | (Function))
171# define VBGL_IOCTL_CODE_FAST(Function) (0x56420000 | (Function))
172# define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) ((a_uIOCtl) & ~VBGL_IOCTL_FLAG_BIT_MASK)
173# define VBOXGUEST_DEVICE_NAME "/dev/misc/vboxguest"
174
175#else /* BSD Like */
176 /* Automatic buffering, size limited to 4KB on *BSD and 8KB on Darwin - commands the limit, 4KB. */
177# include <sys/ioccom.h>
178# define VBGL_IOCTL_CODE_SIZE(Function, Size) _IOC(IOC_INOUT, 'V', (Function), (Size))
179# define VBGL_IOCTL_CODE_BIG(Function) _IO('V', (Function))
180# define VBGL_IOCTL_CODE_FAST(Function) _IO('F', (Function))
181# define VBGL_IOCTL_CODE_STRIPPED(a_uIOCtl) ((a_uIOCtl) & ~(_IOC(0,0,0,IOCPARM_MASK) | VBGL_IOCTL_FLAG_BIT_MASK))
182# define VBGL_IOCTL_IS_FAST(a_uIOCtl) ( IOCGROUP(a_uIOCtl) == 'F' )
183#endif
184
185
186/** @todo It would be nice if we could have two defines without paths. */
187
188/** @def VBOXGUEST_DEVICE_NAME
189 * The support device name. */
190#ifndef VBOXGUEST_DEVICE_NAME /* PORTME */
191# define VBOXGUEST_DEVICE_NAME "/dev/vboxguest"
192#endif
193
194/** @def VBOXGUEST_USER_DEVICE_NAME
195 * The support device name of the user accessible device node. */
196#ifndef VBOXGUEST_USER_DEVICE_NAME
197# define VBOXGUEST_USER_DEVICE_NAME VBOXGUEST_DEVICE_NAME
198#endif
199
200
201/**
202 * Common In/Out header.
203 *
204 * This is a copy/mirror of VMMDevRequestHeader to prevent duplicating data and
205 * needing to verify things multiple times. For that reason this differs a bit
206 * from SUPREQHDR.
207 *
208 * @sa VMMDevRequestHeader
209 */
210typedef struct VBGLREQHDR
211{
212 /** IN: The request input size, and output size if cbOut is zero.
213 * @sa VMMDevRequestHeader::size */
214 uint32_t cbIn;
215 /** IN: Structure version (VBGLREQHDR_VERSION)
216 * @sa VMMDevRequestHeader::version */
217 uint32_t uVersion;
218 /** IN: The VMMDev request type, set to VBGLREQHDR_TYPE_DEFAULT unless this is a
219 * kind of VMMDev request.
220 * @sa VMMDevRequestType, VMMDevRequestHeader::requestType */
221 uint32_t uType;
222 /** OUT: The VBox status code of the operation, out direction only. */
223 int32_t rc;
224 /** IN: The output size. This is optional - set to zero to use cbIn as the
225 * output size. */
226 uint32_t cbOut;
227 /** Reserved, MBZ. */
228 uint32_t uReserved;
229} VBGLREQHDR;
230AssertCompileSize(VBGLREQHDR, 24);
231/** Pointer to a IOC header. */
232typedef VBGLREQHDR RT_FAR *PVBGLREQHDR;
233
234/** Version of VMMDevRequestHeader structure. */
235#define VBGLREQHDR_VERSION UINT32_C(0x10001)
236/** Default request type. Use this for non-VMMDev requests. */
237#define VBGLREQHDR_TYPE_DEFAULT UINT32_C(0)
238
239/** Initialize a VBGLREQHDR structure for a fixed size I/O control call.
240 * @param a_pHdr Pointer to the header to initialize.
241 * @param a_IOCtl The base I/O control name, no VBGL_IOCTL_ prefix. We
242 * have to skip the prefix to avoid it getting expanded
243 * before we append _SIZE_IN and _SIZE_OUT to it.
244 */
245#define VBGLREQHDR_INIT(a_pHdr, a_IOCtl) \
246 VBGLREQHDR_INIT_EX(a_pHdr, RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_IN), RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_OUT))
247/** Initialize a VBGLREQHDR structure, extended version. */
248#define VBGLREQHDR_INIT_EX(a_pHdr, a_cbIn, a_cbOut) \
249 do { \
250 (a_pHdr)->cbIn = (uint32_t)(a_cbIn); \
251 (a_pHdr)->uVersion = VBGLREQHDR_VERSION; \
252 (a_pHdr)->uType = VBGLREQHDR_TYPE_DEFAULT; \
253 (a_pHdr)->rc = VERR_INTERNAL_ERROR; \
254 (a_pHdr)->cbOut = (uint32_t)(a_cbOut); \
255 (a_pHdr)->uReserved = 0; \
256 } while (0)
257/** Initialize a VBGLREQHDR structure for a VMMDev request.
258 * Same as VMMDEV_REQ_HDR_INIT(). */
259#define VBGLREQHDR_INIT_VMMDEV(a_pHdr, a_cb, a_enmType) \
260 do { \
261 (a_pHdr)->cbIn = (a_cb); \
262 (a_pHdr)->uVersion = VBGLREQHDR_VERSION; \
263 (a_pHdr)->uType = (a_enmType); \
264 (a_pHdr)->rc = VERR_INTERNAL_ERROR; \
265 (a_pHdr)->cbOut = 0; \
266 (a_pHdr)->uReserved = 0; \
267 } while (0)
268
269
270
271/**
272 * The VBoxGuest I/O control version.
273 *
274 * As usual, the high word contains the major version and changes to it
275 * signifies incompatible changes.
276 *
277 * The lower word is the minor version number, it is increased when new
278 * functions are added or existing changed in a backwards compatible manner.
279 */
280#define VBGL_IOC_VERSION UINT32_C(0x00010000)
281
282
283
284/** @name VBGL_IOCTL_DRIVER_INFO
285 * Adjust and get driver information.
286 *
287 * @note May switch the session to a backwards compatible interface version if
288 * uClientVersion indicates older client code.
289 *
290 * @{
291 */
292#define VBGL_IOCTL_DRIVER_VERSION_INFO VBGL_IOCTL_CODE_SIZE(0, VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE)
293#define VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE sizeof(VBGLIOCDRIVERVERSIONINFO)
294#define VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE_IN RT_UOFFSET_AFTER(VBGLIOCDRIVERVERSIONINFO, u.In)
295#define VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE_OUT sizeof(VBGLIOCDRIVERVERSIONINFO)
296typedef struct VBGLIOCDRIVERVERSIONINFO
297{
298 /** The header. */
299 VBGLREQHDR Hdr;
300 union
301 {
302 struct
303 {
304 /** The requested interface version number (VBGL_IOC_VERSION). */
305 uint32_t uReqVersion;
306 /** The minimum interface version number
307 * (typically the major version part of VBGL_IOC_VERSION). */
308 uint32_t uMinVersion;
309 /** Reserved, MBZ. */
310 uint32_t uReserved1;
311 /** Reserved, MBZ. */
312 uint32_t uReserved2;
313 } In;
314 struct
315 {
316 /** Interface version for this session (typically VBGL_IOC_VERSION). */
317 uint32_t uSessionVersion;
318 /** The version of the IDC interface (VBGL_IOC_VERSION). */
319 uint32_t uDriverVersion;
320 /** The SVN revision of the driver.
321 * This will be set to 0 if not compiled into the driver. */
322 uint32_t uDriverRevision;
323 /** Reserved \#1 (will be returned as zero until defined). */
324 uint32_t uReserved1;
325 /** Reserved \#2 (will be returned as zero until defined). */
326 uint32_t uReserved2;
327 } Out;
328 } u;
329} VBGLIOCDRIVERVERSIONINFO, RT_FAR *PVBGLIOCDRIVERVERSIONINFO;
330AssertCompileSize(VBGLIOCDRIVERVERSIONINFO, 24 + 20);
331#if !defined(__GNUC__) /* Some GCC versions can't handle the complicated RT_UOFFSET_AFTER macro, it seems. */ \
332 && (!defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__)))
333AssertCompile(VBGL_IOCTL_DRIVER_VERSION_INFO_SIZE_IN == 24 + 16);
334#endif
335/** @} */
336
337
338/** @name VBGL_IOCTL_GET_PORT_INFO
339 * Query VMMDev I/O port region and MMIO mapping address.
340 * @remarks Ring-0 only.
341 * @{
342 */
343#define VBGL_IOCTL_GET_VMMDEV_IO_INFO VBGL_IOCTL_CODE_SIZE(1 | VBGL_IOCTL_FLAG_CC, VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE)
344#define VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE sizeof(VBGLIOCGETVMMDEVIOINFO)
345#define VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE_IN sizeof(VBGLREQHDR)
346#define VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE_OUT sizeof(VBGLIOCGETVMMDEVIOINFO)
347typedef struct VBGLIOCGETVMMDEVIOINFO
348{
349 /** The header. */
350 VBGLREQHDR Hdr;
351 union
352 {
353 struct
354 {
355 /** The MMIO mapping. NULL if no MMIO region. */
356 struct VMMDevMemory volatile RT_FAR *pvVmmDevMapping;
357 /** The I/O port address. */
358 RTIOPORT IoPort;
359 /** Padding, ignore. */
360 RTIOPORT auPadding[HC_ARCH_BITS == 64 ? 3 : 1];
361 } Out;
362 } u;
363} VBGLIOCGETVMMDEVIOINFO, RT_FAR *PVBGLIOCGETVMMDEVIOINFO;
364AssertCompileSize(VBGLIOCGETVMMDEVIOINFO, 24 + (HC_ARCH_BITS == 64 ? 16 : 8));
365/** @} */
366
367
368/** @name VBGL_IOCTL_VMMDEV_REQUEST
369 * IOCTL to VBoxGuest to perform a VMM Device request less than 1KB in size.
370 * @{
371 */
372#define VBGL_IOCTL_VMMDEV_REQUEST(a_cb) VBGL_IOCTL_CODE_SIZE(2, (a_cb))
373/** @} */
374
375
376/** @name VBGL_IOCTL_VMMDEV_REQUEST_BIG
377 * IOCTL to VBoxGuest to perform a VMM Device request that can 1KB or larger.
378 * @{
379 */
380#define VBGL_IOCTL_VMMDEV_REQUEST_BIG VBGL_IOCTL_CODE_BIG(3)
381/** @} */
382
383
384#ifdef VBOX_WITH_HGCM
385/** @name VBGL_IOCTL_HGCM_CONNECT
386 * Connect to a HGCM service.
387 * @{ */
388# define VBGL_IOCTL_HGCM_CONNECT VBGL_IOCTL_CODE_SIZE(4, VBGL_IOCTL_HGCM_CONNECT_SIZE)
389# define VBGL_IOCTL_HGCM_CONNECT_SIZE sizeof(VBGLIOCHGCMCONNECT)
390# define VBGL_IOCTL_HGCM_CONNECT_SIZE_IN sizeof(VBGLIOCHGCMCONNECT)
391# define VBGL_IOCTL_HGCM_CONNECT_SIZE_OUT RT_UOFFSET_AFTER(VBGLIOCHGCMCONNECT, u.Out)
392typedef struct VBGLIOCHGCMCONNECT
393{
394 /** The header. */
395 VBGLREQHDR Hdr;
396 union
397 {
398 struct
399 {
400 HGCMServiceLocation Loc;
401 } In;
402 struct
403 {
404 uint32_t idClient;
405 } Out;
406 } u;
407} VBGLIOCHGCMCONNECT, RT_FAR *PVBGLIOCHGCMCONNECT;
408AssertCompileSize(VBGLIOCHGCMCONNECT, 24 + 132);
409#if !defined(__GNUC__) /* Some GCC versions can't handle the complicated RT_UOFFSET_AFTER macro, it seems. */ \
410 && (!defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__)))
411AssertCompile(VBGL_IOCTL_HGCM_CONNECT_SIZE_OUT == 24 + 4);
412#endif
413/** @} */
414
415
416/** @name VBGL_IOCTL_HGCM_DISCONNECT
417 * Disconnect from a HGCM service.
418 * @{ */
419# define VBGL_IOCTL_HGCM_DISCONNECT VBGL_IOCTL_CODE_SIZE(5, VBGL_IOCTL_HGCM_DISCONNECT_SIZE)
420# define VBGL_IOCTL_HGCM_DISCONNECT_SIZE sizeof(VBGLIOCHGCMDISCONNECT)
421# define VBGL_IOCTL_HGCM_DISCONNECT_SIZE_IN sizeof(VBGLIOCHGCMDISCONNECT)
422# define VBGL_IOCTL_HGCM_DISCONNECT_SIZE_OUT sizeof(VBGLREQHDR)
423/** @note This is also used by a VbglR0 API. */
424typedef struct VBGLIOCHGCMDISCONNECT
425{
426 /** The header. */
427 VBGLREQHDR Hdr;
428 union
429 {
430 struct
431 {
432 uint32_t idClient;
433 } In;
434 } u;
435} VBGLIOCHGCMDISCONNECT, RT_FAR *PVBGLIOCHGCMDISCONNECT;
436AssertCompileSize(VBGLIOCHGCMDISCONNECT, 24 + 4);
437/** @} */
438
439
440/** @name VBGL_IOCTL_HGCM_CALL, VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA
441 *
442 * Make a call to a HGCM servicesure. There are several variations here.
443 *
444 * The VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA variation is for other drivers (like
445 * the graphics ones) passing on requests from user land that contains user
446 * data. These calls are always interruptible.
447 *
448 * @{ */
449# define VBGL_IOCTL_HGCM_CALL(a_cb) VBGL_IOCTL_CODE_SIZE(6 | VBGL_IOCTL_FLAG_CC, (a_cb))
450# define VBGL_IOCTL_HGCM_CALL_32(a_cb) VBGL_IOCTL_CODE_SIZE(6 | VBGL_IOCTL_FLAG_32BIT, (a_cb))
451# define VBGL_IOCTL_HGCM_CALL_64(a_cb) VBGL_IOCTL_CODE_SIZE(6 | VBGL_IOCTL_FLAG_64BIT, (a_cb))
452# define VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA(a_cb) VBGL_IOCTL_CODE_SIZE(7 | VBGL_IOCTL_FLAG_CC, (a_cb))
453/** @note This is used by alot of HGCM call structures. */
454typedef struct VBGLIOCHGCMCALL
455{
456 /** Common header. */
457 VBGLREQHDR Hdr;
458 /** Input: The id of the caller. */
459 uint32_t u32ClientID;
460 /** Input: Function number. */
461 uint32_t u32Function;
462 /** Input: How long to wait (milliseconds) for completion before cancelling the
463 * call. This is ignored if not a VBGL_IOCTL_HGCM_CALL_TIMED or
464 * VBGL_IOCTL_HGCM_CALL_TIMED_32 request. */
465 uint32_t cMsTimeout;
466 /** Input: Whether a timed call is interruptible (ring-0 only). This is ignored
467 * if not a VBGL_IOCTL_HGCM_CALL_TIMED or VBGL_IOCTL_HGCM_CALL_TIMED_32
468 * request, or if made from user land. */
469 bool fInterruptible;
470 /** Explicit padding, MBZ. */
471 uint8_t bReserved;
472 /** Input: How many parameters following this structure.
473 *
474 * The parameters are either HGCMFunctionParameter64 or HGCMFunctionParameter32,
475 * depending on whether we're receiving a 64-bit or 32-bit request.
476 *
477 * The current maximum is 61 parameters (given a 1KB max request size,
478 * and a 64-bit parameter size of 16 bytes).
479 *
480 * @note This information is duplicated by Hdr.cbIn, but it's currently too much
481 * work to eliminate this. */
482 uint16_t cParms;
483 /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
484} VBGLIOCHGCMCALL, RT_FAR *PVBGLIOCHGCMCALL;
485AssertCompileSize(VBGLIOCHGCMCALL, 24 + 16);
486typedef VBGLIOCHGCMCALL const RT_FAR *PCVBGLIOCHGCMCALL;
487
488/**
489 * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call.
490 *
491 * @param a_pHdr The header to initalize.
492 * @param a_idClient The client connection ID to call thru.
493 * @param a_idFunction The function we're calling
494 * @param a_cParameters Number of parameters.
495 */
496# define VBGL_HGCM_HDR_INIT(a_pHdr, a_idClient, a_idFunction, a_cParameters) \
497 do { \
498 VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, \
499 sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter), \
500 sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
501 (a_pHdr)->u32ClientID = (a_idClient); \
502 (a_pHdr)->u32Function = (a_idFunction); \
503 (a_pHdr)->cMsTimeout = RT_INDEFINITE_WAIT; \
504 (a_pHdr)->fInterruptible = true; \
505 (a_pHdr)->bReserved = 0; \
506 (a_pHdr)->cParms = (a_cParameters); \
507 } while (0)
508
509/**
510 * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call, custom size.
511 *
512 * This is usually only needed when appending page lists to the call.
513 *
514 * @param a_pHdr The header to initalize.
515 * @param a_idClient The client connection ID to call thru.
516 * @param a_idFunction The function we're calling
517 * @param a_cParameters Number of parameters.
518 * @param a_cbReq The request size.
519 */
520# define VBGL_HGCM_HDR_INIT_EX(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cbReq) \
521 do { \
522 Assert((a_cbReq) >= sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
523 VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, (a_cbReq), (a_cbReq)); \
524 (a_pHdr)->u32ClientID = (a_idClient); \
525 (a_pHdr)->u32Function = (a_idFunction); \
526 (a_pHdr)->cMsTimeout = RT_INDEFINITE_WAIT; \
527 (a_pHdr)->fInterruptible = true; \
528 (a_pHdr)->bReserved = 0; \
529 (a_pHdr)->cParms = (a_cParameters); \
530 } while (0)
531
532/**
533 * Initialize a HGCM header (VBGLIOCHGCMCALL), with timeout (interruptible).
534 *
535 * @param a_pHdr The header to initalize.
536 * @param a_idClient The client connection ID to call thru.
537 * @param a_idFunction The function we're calling
538 * @param a_cParameters Number of parameters.
539 * @param a_cMsTimeout The timeout in milliseconds.
540 */
541# define VBGL_HGCM_HDR_INIT_TIMED(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cMsTimeout) \
542 do { \
543 (a_pHdr)->u32ClientID = (a_idClient); \
544 (a_pHdr)->u32Function = (a_idFunction); \
545 (a_pHdr)->cMsTimeout = (a_cMsTimeout); \
546 (a_pHdr)->fInterruptible = true; \
547 (a_pHdr)->bReserved = 0; \
548 (a_pHdr)->cParms = (a_cParameters); \
549 } while (0)
550
551/** Get the pointer to the first HGCM parameter. */
552# define VBGL_HGCM_GET_CALL_PARMS(a_pInfo) ( (HGCMFunctionParameter *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
553/** Get the pointer to the first HGCM parameter in a 32-bit request. */
554# define VBGL_HGCM_GET_CALL_PARMS32(a_pInfo) ( (HGCMFunctionParameter32 *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
555
556/** @} */
557#endif /* VBOX_WITH_HGCM */
558
559
560/** @name VBGL_IOCTL_LOG
561 * IOCTL to VBoxGuest to perform backdoor logging.
562 * @{ */
563#define VBOXGUEST_IOCTL_LOG(Size)
564#define VBGL_IOCTL_LOG(a_cchMsg) VBGL_IOCTL_CODE_BIG(8)
565#define VBGL_IOCTL_LOG_SIZE(a_cchMsg) (sizeof(VBGLREQHDR) + (a_cchMsg) + 1)
566#define VBGL_IOCTL_LOG_SIZE_IN(a_cchMsg) (sizeof(VBGLREQHDR) + (a_cchMsg) + 1)
567#define VBGL_IOCTL_LOG_SIZE_OUT sizeof(VBGLREQHDR)
568typedef struct VBGLIOCLOG
569{
570 /** The header. */
571 VBGLREQHDR Hdr;
572 union
573 {
574 struct
575 {
576 /** The log message.
577 * The length is determined from the input size and zero termination. */
578 char szMsg[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION];
579 } In;
580 } u;
581} VBGLIOCLOG, RT_FAR *PVBGLIOCLOG;
582/** @} */
583
584
585/** @name VBGL_IOCTL_WAIT_FOR_EVENTS
586 * Wait for a VMMDev host event notification.
587 * @{
588 */
589#define VBGL_IOCTL_WAIT_FOR_EVENTS VBGL_IOCTL_CODE_SIZE(9, VBGL_IOCTL_GET_VMMDEV_IO_INFO_SIZE)
590#define VBGL_IOCTL_WAIT_FOR_EVENTS_SIZE sizeof(VBGLIOCWAITFOREVENTS)
591#define VBGL_IOCTL_WAIT_FOR_EVENTS_SIZE_IN sizeof(VBGLIOCWAITFOREVENTS)
592#define VBGL_IOCTL_WAIT_FOR_EVENTS_SIZE_OUT RT_UOFFSET_AFTER(VBGLIOCWAITFOREVENTS, u.Out)
593typedef struct VBGLIOCWAITFOREVENTS
594{
595 /** The header. */
596 VBGLREQHDR Hdr;
597 union
598 {
599 struct
600 {
601 /** Timeout in milliseconds. */
602 uint32_t cMsTimeOut;
603 /** Events to wait for. */
604 uint32_t fEvents;
605 } In;
606 struct
607 {
608 /** Events that occurred. */
609 uint32_t fEvents;
610 } Out;
611 } u;
612} VBGLIOCWAITFOREVENTS, RT_FAR *PVBGLIOCWAITFOREVENTS;
613AssertCompileSize(VBGLIOCWAITFOREVENTS, 24 + 8);
614/** @} */
615
616
617/** @name VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS
618 * IOCTL to VBoxGuest to interrupt (cancel) any pending
619 * VBGL_IOCTL_WAIT_FOR_EVENTS and return.
620 *
621 * Handled inside the guest additions and not seen by the host at all.
622 * After calling this, VBGL_IOCTL_WAIT_FOR_EVENTS should no longer be called in
623 * the same session. At the time of writing this is not enforced; at the time
624 * of reading it may be.
625 * @see VBGL_IOCTL_WAIT_FOR_EVENTS
626 *
627 * @{
628 */
629#define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS VBGL_IOCTL_CODE_SIZE(10, VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE)
630#define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE sizeof(VBGLREQHDR)
631#define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE_IN sizeof(VBGLREQHDR)
632#define VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS_SIZE_OUT sizeof(VBGLREQHDR)
633/** @} */
634
635
636/** @name VBGL_IOCTL_CHANGE_FILTER_MASK
637 * IOCTL to VBoxGuest to control the event filter mask.
638 * @{ */
639#define VBGL_IOCTL_CHANGE_FILTER_MASK VBGL_IOCTL_CODE_SIZE(11, VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE)
640#define VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE sizeof(VBGLIOCCHANGEFILTERMASK)
641#define VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE_IN sizeof(VBGLIOCCHANGEFILTERMASK)
642#define VBGL_IOCTL_CHANGE_FILTER_MASK_SIZE_OUT sizeof(VBGLREQHDR)
643typedef struct VBGLIOCCHANGEFILTERMASK
644{
645 /** The header. */
646 VBGLREQHDR Hdr;
647 union
648 {
649 struct
650 {
651 /** Flags to set. */
652 uint32_t fOrMask;
653 /** Flags to remove. */
654 uint32_t fNotMask;
655 } In;
656 } u;
657} VBGLIOCCHANGEFILTERMASK, RT_FAR *PVBGLIOCCHANGEFILTERMASK;
658AssertCompileSize(VBGLIOCCHANGEFILTERMASK, 24 + 8);
659/** @} */
660
661
662/** @name VBGL_IOCTL_GUEST_CAPS_ACQUIRE
663 * IOCTL to for acquiring and releasing guest capabilities.
664 *
665 * This is used for multiple purposes:
666 * 1. By doing @a acquire r3 client application (e.g. VBoxTray) claims it will
667 * use the given session for performing operations like @a seamless or
668 * @a auto-resize, thus, if the application terminates, the driver will
669 * automatically cleanup the caps reported to host, so that host knows guest
670 * does not support them anymore
671 * 2. In a multy-user environment this will not allow r3 applications (like
672 * VBoxTray) running in different user sessions simultaneously to interfere
673 * with each other. An r3 client application (like VBoxTray) is responsible
674 * for Acquiring/Releasing caps properly as needed.
675 *
676 *
677 * VERR_RESOURCE_BUSY is returned if any capabilities in the fOrMask are
678 * currently acquired by some other VBoxGuest session.
679 *
680 * @{
681 */
682#define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES VBGL_IOCTL_CODE_SIZE(12, VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE)
683#define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE sizeof(VBGLIOCACQUIREGUESTCAPS)
684#define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE_IN sizeof(VBGLIOCACQUIREGUESTCAPS)
685#define VBGL_IOCTL_ACQUIRE_GUEST_CAPABILITIES_SIZE_OUT sizeof(VBGLREQHDR)
686
687/** Default operation (full acquire/release). */
688#define VBGL_IOC_AGC_FLAGS_DEFAULT UINT32_C(0x00000000)
689/** Configures VBoxGuest to use the specified caps in Acquire mode, w/o making
690 * any caps acquisition/release. This is only possible to set acquire mode for
691 * caps, but not clear it, so fNotMask is ignored when this flag is set. */
692#define VBGL_IOC_AGC_FLAGS_CONFIG_ACQUIRE_MODE UINT32_C(0x00000001)
693/** Valid flag mask. */
694#define VBGL_IOC_AGC_FLAGS_VALID_MASK UINT32_C(0x00000001)
695
696typedef struct VBGLIOCACQUIREGUESTCAPS
697{
698 /** The header. */
699 VBGLREQHDR Hdr;
700 union
701 {
702 struct
703 {
704 /** Acquire flags (VBGL_IOC_AGC_FLAGS_XXX). */
705 uint32_t fFlags;
706 /** Guest capabilities to acquire (VMMDEV_GUEST_SUPPORTS_XXX). */
707 uint32_t fOrMask;
708 /** Guest capabilities to release (VMMDEV_GUEST_SUPPORTS_XXX). */
709 uint32_t fNotMask;
710 } In;
711 } u;
712} VBGLIOCACQUIREGUESTCAPS, RT_FAR *PVBGLIOCACQUIREGUESTCAPS;
713AssertCompileSize(VBGLIOCACQUIREGUESTCAPS, 24 + 12);
714/** @} */
715
716
717/** @name VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES
718 * IOCTL to VBoxGuest to set guest capabilities.
719 * @{ */
720#define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES VBGL_IOCTL_CODE_SIZE(13, VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE)
721#define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE sizeof(VBGLIOCSETGUESTCAPS)
722#define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE_IN sizeof(VBGLIOCSETGUESTCAPS)
723#define VBGL_IOCTL_CHANGE_GUEST_CAPABILITIES_SIZE_OUT sizeof(VBGLIOCSETGUESTCAPS)
724typedef struct VBGLIOCSETGUESTCAPS
725{
726 /** The header. */
727 VBGLREQHDR Hdr;
728 union
729 {
730 struct
731 {
732 /** The capabilities to set (VMMDEV_GUEST_SUPPORTS_XXX). */
733 uint32_t fOrMask;
734 /** The capabilities to drop (VMMDEV_GUEST_SUPPORTS_XXX). */
735 uint32_t fNotMask;
736 } In;
737 struct
738 {
739 /** The capabilities held by the session after the call (VMMDEV_GUEST_SUPPORTS_XXX). */
740 uint32_t fSessionCaps;
741 /** The capabilities for all the sessions after the call (VMMDEV_GUEST_SUPPORTS_XXX). */
742 uint32_t fGlobalCaps;
743 } Out;
744 } u;
745} VBGLIOCSETGUESTCAPS, RT_FAR *PVBGLIOCSETGUESTCAPS;
746AssertCompileSize(VBGLIOCSETGUESTCAPS, 24 + 8);
747typedef VBGLIOCSETGUESTCAPS VBoxGuestSetCapabilitiesInfo;
748/** @} */
749
750
751/** @name VBGL_IOCTL_SET_MOUSE_STATUS
752 * IOCTL to VBoxGuest to update the mouse status features.
753 * @{ */
754#define VBGL_IOCTL_SET_MOUSE_STATUS VBGL_IOCTL_CODE_SIZE(14, VBGL_IOCTL_SET_MOUSE_STATUS_SIZE)
755#define VBGL_IOCTL_SET_MOUSE_STATUS_SIZE sizeof(VBGLIOCSETMOUSESTATUS)
756#define VBGL_IOCTL_SET_MOUSE_STATUS_SIZE_IN sizeof(VBGLIOCSETMOUSESTATUS)
757#define VBGL_IOCTL_SET_MOUSE_STATUS_SIZE_OUT sizeof(VBGLREQHDR)
758typedef struct VBGLIOCSETMOUSESTATUS
759{
760 /** The header. */
761 VBGLREQHDR Hdr;
762 union
763 {
764 struct
765 {
766 /** Mouse status flags (VMMDEV_MOUSE_XXX). */
767 uint32_t fStatus;
768 } In;
769 } u;
770} VBGLIOCSETMOUSESTATUS, RT_FAR *PVBGLIOCSETMOUSESTATUS;
771/** @} */
772
773
774/** @name VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK
775 *
776 * IOCTL to for setting the mouse driver callback.
777 * @note The callback will be called in interrupt context with the VBoxGuest
778 * device event spinlock held.
779 * @note ring-0 only.
780 *
781 * @{ */
782#define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK VBGL_IOCTL_CODE_SIZE(15, VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE)
783#define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE sizeof(VBGLIOCSETMOUSENOTIFYCALLBACK)
784#define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE_IN sizeof(VBGLIOCSETMOUSENOTIFYCALLBACK)
785#define VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK_SIZE_OUT sizeof(VBGLREQHDR)
786/**
787 * Mouse event noticification callback function.
788 * @param pvUser Argument given when setting the callback.
789 */
790typedef DECLCALLBACK(void) FNVBOXGUESTMOUSENOTIFY(void *pvUser);
791/** Pointer to a mouse event notification callback function. */
792typedef FNVBOXGUESTMOUSENOTIFY *PFNVBOXGUESTMOUSENOTIFY; /**< @todo fix type prefix */
793typedef struct VBGLIOCSETMOUSENOTIFYCALLBACK
794{
795 /** The header. */
796 VBGLREQHDR Hdr;
797 union
798 {
799 struct
800 {
801 /** Mouse notification callback function. */
802 PFNVBOXGUESTMOUSENOTIFY pfnNotify;
803 /** The callback argument. */
804 void RT_FAR *pvUser;
805 } In;
806 } u;
807} VBGLIOCSETMOUSENOTIFYCALLBACK, RT_FAR *PVBGLIOCSETMOUSENOTIFYCALLBACK;
808/** @} */
809
810
811/** @name VBGL_IOCTL_CHECK_BALLOON
812 * IOCTL to VBoxGuest to check memory ballooning.
813 *
814 * The guest kernel module / device driver will ask the host for the current size of
815 * the balloon and adjust the size. Or it will set fHandledInR0 = false and R3 is
816 * responsible for allocating memory and calling R0 (VBGL_IOCTL_CHANGE_BALLOON).
817 * @{ */
818#define VBGL_IOCTL_CHECK_BALLOON VBGL_IOCTL_CODE_SIZE(16, VBGL_IOCTL_CHECK_BALLOON_SIZE)
819#define VBGL_IOCTL_CHECK_BALLOON_SIZE sizeof(VBGLIOCCHECKBALLOON)
820#define VBGL_IOCTL_CHECK_BALLOON_SIZE_IN sizeof(VBGLREQHDR)
821#define VBGL_IOCTL_CHECK_BALLOON_SIZE_OUT sizeof(VBGLIOCCHECKBALLOON)
822typedef struct VBGLIOCCHECKBALLOON
823{
824 /** The header. */
825 VBGLREQHDR Hdr;
826 union
827 {
828 struct
829 {
830 /** The size of the balloon in chunks of 1MB. */
831 uint32_t cBalloonChunks;
832 /** false = handled in R0, no further action required.
833 * true = allocate balloon memory in R3. */
834 bool fHandleInR3;
835 /** Explicit padding, please ignore. */
836 bool afPadding[3];
837 } Out;
838 } u;
839} VBGLIOCCHECKBALLOON, RT_FAR *PVBGLIOCCHECKBALLOON;
840AssertCompileSize(VBGLIOCCHECKBALLOON, 24 + 8);
841typedef VBGLIOCCHECKBALLOON VBoxGuestCheckBalloonInfo;
842/** @} */
843
844
845/** @name VBGL_IOCTL_CHANGE_BALLOON
846 * IOCTL to VBoxGuest to supply or revoke one chunk for ballooning.
847 *
848 * The guest kernel module / device driver will lock down supplied memory or
849 * unlock reclaimed memory and then forward the physical addresses of the
850 * changed balloon chunk to the host.
851 *
852 * @{ */
853#define VBGL_IOCTL_CHANGE_BALLOON VBGL_IOCTL_CODE_SIZE(17, VBGL_IOCTL_CHANGE_BALLOON_SIZE)
854#define VBGL_IOCTL_CHANGE_BALLOON_SIZE sizeof(VBGLIOCCHANGEBALLOON)
855#define VBGL_IOCTL_CHANGE_BALLOON_SIZE_IN sizeof(VBGLIOCCHANGEBALLOON)
856#define VBGL_IOCTL_CHANGE_BALLOON_SIZE_OUT sizeof(VBGLREQHDR)
857typedef struct VBGLIOCCHANGEBALLOON
858{
859 /** The header. */
860 VBGLREQHDR Hdr;
861 union
862 {
863 struct
864 {
865 /** Address of the chunk (user space address). */
866 RTR3PTR pvChunk;
867 /** Explicit alignment padding, MBZ. */
868 uint8_t abPadding[ARCH_BITS == 64 ? 0 + 7 : 4 + 7];
869 /** true = inflate, false = deflate. */
870 bool fInflate;
871 } In;
872 } u;
873} VBGLIOCCHANGEBALLOON, RT_FAR *PVBGLIOCCHANGEBALLOON;
874AssertCompileSize(VBGLIOCCHANGEBALLOON, 24+16);
875/** @} */
876
877
878/** @name VBGL_IOCTL_WRITE_CORE_DUMP
879 * IOCTL to VBoxGuest to write guest core.
880 * @{ */
881#define VBGL_IOCTL_WRITE_CORE_DUMP VBGL_IOCTL_CODE_SIZE(18, VBGL_IOCTL_WRITE_CORE_DUMP_SIZE)
882#define VBGL_IOCTL_WRITE_CORE_DUMP_SIZE sizeof(VBGLIOCWRITECOREDUMP)
883#define VBGL_IOCTL_WRITE_CORE_DUMP_SIZE_IN sizeof(VBGLIOCWRITECOREDUMP)
884#define VBGL_IOCTL_WRITE_CORE_DUMP_SIZE_OUT sizeof(VBGLREQHDR)
885typedef struct VBGLIOCWRITECOREDUMP
886{
887 /** The header. */
888 VBGLREQHDR Hdr;
889 union
890 {
891 struct
892 {
893 /** Flags (reserved, MBZ). */
894 uint32_t fFlags;
895 } In;
896 } u;
897} VBGLIOCWRITECOREDUMP, RT_FAR *PVBGLIOCWRITECOREDUMP;
898AssertCompileSize(VBGLIOCWRITECOREDUMP, 24 + 4);
899typedef VBGLIOCWRITECOREDUMP VBoxGuestWriteCoreDump;
900/** @} */
901
902
903#ifdef VBOX_WITH_DPC_LATENCY_CHECKER
904/** @name VBGL_IOCTL_DPC_LATENCY_CHECKER
905 * IOCTL to VBoxGuest to perform DPC latency tests, printing the result in
906 * the release log on the host. Takes no data, returns no data.
907 * @{ */
908# define VBGL_IOCTL_DPC_LATENCY_CHECKER VBGL_IOCTL_CODE_SIZE(19, VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE)
909# define VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE sizeof(VBGLREQHDR)
910# define VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE_IN sizeof(VBGLREQHDR)
911# define VBGL_IOCTL_DPC_LATENCY_CHECKER_SIZE_OUT sizeof(VBGLREQHDR)
912/** @} */
913#endif
914
915
916#ifdef RT_OS_OS2
917/**
918 * The data buffer layout for the IDC entry point (AttachDD).
919 *
920 * @remark This is defined in multiple 16-bit headers / sources.
921 * Some places it's called VBGOS2IDC to short things a bit.
922 */
923typedef struct VBGLOS2ATTACHDD
924{
925 /** VBGL_IOC_VERSION. */
926 uint32_t u32Version;
927 /** Opaque session handle. */
928 uint32_t u32Session;
929
930 /**
931 * The 32-bit service entry point.
932 *
933 * @returns VBox status code.
934 * @param u32Session The session handle (PVBOXGUESTSESSION).
935 * @param iFunction The requested function.
936 * @param pReqHdr The input/output data buffer. The caller
937 * ensures that this cannot be swapped out, or that
938 * it's acceptable to take a page in fault in the
939 * current context. If the request doesn't take
940 * input or produces output, apssing NULL is okay.
941 * @param cbReq The size of the data buffer.
942 */
943# if ARCH_BITS == 32 || defined(DOXYGEN_RUNNING)
944 DECLCALLBACKMEMBER(int, pfnServiceEP)(uint32_t u32Session, unsigned iFunction, PVBGLREQHDR pReqHdr, size_t cbReq);
945# else
946 uint32_t pfnServiceEP;
947#endif
948
949 /** The 16-bit service entry point for C code (cdecl).
950 *
951 * It's the same as the 32-bit entry point, but the types has
952 * changed to 16-bit equivalents.
953 *
954 * @code
955 * int far cdecl
956 * VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction,
957 * PVBGLREQHDR fpvData, uint16_t cbData);
958 * @endcode
959 */
960# if ARCH_BITS == 16 || defined(DOXYGEN_RUNNING)
961 DECLCALLBACKMEMBER(int, fpfnServiceEP)(uint32_t u32Session, uint16_t iFunction, PVBGLREQHDR fpvData, uint16_t cbData);
962# else
963 RTFAR16 fpfnServiceEP;
964# endif
965
966 /** The 16-bit service entry point for Assembly code (register).
967 *
968 * This is just a wrapper around fpfnServiceEP to simplify calls
969 * from 16-bit assembly code.
970 *
971 * @returns (e)ax: VBox status code; cx: The amount of data returned.
972 *
973 * @param u32Session eax - The above session handle.
974 * @param iFunction dl - The requested function.
975 * @param pvData es:bx - The input/output data buffer.
976 * @param cbData cx - The size of the data buffer.
977 */
978 RTFAR16 fpfnServiceAsmEP;
979} VBGLOS2ATTACHDD;
980/** Pointer to VBOXGUESTOS2IDCCONNECT buffer. */
981typedef VBGLOS2ATTACHDD RT_FAR *PVBGLOS2ATTACHDD;
982
983/**
984 * Prototype for the 16-bit callback returned by AttachDD on OS/2.
985 * @param pAttachInfo Pointer to structure to fill in.
986 */
987# if defined(__IBMC__) || defined(__IBMCPP__)
988typedef void (* __cdecl RT_FAR_CODE PFNVBGLOS2ATTACHDD)(PVBGLOS2ATTACHDD pAttachInfo);
989# else
990typedef void (__cdecl RT_FAR_CODE *PFNVBGLOS2ATTACHDD)(PVBGLOS2ATTACHDD pAttachInfo);
991# endif
992#endif /* RT_OS_OS2 */
993
994
995/** @name VBGL_IOCL_IDC_CONNECT
996 * IDC client connect request.
997 *
998 * On platforms other than Windows and OS/2, this will also create a kernel
999 * session for the caller.
1000 *
1001 * @note ring-0 only.
1002 */
1003#define VBGL_IOCTL_IDC_CONNECT VBGL_IOCTL_CODE_SIZE(63 | VBGL_IOCTL_FLAG_CC, VBGL_IOCTL_IDC_CONNECT_SIZE)
1004#define VBGL_IOCTL_IDC_CONNECT_SIZE sizeof(VBGLIOCIDCCONNECT)
1005#define VBGL_IOCTL_IDC_CONNECT_SIZE_IN RT_UOFFSET_AFTER(VBGLIOCIDCCONNECT, u.In)
1006#define VBGL_IOCTL_IDC_CONNECT_SIZE_OUT sizeof(VBGLIOCIDCCONNECT)
1007typedef struct VBGLIOCIDCCONNECT
1008{
1009 /** The header. */
1010 VBGLREQHDR Hdr;
1011 /** The payload union. */
1012 union
1013 {
1014 struct
1015 {
1016 /** VBGL_IOCTL_IDC_CONNECT_MAGIC_COOKIE. */
1017 uint32_t u32MagicCookie;
1018 /** The desired version of the I/O control interface (VBGL_IOC_VERSION). */
1019 uint32_t uReqVersion;
1020 /** The minimum version of the I/O control interface (VBGL_IOC_VERSION). */
1021 uint32_t uMinVersion;
1022 /** Reserved, MBZ. */
1023 uint32_t uReserved;
1024 } In;
1025 struct
1026 {
1027 /** The session handle (opaque). */
1028#if ARCH_BITS >= 32
1029 void RT_FAR *pvSession;
1030#else
1031 uint32_t pvSession;
1032#endif
1033 /** The version of the I/O control interface for this session
1034 * (typically VBGL_IOC_VERSION). */
1035 uint32_t uSessionVersion;
1036 /** The I/O control interface version for of the driver (VBGL_IOC_VERSION). */
1037 uint32_t uDriverVersion;
1038 /** The SVN revision of the driver.
1039 * This will be set to 0 if not compiled into the driver. */
1040 uint32_t uDriverRevision;
1041 /** Reserved \#1 (will be returned as zero until defined). */
1042 uint32_t uReserved1;
1043 /** Reserved \#2 (will be returned as NULL until defined). */
1044 void RT_FAR *pvReserved2;
1045 } Out;
1046 } u;
1047} VBGLIOCIDCCONNECT, RT_FAR *PVBGLIOCIDCCONNECT;
1048AssertCompileSize(VBGLIOCIDCCONNECT, 24 + 16 + (ARCH_BITS == 64 ? 8 : 4) * 2);
1049#if !defined(__GNUC__) /* Some GCC versions can't handle the complicated RT_UOFFSET_AFTER macro, it seems. */ \
1050 && (!defined(RT_OS_OS2) || (!defined(__IBMC__) && !defined(__IBMCPP__)))
1051AssertCompile(VBGL_IOCTL_IDC_CONNECT_SIZE_IN == 24 + 16);
1052#endif
1053#define VBGL_IOCTL_IDC_CONNECT_MAGIC_COOKIE UINT32_C(0x55aa4d5a) /**< Magic value for doing an IDC connect. */
1054/** @} */
1055
1056
1057/** @name VBGL_IOCL_IDC_DISCONNECT
1058 * IDC client disconnect request.
1059 *
1060 * This will destroy the kernel session associated with the IDC connection.
1061 *
1062 * @note ring-0 only.
1063 */
1064#define VBGL_IOCTL_IDC_DISCONNECT VBGL_IOCTL_CODE_SIZE(62 | VBGL_IOCTL_FLAG_CC, VBGL_IOCTL_IDC_DISCONNECT_SIZE)
1065#define VBGL_IOCTL_IDC_DISCONNECT_SIZE sizeof(VBGLIOCIDCDISCONNECT)
1066#define VBGL_IOCTL_IDC_DISCONNECT_SIZE_IN sizeof(VBGLIOCIDCDISCONNECT)
1067#define VBGL_IOCTL_IDC_DISCONNECT_SIZE_OUT sizeof(VBGLREQHDR)
1068typedef struct VBGLIOCIDCDISCONNECT
1069{
1070 /** The header. */
1071 VBGLREQHDR Hdr;
1072 union
1073 {
1074 struct
1075 {
1076 /** The session handle for platforms where this is needed. */
1077#if ARCH_BITS >= 32
1078 void RT_FAR *pvSession;
1079#else
1080 uint32_t pvSession;
1081#endif
1082 } In;
1083 } u;
1084} VBGLIOCIDCDISCONNECT, RT_FAR *PVBGLIOCIDCDISCONNECT;
1085AssertCompileSize(VBGLIOCIDCDISCONNECT, 24 + (ARCH_BITS == 64 ? 8 : 4));
1086/** @} */
1087
1088
1089#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
1090RT_C_DECLS_BEGIN
1091/**
1092 * The VBoxGuest IDC entry point.
1093 *
1094 * @returns VBox status code.
1095 * @param pvSession The session.
1096 * @param uReq The request code.
1097 * @param pReqHdr The request.
1098 * @param cbReq The request size.
1099 */
1100int VBOXCALL VBoxGuestIDC(void RT_FAR *pvSession, uintptr_t uReq, PVBGLREQHDR pReqHdr, size_t cbReq);
1101RT_C_DECLS_END
1102#endif
1103
1104
1105#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
1106
1107/* Private IOCtls between user space and the kernel video driver. DRM private
1108 * IOCtls always have the type 'd' and a number between 0x40 and 0x99 (0x9F?) */
1109
1110# define VBOX_DRM_IOCTL(a) (0x40 + DRM_VBOX_ ## a)
1111
1112/** Stop using HGSMI in the kernel driver until it is re-enabled, so that a
1113 * user-space driver can use it. It must be re-enabled before the kernel
1114 * driver can be used again in a sensible way. */
1115/** @note These IOCtls was removed from the code, but are left here as
1116 * templates as we may need similar ones in future. */
1117# define DRM_VBOX_DISABLE_HGSMI 0
1118# define DRM_IOCTL_VBOX_DISABLE_HGSMI VBOX_DRM_IOCTL(DISABLE_HGSMI)
1119# define VBOXVIDEO_IOCTL_DISABLE_HGSMI _IO('d', DRM_IOCTL_VBOX_DISABLE_HGSMI)
1120/** Enable HGSMI in the kernel driver after it was previously disabled. */
1121# define DRM_VBOX_ENABLE_HGSMI 1
1122# define DRM_IOCTL_VBOX_ENABLE_HGSMI VBOX_DRM_IOCTL(ENABLE_HGSMI)
1123# define VBOXVIDEO_IOCTL_ENABLE_HGSMI _IO('d', DRM_IOCTL_VBOX_ENABLE_HGSMI)
1124
1125#endif /* RT_OS_LINUX || RT_OS_SOLARIS || RT_OS_FREEBSD */
1126
1127#endif /* !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT) */
1128
1129/** @} */
1130
1131/** @} */
1132#endif
1133
Note: See TracBrowser for help on using the repository browser.

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