VirtualBox

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

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

Additions: relicence components needed for Linux shared folders to MIT.
bugref:9109: Shared folders: update to match in-kernel code more closely
This change makes the code on which the Linux kernel shared folder patch is
based MIT-licenced, so that the version in the Linux kernel can be too. This
would make it easier to move code back and forth.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.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_SizeHack = 0x7fffffff
277} HGCMFunctionParameterType;
278AssertCompileSize(HGCMFunctionParameterType, 4);
279
280
281# ifdef VBOX_WITH_64_BITS_GUESTS
282/**
283 * HGCM function parameter, 32-bit client.
284 */
285# pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of
286 misaligning the value64 member of every other parameter structure. */
287typedef struct
288{
289 HGCMFunctionParameterType type;
290 union
291 {
292 uint32_t value32;
293 uint64_t value64;
294 struct
295 {
296 uint32_t size;
297
298 union
299 {
300 RTGCPHYS32 physAddr;
301 RTGCPTR32 linearAddr;
302 } u;
303 } Pointer;
304 struct
305 {
306 uint32_t size; /**< Size of the buffer described by the page list. */
307 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
308 } PageList;
309 } u;
310# ifdef __cplusplus
311 void SetUInt32(uint32_t u32)
312 {
313 type = VMMDevHGCMParmType_32bit;
314 u.value64 = 0; /* init unused bits to 0 */
315 u.value32 = u32;
316 }
317
318 int GetUInt32(uint32_t RT_FAR *pu32)
319 {
320 if (type == VMMDevHGCMParmType_32bit)
321 {
322 *pu32 = u.value32;
323 return VINF_SUCCESS;
324 }
325 return VERR_INVALID_PARAMETER;
326 }
327
328 void SetUInt64(uint64_t u64)
329 {
330 type = VMMDevHGCMParmType_64bit;
331 u.value64 = u64;
332 }
333
334 int GetUInt64(uint64_t RT_FAR *pu64)
335 {
336 if (type == VMMDevHGCMParmType_64bit)
337 {
338 *pu64 = u.value64;
339 return VINF_SUCCESS;
340 }
341 return VERR_INVALID_PARAMETER;
342 }
343
344 void SetPtr(void RT_FAR *pv, uint32_t cb)
345 {
346 type = VMMDevHGCMParmType_LinAddr;
347 u.Pointer.size = cb;
348 u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv;
349 }
350# endif /* __cplusplus */
351} HGCMFunctionParameter32;
352# pragma pack()
353AssertCompileSize(HGCMFunctionParameter32, 4+8);
354
355/**
356 * HGCM function parameter, 64-bit client.
357 */
358# pragma pack(4)/* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of
359 misaligning the value64, physAddr and linearAddr members of every other parameter structure. */
360typedef struct
361{
362 HGCMFunctionParameterType type;
363 union
364 {
365 uint32_t value32;
366 uint64_t value64;
367 struct
368 {
369 uint32_t size;
370
371 union
372 {
373 RTGCPHYS64 physAddr;
374 RTGCPTR64 linearAddr;
375 } u;
376 } Pointer;
377 struct
378 {
379 uint32_t size; /**< Size of the buffer described by the page list. */
380 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
381 } PageList;
382 } u;
383# ifdef __cplusplus
384 void SetUInt32(uint32_t u32)
385 {
386 type = VMMDevHGCMParmType_32bit;
387 u.value64 = 0; /* init unused bits to 0 */
388 u.value32 = u32;
389 }
390
391 int GetUInt32(uint32_t RT_FAR *pu32)
392 {
393 if (type == VMMDevHGCMParmType_32bit)
394 {
395 *pu32 = u.value32;
396 return VINF_SUCCESS;
397 }
398 return VERR_INVALID_PARAMETER;
399 }
400
401 void SetUInt64(uint64_t u64)
402 {
403 type = VMMDevHGCMParmType_64bit;
404 u.value64 = u64;
405 }
406
407 int GetUInt64(uint64_t RT_FAR *pu64)
408 {
409 if (type == VMMDevHGCMParmType_64bit)
410 {
411 *pu64 = u.value64;
412 return VINF_SUCCESS;
413 }
414 return VERR_INVALID_PARAMETER;
415 }
416
417 void SetPtr(void RT_FAR *pv, uint32_t cb)
418 {
419 type = VMMDevHGCMParmType_LinAddr;
420 u.Pointer.size = cb;
421 u.Pointer.u.linearAddr = (uintptr_t)pv;
422 }
423# endif /** __cplusplus */
424} HGCMFunctionParameter64;
425# pragma pack()
426AssertCompileSize(HGCMFunctionParameter64, 4+12);
427
428/* Redefine the structure type for the guest code. */
429# ifndef VBOX_HGCM_HOST_CODE
430# if ARCH_BITS == 64
431# define HGCMFunctionParameter HGCMFunctionParameter64
432# elif ARCH_BITS == 32 || ARCH_BITS == 16
433# define HGCMFunctionParameter HGCMFunctionParameter32
434# else
435# error "Unsupported sizeof (void *)"
436# endif
437# endif /* !VBOX_HGCM_HOST_CODE */
438
439# else /* !VBOX_WITH_64_BITS_GUESTS */
440
441/**
442 * HGCM function parameter, 32-bit client.
443 *
444 * @todo If this is the same as HGCMFunctionParameter32, why the duplication?
445 */
446# pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of
447 misaligning the value64 member of every other parameter structure. */
448typedef struct
449{
450 HGCMFunctionParameterType type;
451 union
452 {
453 uint32_t value32;
454 uint64_t value64;
455 struct
456 {
457 uint32_t size;
458
459 union
460 {
461 RTGCPHYS32 physAddr;
462 RTGCPTR32 linearAddr;
463 } u;
464 } Pointer;
465 struct
466 {
467 uint32_t size; /**< Size of the buffer described by the page list. */
468 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
469 } PageList;
470 } u;
471# ifdef __cplusplus
472 void SetUInt32(uint32_t u32)
473 {
474 type = VMMDevHGCMParmType_32bit;
475 u.value64 = 0; /* init unused bits to 0 */
476 u.value32 = u32;
477 }
478
479 int GetUInt32(uint32_t *pu32)
480 {
481 if (type == VMMDevHGCMParmType_32bit)
482 {
483 *pu32 = u.value32;
484 return VINF_SUCCESS;
485 }
486 return VERR_INVALID_PARAMETER;
487 }
488
489 void SetUInt64(uint64_t u64)
490 {
491 type = VMMDevHGCMParmType_64bit;
492 u.value64 = u64;
493 }
494
495 int GetUInt64(uint64_t *pu64)
496 {
497 if (type == VMMDevHGCMParmType_64bit)
498 {
499 *pu64 = u.value64;
500 return VINF_SUCCESS;
501 }
502 return VERR_INVALID_PARAMETER;
503 }
504
505 void SetPtr(void *pv, uint32_t cb)
506 {
507 type = VMMDevHGCMParmType_LinAddr;
508 u.Pointer.size = cb;
509 u.Pointer.u.linearAddr = (uintptr_t)pv;
510 }
511# endif /* __cplusplus */
512} HGCMFunctionParameter;
513# pragma pack()
514AssertCompileSize(HGCMFunctionParameter, 4+8);
515# endif /* !VBOX_WITH_64_BITS_GUESTS */
516
517/** @} */
518
519#endif
520
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use