VirtualBox

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

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

merging vbglioc r117730: solaris adjustments.

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