VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibInternal.h@ 99876

最後變更 在這個檔案從99876是 98103,由 vboxsync 提交於 23 月 前

Copyright year updates by scm.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.3 KB
 
1/* $Id: VBoxGuestR0LibInternal.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBoxGuestLibR0 - Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31#ifndef GA_INCLUDED_SRC_common_VBoxGuest_lib_VBoxGuestR0LibInternal_h
32#define GA_INCLUDED_SRC_common_VBoxGuest_lib_VBoxGuestR0LibInternal_h
33#ifndef RT_WITHOUT_PRAGMA_ONCE
34# pragma once
35#endif
36
37/*
38 * Define the private IDC handle structure before we include the VBoxGuestLib.h header.
39 */
40#include <iprt/types.h>
41#include <iprt/assert.h>
42RT_C_DECLS_BEGIN
43
44# ifndef VBGL_VBOXGUEST
45/**
46 * The hidden part of VBGLIDCHANDLE.
47 */
48struct VBGLIDCHANDLEPRIVATE
49{
50 /** Pointer to the session handle. */
51 void *pvSession;
52# if defined(RT_OS_WINDOWS) && (defined(IPRT_INCLUDED_nt_ntddk_h) || defined(IPRT_INCLUDED_nt_nt_h))
53 /** Pointer to the NT device object. */
54 PDEVICE_OBJECT pDeviceObject;
55 /** Pointer to the NT file object. */
56 PFILE_OBJECT pFileObject;
57# elif defined(RT_OS_SOLARIS) && defined(_SYS_SUNLDI_H)
58 /** LDI device handle to keep the device attached. */
59 ldi_handle_t hDev;
60# endif
61};
62/** Indicate that the VBGLIDCHANDLEPRIVATE structure is present. */
63# define VBGLIDCHANDLEPRIVATE_DECLARED 1
64#endif
65
66#include <VBox/VMMDev.h>
67#include <VBox/VBoxGuest.h>
68#include <VBox/VBoxGuestLib.h>
69
70#ifdef VBGLIDCHANDLEPRIVATE_DECLARED
71AssertCompile(RT_SIZEOFMEMB(VBGLIDCHANDLE, apvPadding) >= sizeof(struct VBGLIDCHANDLEPRIVATE));
72#endif
73
74
75/*
76 * Native IDC functions.
77 */
78int VBOXCALL vbglR0IdcNativeOpen(PVBGLIDCHANDLE pHandle, PVBGLIOCIDCCONNECT pReq);
79int VBOXCALL vbglR0IdcNativeClose(PVBGLIDCHANDLE pHandle, PVBGLIOCIDCDISCONNECT pReq);
80
81
82/*
83 * Deprecated logging macro
84 */
85#include <VBox/log.h>
86#ifdef RT_OS_WINDOWS /** @todo dprintf() -> Log() */
87# if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
88# define dprintf(a) RTLogBackdoorPrintf a
89# else
90# define dprintf(a) do {} while (0)
91# endif
92#else
93# define dprintf(a) Log(a)
94#endif
95
96/*
97 * Lazy bird: OS/2 doesn't currently implement the RTSemMutex API in ring-0, so
98 * use a fast mutex instead. Unlike Windows, the OS/2 implementation
99 * doesn't have any nasty side effects on IRQL-like context properties, so the
100 * fast mutexes on OS/2 are identical to normal mutexes except for the missing
101 * timeout aspec. Fortunately we don't need timeouts here.
102 */
103#ifdef RT_OS_OS2
104# define VBGLDATA_USE_FAST_MUTEX
105#endif
106
107struct VBGLPHYSHEAPBLOCK;
108typedef struct VBGLPHYSHEAPBLOCK VBGLPHYSHEAPBLOCK;
109struct VBGLPHYSHEAPFREEBLOCK;
110typedef struct VBGLPHYSHEAPFREEBLOCK VBGLPHYSHEAPFREEBLOCK;
111struct VBGLPHYSHEAPCHUNK;
112typedef struct VBGLPHYSHEAPCHUNK VBGLPHYSHEAPCHUNK;
113
114enum VbglLibStatus
115{
116 VbglStatusNotInitialized = 0,
117 VbglStatusInitializing,
118 VbglStatusReady
119};
120
121/**
122 * Global VBGL ring-0 data.
123 * Lives in VBoxGuestR0LibInit.cpp.
124 */
125typedef struct VBGLDATA
126{
127 enum VbglLibStatus status;
128
129 RTIOPORT portVMMDev;
130
131 VMMDevMemory *pVMMDevMemory;
132
133 /** Physical memory heap data.
134 * @{
135 */
136 RTSEMFASTMUTEX hMtxHeap;
137 /** Head of the block list (both free and allocated blocks).
138 * This runs parallel to the chunk list and is sorted by address within each
139 * chunk. This allows merging with blocks both after and before when
140 * freeing. */
141 VBGLPHYSHEAPBLOCK *pBlockHead;
142 /** Head of the free list.
143 * This is not sorted and more on the most recently freed approach. */
144 VBGLPHYSHEAPFREEBLOCK *pFreeHead;
145 /** Number of block of any kind. */
146 int32_t cBlocks;
147 /** Number of free blocks. */
148 int32_t cFreeBlocks;
149 /** Head of the chunk list. */
150 VBGLPHYSHEAPCHUNK *pChunkHead;
151 /** @} */
152
153 /**
154 * The host version data.
155 */
156 VMMDevReqHostVersion hostVersion;
157
158
159#ifndef VBGL_VBOXGUEST
160 /** The IDC handle. This is used for talking to the main driver. */
161 VBGLIDCHANDLE IdcHandle;
162 /** Mutex used to serialize IDC setup. */
163# ifdef VBGLDATA_USE_FAST_MUTEX
164 RTSEMFASTMUTEX hMtxIdcSetup;
165# else
166 RTSEMMUTEX hMtxIdcSetup;
167# endif
168#endif
169} VBGLDATA;
170
171
172extern VBGLDATA g_vbgldata;
173
174/**
175 * Internal macro for checking whether we can pass physical page lists to the
176 * host.
177 *
178 * ASSUMES that vbglR0Enter has been called already.
179 *
180 * @param a_fLocked For the windows shared folders workarounds.
181 *
182 * @remarks Disabled the PageList feature for locked memory on Windows,
183 * because a new MDL is created by VBGL to get the page addresses
184 * and the pages from the MDL are marked as dirty when they should not.
185 */
186#if defined(RT_OS_WINDOWS)
187# define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
188 ( !(a_fLocked) && (g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
189#else
190# define VBGLR0_CAN_USE_PHYS_PAGE_LIST(a_fLocked) \
191 ( !!(g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
192#endif
193
194int vbglR0Enter (void);
195
196#ifdef VBOX_WITH_HGCM
197struct VBGLHGCMHANDLEDATA *vbglR0HGCMHandleAlloc(void);
198void vbglR0HGCMHandleFree(struct VBGLHGCMHANDLEDATA *pHandle);
199#endif /* VBOX_WITH_HGCM */
200
201#ifndef VBGL_VBOXGUEST
202/**
203 * Get the IDC handle to the main VBoxGuest driver.
204 * @returns VERR_TRY_AGAIN if the main driver has not yet been loaded.
205 */
206int VBOXCALL vbglR0QueryIdcHandle(PVBGLIDCHANDLE *ppIdcHandle);
207#endif
208
209RT_C_DECLS_END
210
211#endif /* !GA_INCLUDED_SRC_common_VBoxGuest_lib_VBoxGuestR0LibInternal_h */
212
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette