]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - ubuntu/vbox/vboxguest/VBGLInternal.h
UBUNTU: vbox-update: Fix up KERN_DIR definitions
[mirror_ubuntu-bionic-kernel.git] / ubuntu / vbox / vboxguest / VBGLInternal.h
1 /* $Id: VBGLInternal.h $ */
2 /** @file
3 * VBoxGuestLibR0 - Internal header.
4 */
5
6 /*
7 * Copyright (C) 2006-2016 Oracle Corporation
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 (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.
16 *
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.
22 *
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.
25 */
26
27 #ifndef ___VBoxGuestLib_VBGLInternal_h
28 #define ___VBoxGuestLib_VBGLInternal_h
29
30 #include <VBox/VMMDev.h>
31 #include <VBox/VBoxGuest.h>
32 #include <VBox/VBoxGuestLib.h>
33
34 #include <VBox/log.h>
35
36
37 #ifdef RT_OS_WINDOWS /** @todo dprintf() -> Log() */
38 # if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
39 # define dprintf(a) RTLogBackdoorPrintf a
40 # else
41 # define dprintf(a) do {} while (0)
42 # endif
43 #else
44 # define dprintf(a) Log(a)
45 #endif
46
47 #include "SysHlp.h"
48
49 struct _VBGLPHYSHEAPBLOCK;
50 typedef struct _VBGLPHYSHEAPBLOCK VBGLPHYSHEAPBLOCK;
51 struct _VBGLPHYSHEAPCHUNK;
52 typedef struct _VBGLPHYSHEAPCHUNK VBGLPHYSHEAPCHUNK;
53
54 #ifndef VBGL_VBOXGUEST
55 struct VBGLHGCMHANDLEDATA
56 {
57 uint32_t fAllocated;
58 VBGLDRIVER driver;
59 };
60 #endif
61
62 enum VbglLibStatus
63 {
64 VbglStatusNotInitialized = 0,
65 VbglStatusInitializing,
66 VbglStatusReady
67 };
68
69 /**
70 * Global VBGL ring-0 data.
71 * Lives in VbglR0Init.cpp.
72 */
73 typedef struct VBGLDATA
74 {
75 enum VbglLibStatus status;
76
77 RTIOPORT portVMMDev;
78
79 VMMDevMemory *pVMMDevMemory;
80
81 /**
82 * Physical memory heap data.
83 * @{
84 */
85
86 VBGLPHYSHEAPBLOCK *pFreeBlocksHead;
87 VBGLPHYSHEAPBLOCK *pAllocBlocksHead;
88 VBGLPHYSHEAPCHUNK *pChunkHead;
89
90 RTSEMFASTMUTEX mutexHeap;
91 /** @} */
92
93 /**
94 * The host version data.
95 */
96 VMMDevReqHostVersion hostVersion;
97
98
99 #ifndef VBGL_VBOXGUEST
100 /**
101 * Handle for the main driver instance.
102 * @{
103 */
104
105 RTSEMMUTEX mutexDriverInit;
106
107 VBGLDRIVER driver;
108
109 /** @} */
110
111 /**
112 * Fast heap for HGCM handles data.
113 * @{
114 */
115
116 RTSEMFASTMUTEX mutexHGCMHandle;
117
118 struct VBGLHGCMHANDLEDATA aHGCMHandleData[64];
119
120 /** @} */
121 #endif
122 } VBGLDATA;
123
124
125 #ifndef VBGL_DECL_DATA
126 extern VBGLDATA g_vbgldata;
127 #endif
128
129 /**
130 * Internal macro for checking whether we can pass physical page lists to the
131 * host.
132 *
133 * ASSUMES that vbglR0Enter has been called already.
134 *
135 * @param a_fLocked For the windows shared folders workarounds.
136 *
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.
140 */
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) )
144 #else
145 # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
146 ( !!(g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
147 #endif
148
149 int vbglR0Enter (void);
150
151 #ifdef VBOX_WITH_HGCM
152 # ifndef VBGL_VBOXGUEST
153 int vbglR0HGCMInit(void);
154 int vbglR0HGCMTerminate(void);
155 # endif
156 struct VBGLHGCMHANDLEDATA *vbglHGCMHandleAlloc(void);
157 void vbglHGCMHandleFree(struct VBGLHGCMHANDLEDATA *pHandle);
158 #endif /* VBOX_WITH_HGCM */
159
160 #ifndef VBGL_VBOXGUEST
161 /**
162 * Get a handle to the main VBoxGuest driver.
163 * @returns VERR_TRY_AGAIN if the main driver has not yet been loaded.
164 */
165 int vbglGetDriver(VBGLDRIVER **ppDriver);
166 #endif
167
168 #endif /* !___VBoxGuestLib_VBGLInternal_h */
169