VirtualBox

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

Last change on this file since 75548 was 75548, checked in by vboxsync, 6 years ago

VMMDev,VBoxGuestR0Lib: Added a new HGCM parameter type that allows embedding small buffers into the request (similar to the page list info structure). Currently only available to kernel code (i.e. shared folders). bugref:9172

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

© 2023 Oracle
ContactPrivacy policyTerms of Use