1 /* $Id: VBGLInternal.h $ */
3 * VBoxGuestLibR0 - Internal header.
7 * Copyright (C) 2006-2016 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
27 #ifndef ___VBoxGuestLib_VBGLInternal_h
28 #define ___VBoxGuestLib_VBGLInternal_h
30 #include <VBox/VMMDev.h>
31 #include <VBox/VBoxGuest.h>
32 #include <VBox/VBoxGuestLib.h>
37 #ifdef RT_OS_WINDOWS /** @todo dprintf() -> Log() */
38 # if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
39 # define dprintf(a) RTLogBackdoorPrintf a
41 # define dprintf(a) do {} while (0)
44 # define dprintf(a) Log(a)
49 struct _VBGLPHYSHEAPBLOCK
;
50 typedef struct _VBGLPHYSHEAPBLOCK VBGLPHYSHEAPBLOCK
;
51 struct _VBGLPHYSHEAPCHUNK
;
52 typedef struct _VBGLPHYSHEAPCHUNK VBGLPHYSHEAPCHUNK
;
54 #ifndef VBGL_VBOXGUEST
55 struct VBGLHGCMHANDLEDATA
64 VbglStatusNotInitialized
= 0,
65 VbglStatusInitializing
,
70 * Global VBGL ring-0 data.
71 * Lives in VbglR0Init.cpp.
73 typedef struct VBGLDATA
75 enum VbglLibStatus status
;
79 VMMDevMemory
*pVMMDevMemory
;
82 * Physical memory heap data.
86 VBGLPHYSHEAPBLOCK
*pFreeBlocksHead
;
87 VBGLPHYSHEAPBLOCK
*pAllocBlocksHead
;
88 VBGLPHYSHEAPCHUNK
*pChunkHead
;
90 RTSEMFASTMUTEX mutexHeap
;
94 * The host version data.
96 VMMDevReqHostVersion hostVersion
;
99 #ifndef VBGL_VBOXGUEST
101 * Handle for the main driver instance.
105 RTSEMMUTEX mutexDriverInit
;
112 * Fast heap for HGCM handles data.
116 RTSEMFASTMUTEX mutexHGCMHandle
;
118 struct VBGLHGCMHANDLEDATA aHGCMHandleData
[64];
125 #ifndef VBGL_DECL_DATA
126 extern VBGLDATA g_vbgldata
;
130 * Internal macro for checking whether we can pass physical page lists to the
133 * ASSUMES that vbglR0Enter has been called already.
135 * @param a_fLocked For the windows shared folders workarounds.
137 * @remarks Disabled the PageList feature for locked memory on Windows,
138 * because a new MDL is created by VBGL to get the page addresses
139 * and the pages from the MDL are marked as dirty when they should not.
141 #if defined(RT_OS_WINDOWS)
142 # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
143 ( !(a_fLocked) && (g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
145 # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
146 ( !!(g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
149 int vbglR0Enter (void);
151 #ifdef VBOX_WITH_HGCM
152 # ifndef VBGL_VBOXGUEST
153 int vbglR0HGCMInit(void);
154 int vbglR0HGCMTerminate(void);
156 struct VBGLHGCMHANDLEDATA
*vbglHGCMHandleAlloc(void);
157 void vbglHGCMHandleFree(struct VBGLHGCMHANDLEDATA
*pHandle
);
158 #endif /* VBOX_WITH_HGCM */
160 #ifndef VBGL_VBOXGUEST
162 * Get a handle to the main VBoxGuest driver.
163 * @returns VERR_TRY_AGAIN if the main driver has not yet been loaded.
165 int vbglGetDriver(VBGLDRIVER
**ppDriver
);
168 #endif /* !___VBoxGuestLib_VBGLInternal_h */