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