1 | /* Id: 73443 $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestLibR0 - Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2012 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 | #pragma pack(4) /** @todo r=bird: What do we need packing for here? None of these structures are shared between drivers AFAIK. */
|
---|
50 |
|
---|
51 | struct _VBGLPHYSHEAPBLOCK;
|
---|
52 | typedef struct _VBGLPHYSHEAPBLOCK VBGLPHYSHEAPBLOCK;
|
---|
53 | struct _VBGLPHYSHEAPCHUNK;
|
---|
54 | typedef struct _VBGLPHYSHEAPCHUNK VBGLPHYSHEAPCHUNK;
|
---|
55 |
|
---|
56 | #ifndef VBGL_VBOXGUEST
|
---|
57 | struct VBGLHGCMHANDLEDATA
|
---|
58 | {
|
---|
59 | uint32_t fAllocated;
|
---|
60 | VBGLDRIVER driver;
|
---|
61 | };
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | enum VbglLibStatus
|
---|
65 | {
|
---|
66 | VbglStatusNotInitialized = 0,
|
---|
67 | VbglStatusInitializing,
|
---|
68 | VbglStatusReady
|
---|
69 | };
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Global VBGL ring-0 data.
|
---|
73 | * Lives in VbglR0Init.cpp.
|
---|
74 | */
|
---|
75 | typedef struct _VBGLDATA
|
---|
76 | {
|
---|
77 | enum VbglLibStatus status;
|
---|
78 |
|
---|
79 | VBGLIOPORT portVMMDev;
|
---|
80 |
|
---|
81 | VMMDevMemory *pVMMDevMemory;
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Physical memory heap data.
|
---|
85 | * @{
|
---|
86 | */
|
---|
87 |
|
---|
88 | VBGLPHYSHEAPBLOCK *pFreeBlocksHead;
|
---|
89 | VBGLPHYSHEAPBLOCK *pAllocBlocksHead;
|
---|
90 | VBGLPHYSHEAPCHUNK *pChunkHead;
|
---|
91 |
|
---|
92 | RTSEMFASTMUTEX mutexHeap;
|
---|
93 | /** @} */
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * The host version data.
|
---|
97 | */
|
---|
98 | VMMDevReqHostVersion hostVersion;
|
---|
99 |
|
---|
100 |
|
---|
101 | #ifndef VBGL_VBOXGUEST
|
---|
102 | /**
|
---|
103 | * Handle for the main driver instance.
|
---|
104 | * @{
|
---|
105 | */
|
---|
106 |
|
---|
107 | RTSEMFASTMUTEX mutexDriverInit;
|
---|
108 |
|
---|
109 | VBGLDRIVER driver;
|
---|
110 |
|
---|
111 | /** @} */
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Fast heap for HGCM handles data.
|
---|
115 | * @{
|
---|
116 | */
|
---|
117 |
|
---|
118 | RTSEMFASTMUTEX mutexHGCMHandle;
|
---|
119 |
|
---|
120 | struct VBGLHGCMHANDLEDATA aHGCMHandleData[64];
|
---|
121 |
|
---|
122 | /** @} */
|
---|
123 | #endif
|
---|
124 | } VBGLDATA;
|
---|
125 |
|
---|
126 |
|
---|
127 | #pragma pack()
|
---|
128 |
|
---|
129 | #ifndef VBGL_DECL_DATA
|
---|
130 | extern VBGLDATA g_vbgldata;
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Internal macro for checking whether we can pass physical page lists to the
|
---|
135 | * host.
|
---|
136 | *
|
---|
137 | * ASSUMES that vbglR0Enter has been called already.
|
---|
138 | *
|
---|
139 | * @param a_fLocked For the windows shared folders workarounds.
|
---|
140 | *
|
---|
141 | * @remarks Disable the PageList feature for 64-bit Windows, because shared
|
---|
142 | * folders do not work, if this is enabled. This should be reenabled
|
---|
143 | * again when the problem is fixed.
|
---|
144 | * @remarks Disabled the PageList feature for 32-bit Windows, see xTracker
|
---|
145 | * ticket 6096 and public ticket 10290. Hopefully this is the same
|
---|
146 | * issue as on Windows/AMD64.
|
---|
147 | */
|
---|
148 | #if defined(RT_OS_WINDOWS)
|
---|
149 | # ifdef RT_ARCH_AMD64
|
---|
150 | # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) ( 0 )
|
---|
151 | # else
|
---|
152 | # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
|
---|
153 | ( !(a_fLocked) && (g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
|
---|
154 | # endif
|
---|
155 | #else
|
---|
156 | # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
|
---|
157 | ( !!(g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
|
---|
158 | #endif
|
---|
159 |
|
---|
160 | int vbglR0Enter (void);
|
---|
161 |
|
---|
162 | #ifdef VBOX_WITH_HGCM
|
---|
163 | # ifndef VBGL_VBOXGUEST
|
---|
164 | int vbglR0HGCMInit (void);
|
---|
165 | int vbglR0HGCMTerminate (void);
|
---|
166 | # endif
|
---|
167 | #endif /* VBOX_WITH_HGCM */
|
---|
168 |
|
---|
169 | #ifndef VBGL_VBOXGUEST
|
---|
170 | /**
|
---|
171 | * Get a handle to the main VBoxGuest driver.
|
---|
172 | * @returns VERR_TRY_AGAIN if the main driver has not yet been loaded.
|
---|
173 | */
|
---|
174 | int vbglGetDriver(VBGLDRIVER **ppDriver);
|
---|
175 | #endif
|
---|
176 |
|
---|
177 | #endif /* !___VBoxGuestLib_VBGLInternal_h */
|
---|
178 |
|
---|