1 | /* $Id: VBGLInternal.h 56294 2015-06-09 14:26:20Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestLibR0 - Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 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 | RTSEMMUTEX 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 Disabled the PageList feature for locked memory on Windows,
|
---|
142 | * because a new MDL is created by VBGL to get the page addresses
|
---|
143 | * and the pages from the MDL are marked as dirty when they should not.
|
---|
144 | */
|
---|
145 | #if defined(RT_OS_WINDOWS)
|
---|
146 | # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
|
---|
147 | ( !(a_fLocked) && (g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
|
---|
148 | #else
|
---|
149 | # define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
|
---|
150 | ( !!(g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
|
---|
151 | #endif
|
---|
152 |
|
---|
153 | int vbglR0Enter (void);
|
---|
154 |
|
---|
155 | #ifdef VBOX_WITH_HGCM
|
---|
156 | # ifndef VBGL_VBOXGUEST
|
---|
157 | int vbglR0HGCMInit (void);
|
---|
158 | int vbglR0HGCMTerminate (void);
|
---|
159 | # endif
|
---|
160 | #endif /* VBOX_WITH_HGCM */
|
---|
161 |
|
---|
162 | #ifndef VBGL_VBOXGUEST
|
---|
163 | /**
|
---|
164 | * Get a handle to the main VBoxGuest driver.
|
---|
165 | * @returns VERR_TRY_AGAIN if the main driver has not yet been loaded.
|
---|
166 | */
|
---|
167 | int vbglGetDriver(VBGLDRIVER **ppDriver);
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | #endif /* !___VBoxGuestLib_VBGLInternal_h */
|
---|
171 |
|
---|