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