VirtualBox

source: vbox/trunk/include/VBox/VMMDevCoreTypes.h@ 78203

Last change on this file since 78203 was 77243, checked in by vboxsync, 5 years ago

HGCM,SharedFolders: Added new variation on the HGCM page list type that does not use a bounce buffer. bugref:9172

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

© 2023 Oracle
ContactPrivacy policyTerms of Use