VirtualBox

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

Last change on this file since 2135 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/** @file
2 * VBoxGuestLib - Support library header for VirtualBox
3 * Additions: Public header.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef __VBox_VBoxGuestLib_h__
23#define __VBox_VBoxGuestLib_h__
24
25#include <VBox/VBoxGuest.h>
26
27#include <VBox/err.h>
28
29#ifndef IN_RING0
30#error VBoxGuestLib is only suitable for ring-0!
31#endif
32
33/** @defgroup grp_guest_lib VirtualBox Guest Library
34 * @{
35 */
36
37/** @page pg_guest_lib VirtualBox Guest Library
38 *
39 * The library has 2 versions for each platform:
40 * 1) for VBoxGuest main driver, who is responsible for managing the VMMDev virtual hardware;
41 * 2) for other guest drivers.
42 *
43 * Library therefore consists of:
44 * common code to be used by both VBoxGuest and other drivers;
45 * VBoxGuest specific code;
46 * code for other drivers which communicate with VBoxGuest via an IOCTL.
47 *
48 * The library sources produce 2 libs VBoxGuestLib and VBoxGuestLibBase,
49 * the latter one is for VBoxGuest.
50 *
51 * Drivers must choose right library in their makefiles.
52 *
53 * Library source code and the header have a define VBGL_VBOXGUEST,
54 * which is defined for VBoxGuest and undefined for other drivers.
55 *
56 */
57
58#define DECLVBGL(type) type VBOXCALL
59
60typedef uint32_t VBGLIOPORT;
61
62__BEGIN_DECLS
63
64#ifdef VBGL_VBOXGUEST
65
66/**
67 * The library initialization function to be used by the main
68 * VBoxGuest system driver.
69 *
70 * @return VBox status code.
71 */
72DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory);
73
74#else
75
76/**
77 * The library initialization function to be used by all drivers
78 * other than the main VBoxGuest system driver.
79 *
80 * @return VBox status code.
81 */
82DECLVBGL(int) VbglInit (void);
83
84#endif
85
86/**
87 * The library termination function.
88 */
89DECLVBGL(void) VbglTerminate (void);
90
91/** @name Generic request functions.
92 * @{
93 */
94
95/**
96 * Allocate memory for generic request and initialize the request header.
97 *
98 * @param ppReq pointer to resulting memory address.
99 * @param cbSize size of memory block required for the request.
100 * @param reqType the generic request type.
101 *
102 * @return VBox status code.
103 */
104DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType);
105
106/**
107 * Perform the generic request.
108 *
109 * @param pReq pointer the request structure.
110 *
111 * @return VBox status code.
112 */
113DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq);
114
115/**
116 * Free the generic request memory.
117 *
118 * @param pReq pointer the request structure.
119 *
120 * @return VBox status code.
121 */
122DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq);
123/** @} */
124
125#ifdef VBOX_HGCM
126
127#ifdef VBGL_VBOXGUEST
128
129/**
130 * Callback function called from HGCM helpers when a wait for request
131 * completion IRQ is required.
132 *
133 * @param pvData VBoxGuest pointer to be passed to callback.
134 * @param u32Data VBoxGuest 32 bit value to be passed to callback.
135 */
136
137typedef DECLVBGL(void) VBGLHGCMCALLBACK(VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data);
138
139/**
140 * Perform a connect request. That is locate required service and
141 * obtain a client identifier for future access.
142 *
143 * @param pConnectInfo The request data.
144 * @param pAsyncCallback Required pointer to function that is called when
145 * host returns VINF_HGCM_ASYNC_EXECUTE. VBoxGuest
146 * implements waiting for an IRQ in this function.
147 * @param pvAsyncData An arbitrary VBoxGuest pointer to be passed to callback.
148 * @param u32AsyncData An arbitrary VBoxGuest 32 bit value to be passed to callback.
149 *
150 * @return VBox status code.
151 */
152
153DECLVBGL(int) VbglHGCMConnect (VBoxGuestHGCMConnectInfo *pConnectInfo,
154 VBGLHGCMCALLBACK *pAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
155
156
157/**
158 * Perform a disconnect request. That is tell the host that
159 * the client will not call the service anymore.
160 *
161 * @param pDisconnectInfo The request data.
162 * @param pAsyncCallback Required pointer to function that is called when
163 * host returns VINF_HGCM_ASYNC_EXECUTE. VBoxGuest
164 * implements waiting for an IRQ in this function.
165 * @param pvAsyncData An arbitrary VBoxGuest pointer to be passed to callback.
166 * @param u32AsyncData An arbitrary VBoxGuest 32 bit value to be passed to callback.
167 *
168 * @return VBox status code.
169 */
170
171DECLVBGL(int) VbglHGCMDisconnect (VBoxGuestHGCMDisconnectInfo *pDisconnectInfo,
172 VBGLHGCMCALLBACK *pAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
173
174/* Call a HGCM service.
175 *
176 * @param pCallInfo The request data.
177 * @param pAsyncCallback Required pointer to function that is called when
178 * host returns VINF_HGCM_ASYNC_EXECUTE. VBoxGuest
179 * implements waiting for an IRQ in this function.
180 * @param pvAsyncData An arbitrary VBoxGuest pointer to be passed to callback.
181 * @param u32AsyncData An arbitrary VBoxGuest 32 bit value to be passed to callback.
182 *
183 * @return VBox status code.
184 */
185DECLVBGL(int) VbglHGCMCall (VBoxGuestHGCMCallInfo *pCallInfo,
186 VBGLHGCMCALLBACK *pAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData);
187
188#else
189
190struct VBGLHGCMHANDLEDATA;
191typedef struct VBGLHGCMHANDLEDATA *VBGLHGCMHANDLE;
192
193/** @name HGCM functions
194 * @{
195 */
196
197/**
198 * Connect to a service.
199 *
200 * @param pHandle Pointer to variable that will hold a handle to be used
201 * further in VbglHGCMCall and VbglHGCMClose.
202 * @param pData Connection information structure.
203 *
204 * @return VBox status code.
205 */
206DECLVBGL(int) VbglHGCMConnect (VBGLHGCMHANDLE *pHandle, VBoxGuestHGCMConnectInfo *pData);
207
208/**
209 * Connect to a service.
210 *
211 * @param handle Handle of the connection.
212 * @param pData Disconnect request information structure.
213 *
214 * @return VBox status code.
215 */
216DECLVBGL(int) VbglHGCMDisconnect (VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData);
217
218/**
219 * Call to a service.
220 *
221 * @param handle Handle of the connection.
222 * @param pData Call request information structure, including function parameters.
223 * @param cbData Length in bytes of data.
224 *
225 * @return VBox status code.
226 */
227DECLVBGL(int) VbglHGCMCall (VBGLHGCMHANDLE handle, VBoxGuestHGCMCallInfo *pData, uint32_t cbData);
228/** @} */
229
230#endif /* VBGL_VBOXGUEST */
231
232#endif /* VBOX_HGCM */
233
234
235/**
236 * Initialize the heap.
237 *
238 * @return VBox error code.
239 */
240DECLVBGL(int) VbglPhysHeapInit (void);
241
242/**
243 * Shutdown the heap.
244 */
245DECLVBGL(void) VbglPhysHeapTerminate (void);
246
247
248/**
249 * Allocate a memory block.
250 *
251 * @param cbSize Size of block to be allocated.
252 * @return Virtual address of allocated memory block.
253 */
254DECLVBGL(void *) VbglPhysHeapAlloc (uint32_t cbSize);
255
256/**
257 * Get physical address of memory block pointed by
258 * the virtual address.
259 *
260 * @note WARNING!
261 * The function does not acquire the Heap mutex!
262 * When calling the function make sure that
263 * the pointer is a valid one and is not being
264 * deallocated.
265 * This function can NOT be used for verifying
266 * if the given pointer is a valid one allocated
267 * from the heap.
268 *
269 *
270 * @param p Virtual address of memory block.
271 * @return Physical memory block.
272 */
273DECLVBGL(RTCCPHYS) VbglPhysHeapGetPhysAddr (void *p);
274
275/**
276 * Free a memory block.
277 *
278 * @param p Virtual address of memory block.
279 */
280DECLVBGL(void) VbglPhysHeapFree (void *p);
281
282DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory);
283
284__END_DECLS
285
286/** @} */
287
288#endif /* __VBox_VBoxGuestLib_h__ */
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