VirtualBox

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

Last change on this file since 27615 was 27615, checked in by vboxsync, 15 years ago

include,tools/env.sh: applying sparc patches.

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