VirtualBox

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

Last change on this file since 21227 was 21227, checked in by vboxsync, 16 years ago

VBoxGuest.h/VMMDev.h/VBoxGuestLib.h usage cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.0 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-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
28 * Clara, CA 95054 USA or visit http://www.sun.com if you need
29 * additional information or have any questions.
30 */
31
32#ifndef ___VBox_VBoxGuest_h
33#define ___VBox_VBoxGuest_h
34
35#include <VBox/cdefs.h>
36#include <VBox/types.h>
37#include <iprt/assert.h>
38#include <VBox/VMMDev2.h>
39#include <VBox/VBoxGuest2.h>
40#if 0
41#include <VBox/VMMDev.h> /* Temporarily. */
42#endif
43
44
45/** @defgroup grp_vboxguest VirtualBox Guest Additions Driver Interface
46 * @{
47 */
48
49/** @todo it would be nice if we could have two define without paths. */
50
51/** @def VBOXGUEST_DEVICE_NAME
52 * The support device name. */
53/** @def VBOXGUEST_USER_DEVICE_NAME
54 * The support device name of the user accessible device node. */
55
56#if defined(RT_OS_OS2)
57# define VBOXGUEST_DEVICE_NAME "\\Dev\\VBoxGst$"
58
59#elif defined(RT_OS_WINDOWS)
60# define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
61
62/** The support service name. */
63# define VBOXGUEST_SERVICE_NAME "VBoxGuest"
64/** Global name for Win2k+ */
65# define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
66/** Win32 driver name */
67# define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
68/** Device name. */
69# define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
70
71#elif defined(RT_OS_LINUX) && !defined(VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX)
72# define VBOXGUEST_DEVICE_NAME "/dev/vboxadd"
73# define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxuser"
74
75#else /* PORTME */
76# define VBOXGUEST_DEVICE_NAME "/dev/vboxguest"
77# if defined(RT_OS_LINUX)
78# define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxuser"
79# endif
80#endif
81
82#ifndef VBOXGUEST_USER_DEVICE_NAME
83# define VBOXGUEST_USER_DEVICE_NAME VBOXGUEST_DEVICE_NAME
84#endif
85
86/** Fictive start address of the hypervisor physical memory for MmMapIoSpace. */
87#define VBOXGUEST_HYPERVISOR_PHYSICAL_START UINT32_C(0xf8000000)
88
89
90#if !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT)
91/** @name VBoxGuest IOCTL codes and structures.
92 *
93 * The range 0..15 is for basic driver communication.
94 * The range 16..31 is for HGCM communcation.
95 * The range 32..47 is reserved for future use.
96 * The range 48..63 is for OS specific communcation.
97 * The 7th bit is reserved for future hacks.
98 * The 8th bit is reserved for distinguishing between 32-bit and 64-bit
99 * processes in future 64-bit guest additions.
100 *
101 * @remarks When creating new IOCtl interfaces keep in mind that not all OSes supports
102 * reporting back the output size. (This got messed up a little bit in VBoxDrv.)
103 *
104 * The request size is also a little bit tricky as it's passed as part of the
105 * request code on unix. The size field is 14 bits on Linux, 12 bits on *BSD,
106 * 13 bits Darwin, and 8-bits on Solaris. All the BSDs and Darwin kernels
107 * will make use of the size field, while Linux and Solaris will not. We're of
108 * course using the size to validate and/or map/lock the request, so it has
109 * to be valid.
110 *
111 * For Solaris we will have to do something special though, 255 isn't
112 * sufficent for all we need. A 4KB restriction (BSD) is probably not
113 * too problematic (yet) as a general one.
114 *
115 * More info can be found in SUPDRVIOC.h and related sources.
116 *
117 * @remarks If adding interfaces that only has input or only has output, some new macros
118 * needs to be created so the most efficient IOCtl data buffering method can be
119 * used.
120 * @{
121 */
122#ifdef RT_ARCH_AMD64
123# define VBOXGUEST_IOCTL_FLAG 128
124#elif defined(RT_ARCH_X86)
125# define VBOXGUEST_IOCTL_FLAG 0
126#else
127# error "dunno which arch this is!"
128#endif
129
130/** Ring-3 request wrapper for big requests.
131 *
132 * This is necessary because the ioctl number scheme on many Unixy OSes (esp. Solaris)
133 * only allows a relatively small size to be encoded into the request. So, for big
134 * request this generic form is used instead. */
135typedef struct VBGLBIGREQ
136{
137 /** Magic value (VBGLBIGREQ_MAGIC). */
138 uint32_t u32Magic;
139 /** The size of the data buffer. */
140 uint32_t cbData;
141 /** The user address of the data buffer. */
142 RTR3PTR pvDataR3;
143#if HC_ARCH_BITS == 32
144 uint32_t u32Padding;
145#endif
146/** @todo r=bird: We need a 'rc' field for passing VBox status codes. Reused
147 * some input field as rc on output. */
148} VBGLBIGREQ;
149/** Pointer to a request wrapper for solaris guests. */
150typedef VBGLBIGREQ *PVBGLBIGREQ;
151/** Pointer to a const request wrapper for solaris guests. */
152typedef const VBGLBIGREQ *PCVBGLBIGREQ;
153
154/** The VBGLBIGREQ::u32Magic value (Ryuu Murakami). */
155#define VBGLBIGREQ_MAGIC 0x19520219
156
157
158#if defined(RT_OS_WINDOWS)
159/* @todo Remove IOCTL_CODE later! Integrate it in VBOXGUEST_IOCTL_CODE below. */
160/** @todo r=bird: IOCTL_CODE is supposedly defined in some header included by Windows.h or ntddk.h, which is why it wasn't in the #if 0 earlier. See HostDrivers/Support/SUPDrvIOC.h... */
161# define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
162 ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
163# define VBOXGUEST_IOCTL_CODE_(Function, Size) IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
164# define VBOXGUEST_IOCTL_STRIP_SIZE_(Code) (Code)
165
166#elif defined(RT_OS_OS2)
167 /* No automatic buffering, size not encoded. */
168# define VBOXGUEST_IOCTL_CATEGORY 0xc2
169# define VBOXGUEST_IOCTL_CODE_(Function, Size) ((unsigned char)(Function))
170# define VBOXGUEST_IOCTL_CATEGORY_FAST 0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
171# define VBOXGUEST_IOCTL_CODE_FAST_(Function) ((unsigned char)(Function))
172# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) (Code)
173
174#elif defined(RT_OS_SOLARIS)
175 /* No automatic buffering, size limited to 255 bytes => use VBGLBIGREQ for everything. */
176# include <sys/ioccom.h>
177# define VBOXGUEST_IOCTL_CODE_(Function, Size) _IOWRN('V', (Function), sizeof(VBGLBIGREQ))
178# define VBOXGUEST_IOCTL_CODE_FAST_(Function) _IO( 'V', (Function))
179# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) (Code)
180
181#elif defined(RT_OS_LINUX)
182 /* No automatic buffering, size limited to 16KB. */
183# include <linux/ioctl.h>
184# define VBOXGUEST_IOCTL_CODE_(Function, Size) _IOC(_IOC_READ|_IOC_WRITE, 'V', (Function), (Size))
185# define VBOXGUEST_IOCTL_CODE_FAST_(Function) _IO( 'V', (Function))
186# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) VBOXGUEST_IOCTL_CODE_(_IOC_NR((Code)), 0)
187
188#elif defined(RT_OS_FREEBSD) /** @todo r=bird: Please do it like SUPDRVIOC to keep it as similar as possible. */
189# include <sys/ioccom.h>
190
191# define VBOXGUEST_IOCTL_CODE_(Function, Size) _IOWR('V', (Function), VBGLBIGREQ)
192# define VBOXGUEST_IOCTL_CODE_FAST_(Function) _IO( 'V', (Function))
193# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) IOCBASECMD(Code)
194
195#else
196/* PORTME */
197#endif
198
199#define VBOXGUEST_IOCTL_CODE(Function, Size) VBOXGUEST_IOCTL_CODE_((Function) | VBOXGUEST_IOCTL_FLAG, Size)
200#define VBOXGUEST_IOCTL_CODE_FAST(Function) VBOXGUEST_IOCTL_CODE_FAST_((Function) | VBOXGUEST_IOCTL_FLAG)
201
202/* Define 32 bit codes to support 32 bit applications requests in the 64 bit guest driver. */
203#ifdef RT_ARCH_AMD64
204# define VBOXGUEST_IOCTL_CODE_32(Function, Size) VBOXGUEST_IOCTL_CODE_(Function, Size)
205# define VBOXGUEST_IOCTL_CODE_FAST_32(Function) VBOXGUEST_IOCTL_CODE_FAST_(Function)
206#endif /* RT_ARCH_AMD64 */
207
208
209
210/** IOCTL to VBoxGuest to query the VMMDev IO port region start.
211 * @remarks Ring-0 only. */
212#define VBOXGUEST_IOCTL_GETVMMDEVPORT VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
213
214#pragma pack(4)
215typedef struct VBoxGuestPortInfo
216{
217 uint32_t portAddress;
218 struct VMMDevMemory *pVMMDevMemory;
219} VBoxGuestPortInfo;
220
221
222/** IOCTL to VBoxGuest to wait for a VMMDev host notification */
223#define VBOXGUEST_IOCTL_WAITEVENT VBOXGUEST_IOCTL_CODE_(2, sizeof(VBoxGuestWaitEventInfo))
224
225/** @name Result codes for VBoxGuestWaitEventInfo::u32Result
226 * @{
227 */
228/** Successful completion, an event occured. */
229#define VBOXGUEST_WAITEVENT_OK (0)
230/** Successful completion, timed out. */
231#define VBOXGUEST_WAITEVENT_TIMEOUT (1)
232/** Wait was interrupted. */
233#define VBOXGUEST_WAITEVENT_INTERRUPTED (2)
234/** An error occured while processing the request. */
235#define VBOXGUEST_WAITEVENT_ERROR (3)
236/** @} */
237
238/** Input and output buffers layout of the IOCTL_VBOXGUEST_WAITEVENT */
239typedef struct VBoxGuestWaitEventInfo
240{
241 /** timeout in milliseconds */
242 uint32_t u32TimeoutIn;
243 /** events to wait for */
244 uint32_t u32EventMaskIn;
245 /** result code */
246 uint32_t u32Result;
247 /** events occured */
248 uint32_t u32EventFlagsOut;
249} VBoxGuestWaitEventInfo;
250AssertCompileSize(VBoxGuestWaitEventInfo, 16);
251
252
253/** IOCTL to VBoxGuest to interrupt (cancel) any pending WAITEVENTs and return.
254 * Handled inside the guest additions and not seen by the host at all.
255 * @see VBOXGUEST_IOCTL_WAITEVENT */
256#define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS VBOXGUEST_IOCTL_CODE_(5, 0)
257
258
259
260/** IOCTL to VBoxGuest to perform a VMM request
261 * @remark The data buffer for this IOCtl has an variable size, keep this in mind
262 * on systems where this matters. */
263#define VBOXGUEST_IOCTL_VMMREQUEST(Size) VBOXGUEST_IOCTL_CODE_(3, (Size))
264
265
266/** IOCTL to VBoxGuest to control event filter mask. */
267#define VBOXGUEST_IOCTL_CTL_FILTER_MASK VBOXGUEST_IOCTL_CODE_(4, sizeof(VBoxGuestFilterMaskInfo))
268
269/** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
270typedef struct VBoxGuestFilterMaskInfo
271{
272 uint32_t u32OrMask;
273 uint32_t u32NotMask;
274} VBoxGuestFilterMaskInfo;
275AssertCompileSize(VBoxGuestFilterMaskInfo, 8);
276#pragma pack()
277
278
279/** IOCTL to VBoxGuest to check memory ballooning. */
280#define VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK VBOXGUEST_IOCTL_CODE_(7, 100)
281
282
283/** IOCTL to VBoxGuest to perform backdoor logging.
284 * The argument is a string buffer of the specified size. */
285#define VBOXGUEST_IOCTL_LOG(Size) VBOXGUEST_IOCTL_CODE_(6, (Size))
286
287
288#ifdef VBOX_WITH_HGCM
289/** IOCTL to VBoxGuest to connect to a HGCM service. */
290# define VBOXGUEST_IOCTL_HGCM_CONNECT VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
291
292/** IOCTL to VBoxGuest to disconnect from a HGCM service. */
293# define VBOXGUEST_IOCTL_HGCM_DISCONNECT VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
294
295/** IOCTL to VBoxGuest to make a call to a HGCM service.
296 * @see VBoxGuestHGCMCallInfo */
297# define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18, (Size))
298
299/** IOCTL to VBoxGuest to make a timed call to a HGCM service. */
300# define VBOXGUEST_IOCTL_HGCM_CALL_TIMED(Size) VBOXGUEST_IOCTL_CODE(20, (Size))
301
302# ifdef RT_ARCH_AMD64
303/** @name IOCTL numbers that 32-bit clients, like the Windows OpenGL guest
304 * driver, will use when taking to a 64-bit driver.
305 * @remarks These are only used by the driver implementation! */
306# define VBOXGUEST_IOCTL_HGCM_CONNECT_32 VBOXGUEST_IOCTL_CODE_32(16, sizeof(VBoxGuestHGCMConnectInfo))
307# define VBOXGUEST_IOCTL_HGCM_DISCONNECT_32 VBOXGUEST_IOCTL_CODE_32(17, sizeof(VBoxGuestHGCMDisconnectInfo))
308# define VBOXGUEST_IOCTL_HGCM_CALL_32(Size) VBOXGUEST_IOCTL_CODE_32(18, (Size))
309# define VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(Size) VBOXGUEST_IOCTL_CODE_32(20, (Size))
310/** @} */
311# endif /* RT_ARCH_AMD64 */
312
313/** Get the pointer to the first HGCM parameter. */
314# define VBOXGUEST_HGCM_CALL_PARMS(a) ( (HGCMFunctionParameter *)((uint8_t *)(a) + sizeof(VBoxGuestHGCMCallInfo)) )
315/** Get the pointer to the first HGCM parameter in a 32-bit request. */
316# define VBOXGUEST_HGCM_CALL_PARMS32(a) ( (HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof(VBoxGuestHGCMCallInfo)) )
317
318/** IOCTL to VBoxGuest to make a connect to the clipboard service.
319 * @todo Seems this is no longer is use. Try remove it. */
320# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CODE_(19, sizeof(uint32_t))
321
322#endif /* VBOX_WITH_HGCM */
323
324
325#ifdef RT_OS_OS2
326
327/**
328 * The data buffer layout for the IDC entry point (AttachDD).
329 *
330 * @remark This is defined in multiple 16-bit headers / sources.
331 * Some places it's called VBGOS2IDC to short things a bit.
332 */
333typedef struct VBOXGUESTOS2IDCCONNECT
334{
335 /** VMMDEV_VERSION. */
336 uint32_t u32Version;
337 /** Opaque session handle. */
338 uint32_t u32Session;
339
340 /**
341 * The 32-bit service entry point.
342 *
343 * @returns VBox status code.
344 * @param u32Session The above session handle.
345 * @param iFunction The requested function.
346 * @param pvData The input/output data buffer. The caller ensures that this
347 * cannot be swapped out, or that it's acceptable to take a
348 * page in fault in the current context. If the request doesn't
349 * take input or produces output, apssing NULL is okay.
350 * @param cbData The size of the data buffer.
351 * @param pcbDataReturned Where to store the amount of data that's returned.
352 * This can be NULL if pvData is NULL.
353 */
354 DECLCALLBACKMEMBER(int, pfnServiceEP)(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned);
355
356 /** The 16-bit service entry point for C code (cdecl).
357 *
358 * It's the same as the 32-bit entry point, but the types has
359 * changed to 16-bit equivalents.
360 *
361 * @code
362 * int far cdecl
363 * VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction,
364 * void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);
365 * @endcode
366 */
367 RTFAR16 fpfnServiceEP;
368
369 /** The 16-bit service entry point for Assembly code (register).
370 *
371 * This is just a wrapper around fpfnServiceEP to simplify calls
372 * from 16-bit assembly code.
373 *
374 * @returns (e)ax: VBox status code; cx: The amount of data returned.
375 *
376 * @param u32Session eax - The above session handle.
377 * @param iFunction dl - The requested function.
378 * @param pvData es:bx - The input/output data buffer.
379 * @param cbData cx - The size of the data buffer.
380 */
381 RTFAR16 fpfnServiceAsmEP;
382} VBOXGUESTOS2IDCCONNECT;
383/** Pointer to VBOXGUESTOS2IDCCONNECT buffer. */
384typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUESTOS2IDCCONNECT;
385
386/** OS/2 specific: IDC client disconnect request.
387 *
388 * This takes no input and it doesn't return anything. Obviously this
389 * is only recognized if it arrives thru the IDC service EP.
390 */
391# define VBOXGUEST_IOCTL_OS2_IDC_DISCONNECT VBOXGUEST_IOCTL_CODE(48, sizeof(uint32_t))
392
393#endif /* RT_OS_OS2 */
394
395/** @} */
396#endif /* !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT) */
397
398
399#if 0 /*def IN_RING3*/
400# include <VBox/VBoxGuestLib.h> /** @todo eliminate this. */
401#endif /* IN_RING3 */
402
403#endif
404
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