VirtualBox

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

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

merging vbglioc r117764: VBoxGuest.h: OS/2 gradd build fix

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