1 | /** @file
|
---|
2 | * Virtual Device for Guest <-> VMM/Host communication, Core Types. (ADD,DEV)
|
---|
3 | *
|
---|
4 | * These types are needed by several headers VBoxGuestLib.h and are kept
|
---|
5 | * separate to avoid having to include the whole VMMDev.h fun.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
10 | *
|
---|
11 | * Permission is hereby granted, free of charge, to any person
|
---|
12 | * obtaining a copy of this software and associated documentation
|
---|
13 | * files (the "Software"), to deal in the Software without
|
---|
14 | * restriction, including without limitation the rights to use,
|
---|
15 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
16 | * copies of the Software, and to permit persons to whom the
|
---|
17 | * Software is furnished to do so, subject to the following
|
---|
18 | * conditions:
|
---|
19 | *
|
---|
20 | * The above copyright notice and this permission notice shall be
|
---|
21 | * included in all copies or substantial portions of the Software.
|
---|
22 | *
|
---|
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
25 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
27 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
28 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
30 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef VBOX_INCLUDED_VMMDevCoreTypes_h
|
---|
34 | #define VBOX_INCLUDED_VMMDevCoreTypes_h
|
---|
35 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
36 | # pragma once
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | #include <iprt/assertcompile.h>
|
---|
40 | #include <iprt/types.h>
|
---|
41 | #ifdef __cplusplus
|
---|
42 | # include <iprt/assert.h>
|
---|
43 | # include <iprt/errcore.h>
|
---|
44 | #endif
|
---|
45 |
|
---|
46 |
|
---|
47 | /** @addtogroup grp_vmmdev
|
---|
48 | * @{
|
---|
49 | */
|
---|
50 |
|
---|
51 | /* Helpful forward declarations: */
|
---|
52 | struct VMMDevRequestHeader;
|
---|
53 | struct VMMDevReqMousePointer;
|
---|
54 | struct VMMDevMemory;
|
---|
55 |
|
---|
56 |
|
---|
57 | /** @name VMMDev events.
|
---|
58 | *
|
---|
59 | * Used mainly by VMMDevReq_AcknowledgeEvents/VMMDevEvents and version 1.3 of
|
---|
60 | * VMMDevMemory.
|
---|
61 | *
|
---|
62 | * @{
|
---|
63 | */
|
---|
64 | /** Host mouse capabilities has been changed. */
|
---|
65 | #define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED RT_BIT(0)
|
---|
66 | /** HGCM event. */
|
---|
67 | #define VMMDEV_EVENT_HGCM RT_BIT(1)
|
---|
68 | /** A display change request has been issued. */
|
---|
69 | #define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST RT_BIT(2)
|
---|
70 | /** Credentials are available for judgement. */
|
---|
71 | #define VMMDEV_EVENT_JUDGE_CREDENTIALS RT_BIT(3)
|
---|
72 | /** The guest has been restored. */
|
---|
73 | #define VMMDEV_EVENT_RESTORED RT_BIT(4)
|
---|
74 | /** Seamless mode state changed. */
|
---|
75 | #define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST RT_BIT(5)
|
---|
76 | /** Memory balloon size changed. */
|
---|
77 | #define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST RT_BIT(6)
|
---|
78 | /** Statistics interval changed. */
|
---|
79 | #define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST RT_BIT(7)
|
---|
80 | /** VRDP status changed. */
|
---|
81 | #define VMMDEV_EVENT_VRDP RT_BIT(8)
|
---|
82 | /** New mouse position data available. */
|
---|
83 | #define VMMDEV_EVENT_MOUSE_POSITION_CHANGED RT_BIT(9)
|
---|
84 | /** CPU hotplug event occurred. */
|
---|
85 | #define VMMDEV_EVENT_CPU_HOTPLUG RT_BIT(10)
|
---|
86 | /** The mask of valid events, for sanity checking. */
|
---|
87 | #define VMMDEV_EVENT_VALID_EVENT_MASK UINT32_C(0x000007ff)
|
---|
88 | /** @} */
|
---|
89 |
|
---|
90 |
|
---|
91 | /** @name The ballooning chunk size which VMMDev works at.
|
---|
92 | * @{ */
|
---|
93 | #define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (_1M/4096)
|
---|
94 | #define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE (VMMDEV_MEMORY_BALLOON_CHUNK_PAGES*4096)
|
---|
95 | /** @} */
|
---|
96 |
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Seamless mode.
|
---|
100 | *
|
---|
101 | * Used by VbglR3SeamlessWaitEvent
|
---|
102 | *
|
---|
103 | * @ingroup grp_vmmdev_req
|
---|
104 | */
|
---|
105 | typedef enum
|
---|
106 | {
|
---|
107 | VMMDev_Seamless_Disabled = 0, /**< normal mode; entire guest desktop displayed. */
|
---|
108 | VMMDev_Seamless_Visible_Region = 1, /**< visible region mode; only top-level guest windows displayed. */
|
---|
109 | VMMDev_Seamless_Host_Window = 2, /**< windowed mode; each top-level guest window is represented in a host window. */
|
---|
110 | VMMDev_Seamless_SizeHack = 0x7fffffff
|
---|
111 | } VMMDevSeamlessMode;
|
---|
112 | AssertCompileSize(VMMDevSeamlessMode, 4);
|
---|
113 |
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * CPU event types.
|
---|
117 | *
|
---|
118 | * Used by VbglR3CpuHotplugWaitForEvent
|
---|
119 | *
|
---|
120 | * @ingroup grp_vmmdev_req
|
---|
121 | */
|
---|
122 | typedef enum
|
---|
123 | {
|
---|
124 | VMMDevCpuEventType_Invalid = 0,
|
---|
125 | VMMDevCpuEventType_None = 1,
|
---|
126 | VMMDevCpuEventType_Plug = 2,
|
---|
127 | VMMDevCpuEventType_Unplug = 3,
|
---|
128 | VMMDevCpuEventType_SizeHack = 0x7fffffff
|
---|
129 | } VMMDevCpuEventType;
|
---|
130 | AssertCompileSize(VMMDevCpuEventType, 4);
|
---|
131 |
|
---|
132 |
|
---|
133 | /** @name Guest capability bits.
|
---|
134 | * Used by VMMDevReq_ReportGuestCapabilities and VMMDevReq_SetGuestCapabilities.
|
---|
135 | * @{ */
|
---|
136 | /** The guest supports seamless display rendering. */
|
---|
137 | #define VMMDEV_GUEST_SUPPORTS_SEAMLESS RT_BIT_32(0)
|
---|
138 | /** The guest supports mapping guest to host windows. */
|
---|
139 | #define VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING RT_BIT_32(1)
|
---|
140 | /** The guest graphical additions are active.
|
---|
141 | * Used for fast activation and deactivation of certain graphical operations
|
---|
142 | * (e.g. resizing & seamless). The legacy VMMDevReq_ReportGuestCapabilities
|
---|
143 | * request sets this automatically, but VMMDevReq_SetGuestCapabilities does
|
---|
144 | * not. */
|
---|
145 | #define VMMDEV_GUEST_SUPPORTS_GRAPHICS RT_BIT_32(2)
|
---|
146 | /** The mask of valid events, for sanity checking. */
|
---|
147 | #define VMMDEV_GUEST_CAPABILITIES_MASK UINT32_C(0x00000007)
|
---|
148 | /** @} */
|
---|
149 |
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * The guest facility.
|
---|
153 | * This needs to be kept in sync with AdditionsFacilityType of the Main API!
|
---|
154 | */
|
---|
155 | typedef enum
|
---|
156 | {
|
---|
157 | VBoxGuestFacilityType_Unknown = 0,
|
---|
158 | VBoxGuestFacilityType_VBoxGuestDriver = 20,
|
---|
159 | VBoxGuestFacilityType_AutoLogon = 90, /* VBoxGINA / VBoxCredProv / pam_vbox. */
|
---|
160 | VBoxGuestFacilityType_VBoxService = 100,
|
---|
161 | VBoxGuestFacilityType_VBoxTrayClient = 101, /* VBoxTray (Windows), VBoxClient (Linux, Unix). */
|
---|
162 | VBoxGuestFacilityType_Seamless = 1000,
|
---|
163 | VBoxGuestFacilityType_Graphics = 1100,
|
---|
164 | VBoxGuestFacilityType_MonitorAttach = 1101,
|
---|
165 | VBoxGuestFacilityType_All = 0x7ffffffe,
|
---|
166 | VBoxGuestFacilityType_SizeHack = 0x7fffffff
|
---|
167 | } VBoxGuestFacilityType;
|
---|
168 | AssertCompileSize(VBoxGuestFacilityType, 4);
|
---|
169 |
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * The current guest status of a facility.
|
---|
173 | * This needs to be kept in sync with AdditionsFacilityStatus of the Main API!
|
---|
174 | *
|
---|
175 | * @remarks r=bird: Pretty please, for future types like this, simply do a
|
---|
176 | * linear allocation without any gaps. This stuff is impossible work
|
---|
177 | * efficiently with, let alone validate. Applies to the other facility
|
---|
178 | * enums too.
|
---|
179 | */
|
---|
180 | typedef enum
|
---|
181 | {
|
---|
182 | VBoxGuestFacilityStatus_Inactive = 0,
|
---|
183 | VBoxGuestFacilityStatus_Paused = 1,
|
---|
184 | VBoxGuestFacilityStatus_PreInit = 20,
|
---|
185 | VBoxGuestFacilityStatus_Init = 30,
|
---|
186 | VBoxGuestFacilityStatus_Active = 50,
|
---|
187 | VBoxGuestFacilityStatus_Terminating = 100,
|
---|
188 | VBoxGuestFacilityStatus_Terminated = 101,
|
---|
189 | VBoxGuestFacilityStatus_Failed = 800,
|
---|
190 | VBoxGuestFacilityStatus_Unknown = 999,
|
---|
191 | VBoxGuestFacilityStatus_SizeHack = 0x7fffffff
|
---|
192 | } VBoxGuestFacilityStatus;
|
---|
193 | AssertCompileSize(VBoxGuestFacilityStatus, 4);
|
---|
194 |
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * The current status of specific guest user.
|
---|
198 | * This needs to be kept in sync with GuestUserState of the Main API!
|
---|
199 | */
|
---|
200 | typedef enum VBoxGuestUserState
|
---|
201 | {
|
---|
202 | VBoxGuestUserState_Unknown = 0,
|
---|
203 | VBoxGuestUserState_LoggedIn = 1,
|
---|
204 | VBoxGuestUserState_LoggedOut = 2,
|
---|
205 | VBoxGuestUserState_Locked = 3,
|
---|
206 | VBoxGuestUserState_Unlocked = 4,
|
---|
207 | VBoxGuestUserState_Disabled = 5,
|
---|
208 | VBoxGuestUserState_Idle = 6,
|
---|
209 | VBoxGuestUserState_InUse = 7,
|
---|
210 | VBoxGuestUserState_Created = 8,
|
---|
211 | VBoxGuestUserState_Deleted = 9,
|
---|
212 | VBoxGuestUserState_SessionChanged = 10,
|
---|
213 | VBoxGuestUserState_CredentialsChanged = 11,
|
---|
214 | VBoxGuestUserState_RoleChanged = 12,
|
---|
215 | VBoxGuestUserState_GroupAdded = 13,
|
---|
216 | VBoxGuestUserState_GroupRemoved = 14,
|
---|
217 | VBoxGuestUserState_Elevated = 15,
|
---|
218 | VBoxGuestUserState_SizeHack = 0x7fffffff
|
---|
219 | } VBoxGuestUserState;
|
---|
220 | AssertCompileSize(VBoxGuestUserState, 4);
|
---|
221 |
|
---|
222 |
|
---|
223 |
|
---|
224 | /**
|
---|
225 | * HGCM service location types.
|
---|
226 | * @ingroup grp_vmmdev_req
|
---|
227 | */
|
---|
228 | typedef enum
|
---|
229 | {
|
---|
230 | VMMDevHGCMLoc_Invalid = 0,
|
---|
231 | VMMDevHGCMLoc_LocalHost = 1,
|
---|
232 | VMMDevHGCMLoc_LocalHost_Existing = 2,
|
---|
233 | VMMDevHGCMLoc_SizeHack = 0x7fffffff
|
---|
234 | } HGCMServiceLocationType;
|
---|
235 | AssertCompileSize(HGCMServiceLocationType, 4);
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * HGCM host service location.
|
---|
239 | * @ingroup grp_vmmdev_req
|
---|
240 | */
|
---|
241 | typedef struct
|
---|
242 | {
|
---|
243 | char achName[128]; /**< This is really szName. */
|
---|
244 | } HGCMServiceLocationHost;
|
---|
245 | AssertCompileSize(HGCMServiceLocationHost, 128);
|
---|
246 |
|
---|
247 | /**
|
---|
248 | * HGCM service location.
|
---|
249 | * @ingroup grp_vmmdev_req
|
---|
250 | */
|
---|
251 | typedef struct HGCMSERVICELOCATION
|
---|
252 | {
|
---|
253 | /** Type of the location. */
|
---|
254 | HGCMServiceLocationType type;
|
---|
255 |
|
---|
256 | union
|
---|
257 | {
|
---|
258 | HGCMServiceLocationHost host;
|
---|
259 | } u;
|
---|
260 | } HGCMServiceLocation;
|
---|
261 | AssertCompileSize(HGCMServiceLocation, 128+4);
|
---|
262 |
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * HGCM parameter type.
|
---|
266 | */
|
---|
267 | typedef enum
|
---|
268 | {
|
---|
269 | VMMDevHGCMParmType_Invalid = 0,
|
---|
270 | VMMDevHGCMParmType_32bit = 1,
|
---|
271 | VMMDevHGCMParmType_64bit = 2,
|
---|
272 | VMMDevHGCMParmType_PhysAddr = 3, /**< @deprecated Doesn't work, use PageList. */
|
---|
273 | VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
|
---|
274 | VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */
|
---|
275 | VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */
|
---|
276 | VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out - for VBoxGuest, not host. */
|
---|
277 | VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) - for VBoxGuest, not host. */
|
---|
278 | VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) - for VBoxGuest, not host. */
|
---|
279 | VMMDevHGCMParmType_PageList = 10, /**< Physical addresses of locked pages for a buffer. */
|
---|
280 | VMMDevHGCMParmType_Embedded = 11, /**< Small buffer embedded in request. */
|
---|
281 | VMMDevHGCMParmType_ContiguousPageList = 12, /**< Like PageList but with physically contiguous memory, so only one page entry. */
|
---|
282 | VMMDevHGCMParmType_NoBouncePageList = 13, /**< Like PageList but host function requires no bounce buffering. */
|
---|
283 | VMMDevHGCMParmType_SizeHack = 0x7fffffff
|
---|
284 | } HGCMFunctionParameterType;
|
---|
285 | AssertCompileSize(HGCMFunctionParameterType, 4);
|
---|
286 |
|
---|
287 |
|
---|
288 | # ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
289 | /**
|
---|
290 | * HGCM function parameter, 32-bit client.
|
---|
291 | */
|
---|
292 | # pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of
|
---|
293 | misaligning the value64 member of every other parameter structure. */
|
---|
294 | typedef struct HGCMFunctionParameter32
|
---|
295 | {
|
---|
296 | HGCMFunctionParameterType type;
|
---|
297 | union
|
---|
298 | {
|
---|
299 | uint32_t value32;
|
---|
300 | uint64_t value64;
|
---|
301 | struct
|
---|
302 | {
|
---|
303 | uint32_t size;
|
---|
304 |
|
---|
305 | union
|
---|
306 | {
|
---|
307 | RTGCPHYS32 physAddr;
|
---|
308 | RTGCPTR32 linearAddr;
|
---|
309 | } u;
|
---|
310 | } Pointer;
|
---|
311 | struct
|
---|
312 | {
|
---|
313 | uint32_t cb;
|
---|
314 | RTGCPTR32 uAddr;
|
---|
315 | } LinAddr; /**< Shorter version of the above Pointer structure. */
|
---|
316 | struct
|
---|
317 | {
|
---|
318 | uint32_t size; /**< Size of the buffer described by the page list. */
|
---|
319 | uint32_t offset; /**< Relative to the request header of a HGCMPageListInfo structure, valid if size != 0. */
|
---|
320 | } PageList;
|
---|
321 | struct
|
---|
322 | {
|
---|
323 | uint32_t fFlags : 8; /**< VBOX_HGCM_F_PARM_*. */
|
---|
324 | uint32_t offData : 24; /**< Relative to the request header, valid if cb != 0. */
|
---|
325 | uint32_t cbData; /**< The buffer size. */
|
---|
326 | } Embedded;
|
---|
327 | } u;
|
---|
328 | # ifdef __cplusplus
|
---|
329 | void SetUInt32(uint32_t u32)
|
---|
330 | {
|
---|
331 | type = VMMDevHGCMParmType_32bit;
|
---|
332 | u.value64 = 0; /* init unused bits to 0 */
|
---|
333 | u.value32 = u32;
|
---|
334 | }
|
---|
335 |
|
---|
336 | int GetUInt32(uint32_t RT_FAR *pu32)
|
---|
337 | {
|
---|
338 | AssertMsgReturnStmt(type == VMMDevHGCMParmType_32bit, ("type=%d\n", type),
|
---|
339 | *pu32 = UINT32_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE);
|
---|
340 | *pu32 = u.value32;
|
---|
341 | return VINF_SUCCESS;
|
---|
342 | }
|
---|
343 |
|
---|
344 | void SetUInt64(uint64_t u64)
|
---|
345 | {
|
---|
346 | type = VMMDevHGCMParmType_64bit;
|
---|
347 | u.value64 = u64;
|
---|
348 | }
|
---|
349 |
|
---|
350 | int GetUInt64(uint64_t RT_FAR *pu64)
|
---|
351 | {
|
---|
352 | AssertMsgReturnStmt(type == VMMDevHGCMParmType_64bit, ("type=%d\n", type),
|
---|
353 | *pu64 = UINT64_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE);
|
---|
354 | *pu64 = u.value64;
|
---|
355 | return VINF_SUCCESS;
|
---|
356 | }
|
---|
357 |
|
---|
358 | void SetPtr(void RT_FAR *pv, uint32_t cb)
|
---|
359 | {
|
---|
360 | type = VMMDevHGCMParmType_LinAddr;
|
---|
361 | u.Pointer.size = cb;
|
---|
362 | u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv;
|
---|
363 | }
|
---|
364 | # endif /* __cplusplus */
|
---|
365 | } HGCMFunctionParameter32;
|
---|
366 | # pragma pack()
|
---|
367 | AssertCompileSize(HGCMFunctionParameter32, 4+8);
|
---|
368 |
|
---|
369 | /**
|
---|
370 | * HGCM function parameter, 64-bit client.
|
---|
371 | */
|
---|
372 | # pragma pack(4)/* We force structure dword packing here for hysterical raisins. Saves us 4 bytes,
|
---|
373 | at the cost of misaligning the value64 members. */
|
---|
374 | typedef struct HGCMFunctionParameter64
|
---|
375 | {
|
---|
376 | HGCMFunctionParameterType type;
|
---|
377 | union
|
---|
378 | {
|
---|
379 | uint32_t value32;
|
---|
380 | uint64_t value64;
|
---|
381 | struct
|
---|
382 | {
|
---|
383 | uint32_t size;
|
---|
384 |
|
---|
385 | union
|
---|
386 | {
|
---|
387 | RTGCPHYS64 physAddr;
|
---|
388 | RTGCPTR64 linearAddr;
|
---|
389 | } u;
|
---|
390 | } Pointer;
|
---|
391 | struct
|
---|
392 | {
|
---|
393 | uint32_t cb;
|
---|
394 | RTGCPTR64 uAddr;
|
---|
395 | } LinAddr; /**< Shorter version of the above Pointer structure. */
|
---|
396 | struct
|
---|
397 | {
|
---|
398 | uint32_t size; /**< Size of the buffer described by the page list. */
|
---|
399 | uint32_t offset; /**< Relative to the request header, valid if size != 0. */
|
---|
400 | } PageList;
|
---|
401 | struct
|
---|
402 | {
|
---|
403 | uint32_t fFlags : 8; /**< VBOX_HGCM_F_PARM_*. */
|
---|
404 | uint32_t offData : 24; /**< Relative to the request header, valid if cb != 0. */
|
---|
405 | uint32_t cbData; /**< The buffer size. */
|
---|
406 | } Embedded;
|
---|
407 | } u;
|
---|
408 | # ifdef __cplusplus
|
---|
409 | void SetUInt32(uint32_t u32)
|
---|
410 | {
|
---|
411 | type = VMMDevHGCMParmType_32bit;
|
---|
412 | u.value64 = 0; /* init unused bits to 0 */
|
---|
413 | u.value32 = u32;
|
---|
414 | }
|
---|
415 |
|
---|
416 | int GetUInt32(uint32_t RT_FAR *pu32)
|
---|
417 | {
|
---|
418 | AssertMsgReturnStmt(type == VMMDevHGCMParmType_32bit, ("type=%d\n", type),
|
---|
419 | *pu32 = UINT32_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE);
|
---|
420 | *pu32 = u.value32;
|
---|
421 | return VINF_SUCCESS;
|
---|
422 | }
|
---|
423 |
|
---|
424 | void SetUInt64(uint64_t u64)
|
---|
425 | {
|
---|
426 | type = VMMDevHGCMParmType_64bit;
|
---|
427 | u.value64 = u64;
|
---|
428 | }
|
---|
429 |
|
---|
430 | int GetUInt64(uint64_t RT_FAR *pu64)
|
---|
431 | {
|
---|
432 | AssertMsgReturnStmt(type == VMMDevHGCMParmType_64bit, ("type=%d\n", type),
|
---|
433 | *pu64 = UINT64_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE);
|
---|
434 | *pu64 = u.value64;
|
---|
435 | return VINF_SUCCESS;
|
---|
436 | }
|
---|
437 |
|
---|
438 | void SetPtr(void RT_FAR *pv, uint32_t cb)
|
---|
439 | {
|
---|
440 | type = VMMDevHGCMParmType_LinAddr;
|
---|
441 | u.Pointer.size = cb;
|
---|
442 | u.Pointer.u.linearAddr = (uintptr_t)pv;
|
---|
443 | }
|
---|
444 | # endif /** __cplusplus */
|
---|
445 | } HGCMFunctionParameter64;
|
---|
446 | # pragma pack()
|
---|
447 | AssertCompileSize(HGCMFunctionParameter64, 4+12);
|
---|
448 |
|
---|
449 | /* Redefine the structure type for the guest code. */
|
---|
450 | # ifndef VBOX_HGCM_HOST_CODE
|
---|
451 | # if ARCH_BITS == 64
|
---|
452 | # define HGCMFunctionParameter HGCMFunctionParameter64
|
---|
453 | # elif ARCH_BITS == 32 || ARCH_BITS == 16
|
---|
454 | # define HGCMFunctionParameter HGCMFunctionParameter32
|
---|
455 | # else
|
---|
456 | # error "Unsupported sizeof (void *)"
|
---|
457 | # endif
|
---|
458 | # endif /* !VBOX_HGCM_HOST_CODE */
|
---|
459 |
|
---|
460 | # else /* !VBOX_WITH_64_BITS_GUESTS */
|
---|
461 |
|
---|
462 | /**
|
---|
463 | * HGCM function parameter, 32-bit client.
|
---|
464 | *
|
---|
465 | * @todo If this is the same as HGCMFunctionParameter32, why the duplication?
|
---|
466 | */
|
---|
467 | # pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of
|
---|
468 | misaligning the value64 member of every other parameter structure. */
|
---|
469 | typedef struct
|
---|
470 | {
|
---|
471 | HGCMFunctionParameterType type;
|
---|
472 | union
|
---|
473 | {
|
---|
474 | uint32_t value32;
|
---|
475 | uint64_t value64;
|
---|
476 | struct
|
---|
477 | {
|
---|
478 | uint32_t size;
|
---|
479 |
|
---|
480 | union
|
---|
481 | {
|
---|
482 | RTGCPHYS32 physAddr;
|
---|
483 | RTGCPTR32 linearAddr;
|
---|
484 | } u;
|
---|
485 | } Pointer;
|
---|
486 | struct
|
---|
487 | {
|
---|
488 | uint32_t cb;
|
---|
489 | RTGCPTR32 uAddr;
|
---|
490 | } LinAddr; /**< Shorter version of the above Pointer structure. */
|
---|
491 | struct
|
---|
492 | {
|
---|
493 | uint32_t size; /**< Size of the buffer described by the page list. */
|
---|
494 | uint32_t offset; /**< Relative to the request header, valid if size != 0. */
|
---|
495 | } PageList;
|
---|
496 | struct
|
---|
497 | {
|
---|
498 | uint32_t fFlags : 8; /**< VBOX_HGCM_F_PARM_*. */
|
---|
499 | uint32_t offData : 24; /**< Relative to the request header (must be a valid offset even if cbData is zero). */
|
---|
500 | uint32_t cbData; /**< The buffer size. */
|
---|
501 | } Embedded;
|
---|
502 | } u;
|
---|
503 | # ifdef __cplusplus
|
---|
504 | void SetUInt32(uint32_t u32)
|
---|
505 | {
|
---|
506 | type = VMMDevHGCMParmType_32bit;
|
---|
507 | u.value64 = 0; /* init unused bits to 0 */
|
---|
508 | u.value32 = u32;
|
---|
509 | }
|
---|
510 |
|
---|
511 | int GetUInt32(uint32_t *pu32)
|
---|
512 | {
|
---|
513 | AssertMsgReturnStmt(type == VMMDevHGCMParmType_32bit, ("type=%d\n", type),
|
---|
514 | *pu32 = UINT32_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE)
|
---|
515 | *pu32 = u.value32;
|
---|
516 | return VINF_SUCCESS;
|
---|
517 | }
|
---|
518 |
|
---|
519 | void SetUInt64(uint64_t u64)
|
---|
520 | {
|
---|
521 | type = VMMDevHGCMParmType_64bit;
|
---|
522 | u.value64 = u64;
|
---|
523 | }
|
---|
524 |
|
---|
525 | int GetUInt64(uint64_t *pu64)
|
---|
526 | {
|
---|
527 | AssertMsgReturnStmt(type == VMMDevHGCMParmType_64bit, ("type=%d\n", type),
|
---|
528 | *pu64 = UINT64_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE);
|
---|
529 | *pu64 = u.value64;
|
---|
530 | return VINF_SUCCESS;
|
---|
531 | }
|
---|
532 |
|
---|
533 | void SetPtr(void *pv, uint32_t cb)
|
---|
534 | {
|
---|
535 | type = VMMDevHGCMParmType_LinAddr;
|
---|
536 | u.Pointer.size = cb;
|
---|
537 | u.Pointer.u.linearAddr = (uintptr_t)pv;
|
---|
538 | }
|
---|
539 | # endif /* __cplusplus */
|
---|
540 | } HGCMFunctionParameter;
|
---|
541 | # pragma pack()
|
---|
542 | AssertCompileSize(HGCMFunctionParameter, 4+8);
|
---|
543 | # endif /* !VBOX_WITH_64_BITS_GUESTS */
|
---|
544 |
|
---|
545 | /** @} */
|
---|
546 |
|
---|
547 | #endif /* !VBOX_INCLUDED_VMMDevCoreTypes_h */
|
---|
548 |
|
---|