VirtualBox

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

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

Adding VBoxGuestCoreTypes.h for avoiding having to include VMMDev.h from VBoxGuestLib.h. Dropped a few unnecessary VMMDev.h includes here and there.

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