VirtualBox

source: vbox/trunk/include/VBox/VBoxGuestLib.h@ 21217

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

VBoxGuest.h,VBoxGuestLib: Moved the VbglR3 API out of VBoxGuest.h and did some cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.8 KB
Line 
1/** @file
2 * VBoxGuestLib - VirtualBox Guest Additions Library.
3 */
4
5/*
6 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_VBoxGuestLib_h
31#define ___VBox_VBoxGuestLib_h
32
33#ifdef IN_RING0
34# include <VBox/VBoxGuest.h> /** @todo Try stop including <VBox/VBoxGuest.h> in ring-0. */
35# include <VBox/err.h> /** @todo Why is this here?? */
36#endif
37#include <VBox/types.h>
38
39
40/** @defgroup grp_guest_lib VirtualBox Guest Additions Library
41 * @{
42 */
43
44/** @page pg_guest_lib VirtualBox Guest Library
45 *
46 * This is a library for abstracting the additions driver interface. There are
47 * multiple versions of the library depending on the context. The main
48 * distinction is between kernel and user mode where the interfaces are very
49 * different.
50 *
51 *
52 * @section sec_guest_lib_ring0 Ring-0
53 *
54 * In ring-0 there are two version:
55 * - VBOX_LIB_VBGL_R0_BASE / VBoxGuestR0LibBase for the VBoxGuest main driver,
56 * who is responsible for managing the VMMDev virtual hardware.
57 * - VBOX_LIB_VBGL_R0 / VBoxGuestR0Lib for other (client) guest drivers.
58 *
59 *
60 * The library source code and the header have a define VBGL_VBOXGUEST, which is
61 * defined for VBoxGuest and undefined for other drivers. Drivers must choose
62 * right library in their makefiles and set VBGL_VBOXGUEST accordingly.
63 *
64 * The libraries consists of:
65 * - common code to be used by both VBoxGuest and other drivers;
66 * - VBoxGuest specific code;
67 * - code for other drivers which communicate with VBoxGuest via an IOCTL.
68 *
69 *
70 * @section sec_guest_lib_ring3 Ring-3
71 *
72 * There are more variants of the library here:
73 * - VBOX_LIB_VBGL_R3 / VBoxGuestR3Lib for programs.
74 * - VBOX_LIB_VBGL_R3_XFREE86 / VBoxGuestR3LibXFree86 for old style XFree
75 * drivers which uses special loader and or symbol resolving strategy.
76 * - VBOX_LIB_VBGL_R3_SHARED / VBoxGuestR3LibShared for shared objects / DLLs /
77 * Dylibs.
78 *
79 */
80
81RT_C_DECLS_BEGIN
82
83
84/** @defgroup grp_guest_lib_r0 Ring-0 interface.
85 * @{
86 */
87#if defined(IN_RING0) && !defined(IN_RING0_AGNOSTIC)
88# define DECLVBGL(type) type VBOXCALL
89
90typedef uint32_t VBGLIOPORT; /**< @todo r=bird: We have RTIOPORT (uint16_t) for this. */
91
92
93# ifdef VBGL_VBOXGUEST
94
95/**
96 * The library initialization function to be used by the main
97 * VBoxGuest system driver.
98 *
99 * @return VBox status code.
100 */
101DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory);
102
103# else
104
105/**
106 * The library initialization function to be used by all drivers
107 * other than the main VBoxGuest system driver.
108 *
109 * @return VBox status code.
110 */
111DECLVBGL(int) VbglInit (void);
112
113# endif
114
115/**
116 * The library termination function.
117 */
118DECLVBGL(void) VbglTerminate (void);
119
120
121/** @name Generic request functions.
122 * @{
123 */
124
125/**
126 * Allocate memory for generic request and initialize the request header.
127 *
128 * @param ppReq pointer to resulting memory address.
129 * @param cbSize size of memory block required for the request.
130 * @param reqType the generic request type.
131 *
132 * @return VBox status code.
133 */
134DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType);
135
136/**
137 * Perform the generic request.
138 *
139 * @param pReq pointer the request structure.
140 *
141 * @return VBox status code.
142 */
143DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq);
144
145/**
146 * Free the generic request memory.
147 *
148 * @param pReq pointer the request structure.
149 *
150 * @return VBox status code.
151 */
152DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq);
153/** @} */
154
155# ifdef VBOX_WITH_HGCM
156
157# ifdef VBGL_VBOXGUEST
158
159/**
160 * Callback function called from HGCM helpers when a wait for request
161 * completion IRQ is required.
162 *
163 * @param pvData VBoxGuest pointer to be passed to callback.
164 * @param u32Data VBoxGuest 32 bit value to be passed to callback.
165 */
166
167typedef DECLVBGL(void) VBGLHGCMCALLBACK(VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data);
168
169/**
170 * Perform a connect request. That is locate required service and
171 * obtain a client identifier for future access.
172 *
173 * @note This function can NOT handle cancelled requests!
174 *
175 * @param pConnectInfo The request data.
176 * @param pAsyncCallback Required pointer to function that is called when
177 * host returns VINF_HGCM_ASYNC_EXECUTE. VBoxGuest
178 * implements waiting for an IRQ in this function.
179 * @param pvAsyncData An arbitrary VBoxGuest pointer to be passed to callback.
180 * @param u32AsyncData An arbitrary VBoxGuest 32 bit value to be passed to callback.
181 *
182 * @return VBox status code.
183 */
184
185DECLVBGL(int) VbglHGCMConnect (VBoxGuestHGCMConnectInfo *pConnectInfo,
186 VBGLHGCMCALLBACK *pAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
187
188
189/**
190 * Perform a disconnect request. That is tell the host that
191 * the client will not call the service anymore.
192 *
193 * @note This function can NOT handle cancelled requests!
194 *
195 * @param pDisconnectInfo The request data.
196 * @param pAsyncCallback Required pointer to function that is called when
197 * host returns VINF_HGCM_ASYNC_EXECUTE. VBoxGuest
198 * implements waiting for an IRQ in this function.
199 * @param pvAsyncData An arbitrary VBoxGuest pointer to be passed to callback.
200 * @param u32AsyncData An arbitrary VBoxGuest 32 bit value to be passed to callback.
201 *
202 * @return VBox status code.
203 */
204
205DECLVBGL(int) VbglHGCMDisconnect (VBoxGuestHGCMDisconnectInfo *pDisconnectInfo,
206 VBGLHGCMCALLBACK *pAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
207
208/** Call a HGCM service.
209 *
210 * @note This function can deal with cancelled requests.
211 *
212 * @param pCallInfo The request data.
213 * @param pAsyncCallback Required pointer to function that is called when
214 * host returns VINF_HGCM_ASYNC_EXECUTE. VBoxGuest
215 * implements waiting for an IRQ in this function.
216 * @param pvAsyncData An arbitrary VBoxGuest pointer to be passed to callback.
217 * @param u32AsyncData An arbitrary VBoxGuest 32 bit value to be passed to callback.
218 *
219 * @return VBox status code.
220 */
221DECLVBGL(int) VbglHGCMCall (VBoxGuestHGCMCallInfo *pCallInfo,
222 VBGLHGCMCALLBACK *pAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
223
224/** Call a HGCM service. (32 bits packet structure in a 64 bits guest)
225 *
226 * @note This function can deal with cancelled requests.
227 *
228 * @param pCallInfo The request data.
229 * @param pAsyncCallback Required pointer to function that is called when
230 * host returns VINF_HGCM_ASYNC_EXECUTE. VBoxGuest
231 * implements waiting for an IRQ in this function.
232 * @param pvAsyncData An arbitrary VBoxGuest pointer to be passed to callback.
233 * @param u32AsyncData An arbitrary VBoxGuest 32 bit value to be passed to callback.
234 *
235 * @return VBox status code.
236 */
237DECLVBGL(int) VbglHGCMCall32 (VBoxGuestHGCMCallInfo *pCallInfo,
238 VBGLHGCMCALLBACK *pAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
239
240# else /* !VBGL_VBOXGUEST */
241
242struct VBGLHGCMHANDLEDATA;
243typedef struct VBGLHGCMHANDLEDATA *VBGLHGCMHANDLE;
244
245/** @name HGCM functions
246 * @{
247 */
248
249/**
250 * Connect to a service.
251 *
252 * @param pHandle Pointer to variable that will hold a handle to be used
253 * further in VbglHGCMCall and VbglHGCMClose.
254 * @param pData Connection information structure.
255 *
256 * @return VBox status code.
257 */
258DECLVBGL(int) VbglHGCMConnect (VBGLHGCMHANDLE *pHandle, VBoxGuestHGCMConnectInfo *pData);
259
260/**
261 * Connect to a service.
262 *
263 * @param handle Handle of the connection.
264 * @param pData Disconnect request information structure.
265 *
266 * @return VBox status code.
267 */
268DECLVBGL(int) VbglHGCMDisconnect (VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData);
269
270/**
271 * Call to a service.
272 *
273 * @param handle Handle of the connection.
274 * @param pData Call request information structure, including function parameters.
275 * @param cbData Length in bytes of data.
276 *
277 * @return VBox status code.
278 */
279DECLVBGL(int) VbglHGCMCall (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
280
281/**
282 * Call to a service with timeout.
283 *
284 * @param handle Handle of the connection.
285 * @param pData Call request information structure, including function parameters.
286 * @param cbData Length in bytes of data.
287 * @param cMillies Timeout in milliseconds. Use RT_INDEFINITE_WAIT to wait forever.
288 *
289 * @return VBox status code.
290 */
291DECLVBGL(int) VbglHGCMCallTimed (VBGLHGCMHANDLE handle,
292 VBoxGuestHGCMCallInfoTimed *pData, uint32_t cbData);
293/** @} */
294
295# endif /* !VBGL_VBOXGUEST */
296
297# endif /* VBOX_WITH_HGCM */
298
299
300/**
301 * Initialize the heap.
302 *
303 * @return VBox error code.
304 */
305DECLVBGL(int) VbglPhysHeapInit (void);
306
307/**
308 * Shutdown the heap.
309 */
310DECLVBGL(void) VbglPhysHeapTerminate (void);
311
312
313/**
314 * Allocate a memory block.
315 *
316 * @param cbSize Size of block to be allocated.
317 * @return Virtual address of allocated memory block.
318 */
319DECLVBGL(void *) VbglPhysHeapAlloc (uint32_t cbSize);
320
321/**
322 * Get physical address of memory block pointed by
323 * the virtual address.
324 *
325 * @note WARNING!
326 * The function does not acquire the Heap mutex!
327 * When calling the function make sure that
328 * the pointer is a valid one and is not being
329 * deallocated.
330 * This function can NOT be used for verifying
331 * if the given pointer is a valid one allocated
332 * from the heap.
333 *
334 *
335 * @param p Virtual address of memory block.
336 * @return Physical memory block.
337 */
338DECLVBGL(RTCCPHYS) VbglPhysHeapGetPhysAddr (void *p);
339
340/**
341 * Free a memory block.
342 *
343 * @param p Virtual address of memory block.
344 */
345DECLVBGL(void) VbglPhysHeapFree (void *p);
346
347DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory);
348
349#endif /* IN_RING0 && !IN_RING0_AGNOSTIC */
350/** @} */
351
352
353/** @defgroup grp_guest_lib_r3 Ring-3 interface.
354 * @{
355 */
356#ifdef IN_RING3
357
358/** @def VBGLR3DECL
359 * Ring 3 VBGL declaration.
360 * @param type The return type of the function declaration.
361 */
362# define VBGLR3DECL(type) type VBOXCALL
363
364/** @name General-purpose functions
365 * @{ */
366VBGLR3DECL(int) VbglR3Init(void);
367VBGLR3DECL(int) VbglR3InitUser(void);
368VBGLR3DECL(void) VbglR3Term(void);
369# ifdef ___iprt_time_h
370VBGLR3DECL(int) VbglR3GetHostTime(PRTTIMESPEC pTime);
371# endif
372VBGLR3DECL(int) VbglR3InterruptEventWaits(void);
373VBGLR3DECL(int) VbglR3WriteLog(const char *pch, size_t cb);
374VBGLR3DECL(int) VbglR3CtlFilterMask(uint32_t fOr, uint32_t fNot);
375VBGLR3DECL(int) VbglR3Daemonize(bool fNoChDir, bool fNoClose);
376VBGLR3DECL(int) VbglR3PidFile(const char *pszPath, PRTFILE phFile);
377VBGLR3DECL(void) VbglR3ClosePidFile(const char *pszPath, RTFILE hFile);
378VBGLR3DECL(int) VbglR3SetGuestCaps(uint32_t fOr, uint32_t fNot);
379/** @} */
380
381/** @name Shared clipboard
382 * @{ */
383VBGLR3DECL(int) VbglR3ClipboardConnect(uint32_t *pu32ClientId);
384VBGLR3DECL(int) VbglR3ClipboardDisconnect(uint32_t u32ClientId);
385VBGLR3DECL(int) VbglR3ClipboardGetHostMsg(uint32_t u32ClientId, uint32_t *pMsg, uint32_t *pfFormats);
386VBGLR3DECL(int) VbglR3ClipboardReadData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb);
387VBGLR3DECL(int) VbglR3ClipboardReportFormats(uint32_t u32ClientId, uint32_t fFormats);
388VBGLR3DECL(int) VbglR3ClipboardWriteData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb);
389/** @} */
390
391/** @name Seamless mode
392 * @{ */
393VBGLR3DECL(int) VbglR3SeamlessSetCap(bool fState);
394# ifdef VBOX_MOUSE_POINTER_SHAPE /** @todo Move common structures/enums out of VBoxGuest.h or/and the externalize the IOCtl interface... Whatever works, just try keep the amout of lowevel mess exposed here to a minimum. */
395VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode);
396# endif
397VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects);
398/** @} */
399
400/** @name Mouse
401 * @{ */
402VBGLR3DECL(int) VbglR3GetMouseStatus(uint32_t *pfFeatures, uint32_t *px, uint32_t *py);
403VBGLR3DECL(int) VbglR3SetMouseStatus(uint32_t fFeatures);
404/** @} */
405
406/** @name Video
407 * @{ */
408VBGLR3DECL(int) VbglR3VideoAccelEnable(bool fEnable);
409VBGLR3DECL(int) VbglR3VideoAccelFlush(void);
410VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg);
411# ifdef VBOX_MOUSE_POINTER_SHAPE /** @todo Move common structures/enums out of VBoxGuest.h or/and the externalize the IOCtl interface... Whatever works, just try keep the amout of lowevel mess exposed here to a minimum. */
412VBGLR3DECL(int) VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq);
413# endif
414/** @} */
415
416/** @name Display
417 * @{ */
418VBGLR3DECL(int) VbglR3GetLastDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay);
419VBGLR3DECL(int) VbglR3DisplayChangeWaitEvent(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay);
420VBGLR3DECL(bool) VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits);
421VBGLR3DECL(int) VbglR3SaveVideoMode(const char *pszName, uint32_t cx, uint32_t cy, uint32_t cBits);
422VBGLR3DECL(int) VbglR3RetrieveVideoMode(const char *pszName, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits);
423/** @} */
424
425# ifdef VBOX_WITH_GUEST_PROPS
426/** @name Guest properties
427 * @{ */
428/** @todo Docs. */
429typedef struct VBGLR3GUESTPROPENUM VBGLR3GUESTPROPENUM;
430/** @todo Docs. */
431typedef VBGLR3GUESTPROPENUM *PVBGLR3GUESTPROPENUM;
432VBGLR3DECL(int) VbglR3GuestPropConnect(uint32_t *pu32ClientId);
433VBGLR3DECL(int) VbglR3GuestPropDisconnect(uint32_t u32ClientId);
434VBGLR3DECL(int) VbglR3GuestPropWrite(uint32_t u32ClientId, const char *pszName, const char *pszValue, const char *pszFlags);
435VBGLR3DECL(int) VbglR3GuestPropWriteValue(uint32_t u32ClientId, const char *pszName, const char *pszValue);
436VBGLR3DECL(int) VbglR3GuestPropWriteValueV(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, va_list va);
437VBGLR3DECL(int) VbglR3GuestPropWriteValueF(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, ...);
438VBGLR3DECL(int) VbglR3GuestPropRead(uint32_t u32ClientId, const char *pszName, void *pvBuf, uint32_t cbBuf, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
439VBGLR3DECL(int) VbglR3GuestPropReadValue(uint32_t ClientId, const char *pszName, char *pszValue, uint32_t cchValue, uint32_t *pcchValueActual);
440VBGLR3DECL(int) VbglR3GuestPropReadValueAlloc(uint32_t u32ClientId, const char *pszName, char **ppszValue);
441VBGLR3DECL(void) VbglR3GuestPropReadValueFree(char *pszValue);
442VBGLR3DECL(int) VbglR3GuestPropEnumRaw(uint32_t u32ClientId, const char *paszPatterns, char *pcBuf, uint32_t cbBuf, uint32_t *pcbBufActual);
443VBGLR3DECL(int) VbglR3GuestPropEnum(uint32_t u32ClientId, char const * const *ppaszPatterns, uint32_t cPatterns, PVBGLR3GUESTPROPENUM *ppHandle,
444 char const **ppszName, char const **ppszValue, uint64_t *pu64Timestamp, char const **ppszFlags);
445VBGLR3DECL(int) VbglR3GuestPropEnumNext(PVBGLR3GUESTPROPENUM pHandle, char const **ppszName, char const **ppszValue, uint64_t *pu64Timestamp,
446 char const **ppszFlags);
447VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle);
448VBGLR3DECL(int) VbglR3GuestPropDelSet(uint32_t u32ClientId, char const * const *papszPatterns, uint32_t cPatterns);
449VBGLR3DECL(int) VbglR3GuestPropWait(uint32_t u32ClientId, const char *pszPatterns, void *pvBuf, uint32_t cbBuf, uint64_t u64Timestamp, uint32_t u32Timeout, char ** ppszName, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual);
450/** @} */
451# endif /* VBOX_WITH_GUEST_PROPS defined */
452
453#endif /* IN_RING3 */
454/** @} */
455
456RT_C_DECLS_END
457
458/** @} */
459
460#endif
461
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use