VirtualBox

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

Last change on this file since 68575 was 68575, checked in by vboxsync, 7 years ago

merging vbglioc r117751: OS/2 mouse driver related changes.

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