VirtualBox

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

Last change on this file since 4878 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

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