VirtualBox

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

Last change on this file since 98103 was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.8 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-2023 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: */
52struct VMMDevRequestHeader;
53struct VMMDevReqMousePointer;
54struct 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 */
105typedef 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;
112AssertCompileSize(VMMDevSeamlessMode, 4);
113
114
115/**
116 * CPU event types.
117 *
118 * Used by VbglR3CpuHotplugWaitForEvent
119 *
120 * @ingroup grp_vmmdev_req
121 */
122typedef enum
123{
124 VMMDevCpuEventType_Invalid = 0,
125 VMMDevCpuEventType_None = 1,
126 VMMDevCpuEventType_Plug = 2,
127 VMMDevCpuEventType_Unplug = 3,
128 VMMDevCpuEventType_SizeHack = 0x7fffffff
129} VMMDevCpuEventType;
130AssertCompileSize(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 */
155typedef 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;
168AssertCompileSize(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 */
180typedef 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;
193AssertCompileSize(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 */
200typedef 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;
220AssertCompileSize(VBoxGuestUserState, 4);
221
222
223
224/**
225 * HGCM service location types.
226 * @ingroup grp_vmmdev_req
227 */
228typedef enum
229{
230 VMMDevHGCMLoc_Invalid = 0,
231 VMMDevHGCMLoc_LocalHost = 1,
232 VMMDevHGCMLoc_LocalHost_Existing = 2,
233 VMMDevHGCMLoc_SizeHack = 0x7fffffff
234} HGCMServiceLocationType;
235AssertCompileSize(HGCMServiceLocationType, 4);
236
237/**
238 * HGCM host service location.
239 * @ingroup grp_vmmdev_req
240 */
241typedef struct
242{
243 char achName[128]; /**< This is really szName. */
244} HGCMServiceLocationHost;
245AssertCompileSize(HGCMServiceLocationHost, 128);
246
247/**
248 * HGCM service location.
249 * @ingroup grp_vmmdev_req
250 */
251typedef struct HGCMSERVICELOCATION
252{
253 /** Type of the location. */
254 HGCMServiceLocationType type;
255
256 union
257 {
258 HGCMServiceLocationHost host;
259 } u;
260} HGCMServiceLocation;
261AssertCompileSize(HGCMServiceLocation, 128+4);
262
263
264/**
265 * HGCM parameter type.
266 */
267typedef 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;
285AssertCompileSize(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. */
294typedef 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 if (type == VMMDevHGCMParmType_32bit)
339 {
340 *pu32 = u.value32;
341 return VINF_SUCCESS;
342 }
343 return VERR_INVALID_PARAMETER;
344 }
345
346 void SetUInt64(uint64_t u64)
347 {
348 type = VMMDevHGCMParmType_64bit;
349 u.value64 = u64;
350 }
351
352 int GetUInt64(uint64_t RT_FAR *pu64)
353 {
354 if (type == VMMDevHGCMParmType_64bit)
355 {
356 *pu64 = u.value64;
357 return VINF_SUCCESS;
358 }
359 return VERR_INVALID_PARAMETER;
360 }
361
362 void SetPtr(void RT_FAR *pv, uint32_t cb)
363 {
364 type = VMMDevHGCMParmType_LinAddr;
365 u.Pointer.size = cb;
366 u.Pointer.u.linearAddr = (RTGCPTR32)(uintptr_t)pv;
367 }
368# endif /* __cplusplus */
369} HGCMFunctionParameter32;
370# pragma pack()
371AssertCompileSize(HGCMFunctionParameter32, 4+8);
372
373/**
374 * HGCM function parameter, 64-bit client.
375 */
376# pragma pack(4)/* We force structure dword packing here for hysterical raisins. Saves us 4 bytes,
377 at the cost of misaligning the value64 members. */
378typedef struct HGCMFunctionParameter64
379{
380 HGCMFunctionParameterType type;
381 union
382 {
383 uint32_t value32;
384 uint64_t value64;
385 struct
386 {
387 uint32_t size;
388
389 union
390 {
391 RTGCPHYS64 physAddr;
392 RTGCPTR64 linearAddr;
393 } u;
394 } Pointer;
395 struct
396 {
397 uint32_t cb;
398 RTGCPTR64 uAddr;
399 } LinAddr; /**< Shorter version of the above Pointer structure. */
400 struct
401 {
402 uint32_t size; /**< Size of the buffer described by the page list. */
403 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
404 } PageList;
405 struct
406 {
407 uint32_t fFlags : 8; /**< VBOX_HGCM_F_PARM_*. */
408 uint32_t offData : 24; /**< Relative to the request header, valid if cb != 0. */
409 uint32_t cbData; /**< The buffer size. */
410 } Embedded;
411 } u;
412# ifdef __cplusplus
413 void SetUInt32(uint32_t u32)
414 {
415 type = VMMDevHGCMParmType_32bit;
416 u.value64 = 0; /* init unused bits to 0 */
417 u.value32 = u32;
418 }
419
420 int GetUInt32(uint32_t RT_FAR *pu32)
421 {
422 if (type == VMMDevHGCMParmType_32bit)
423 {
424 *pu32 = u.value32;
425 return VINF_SUCCESS;
426 }
427 return VERR_INVALID_PARAMETER;
428 }
429
430 void SetUInt64(uint64_t u64)
431 {
432 type = VMMDevHGCMParmType_64bit;
433 u.value64 = u64;
434 }
435
436 int GetUInt64(uint64_t RT_FAR *pu64)
437 {
438 if (type == VMMDevHGCMParmType_64bit)
439 {
440 *pu64 = u.value64;
441 return VINF_SUCCESS;
442 }
443 return VERR_INVALID_PARAMETER;
444 }
445
446 void SetPtr(void RT_FAR *pv, uint32_t cb)
447 {
448 type = VMMDevHGCMParmType_LinAddr;
449 u.Pointer.size = cb;
450 u.Pointer.u.linearAddr = (uintptr_t)pv;
451 }
452# endif /** __cplusplus */
453} HGCMFunctionParameter64;
454# pragma pack()
455AssertCompileSize(HGCMFunctionParameter64, 4+12);
456
457/* Redefine the structure type for the guest code. */
458# ifndef VBOX_HGCM_HOST_CODE
459# if ARCH_BITS == 64
460# define HGCMFunctionParameter HGCMFunctionParameter64
461# elif ARCH_BITS == 32 || ARCH_BITS == 16
462# define HGCMFunctionParameter HGCMFunctionParameter32
463# else
464# error "Unsupported sizeof (void *)"
465# endif
466# endif /* !VBOX_HGCM_HOST_CODE */
467
468# else /* !VBOX_WITH_64_BITS_GUESTS */
469
470/**
471 * HGCM function parameter, 32-bit client.
472 *
473 * @todo If this is the same as HGCMFunctionParameter32, why the duplication?
474 */
475# pragma pack(4) /* We force structure dword packing here for hysterical raisins. Saves us 4 bytes, at the cost of
476 misaligning the value64 member of every other parameter structure. */
477typedef struct
478{
479 HGCMFunctionParameterType type;
480 union
481 {
482 uint32_t value32;
483 uint64_t value64;
484 struct
485 {
486 uint32_t size;
487
488 union
489 {
490 RTGCPHYS32 physAddr;
491 RTGCPTR32 linearAddr;
492 } u;
493 } Pointer;
494 struct
495 {
496 uint32_t cb;
497 RTGCPTR32 uAddr;
498 } LinAddr; /**< Shorter version of the above Pointer structure. */
499 struct
500 {
501 uint32_t size; /**< Size of the buffer described by the page list. */
502 uint32_t offset; /**< Relative to the request header, valid if size != 0. */
503 } PageList;
504 struct
505 {
506 uint32_t fFlags : 8; /**< VBOX_HGCM_F_PARM_*. */
507 uint32_t offData : 24; /**< Relative to the request header (must be a valid offset even if cbData is zero). */
508 uint32_t cbData; /**< The buffer size. */
509 } Embedded;
510 } u;
511# ifdef __cplusplus
512 void SetUInt32(uint32_t u32)
513 {
514 type = VMMDevHGCMParmType_32bit;
515 u.value64 = 0; /* init unused bits to 0 */
516 u.value32 = u32;
517 }
518
519 int GetUInt32(uint32_t *pu32)
520 {
521 AssertMsgReturnStmt(type == VMMDevHGCMParmType_32bit, ("type=-%d\n", type),
522 *pu32 = UINT32_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE)
523 *pu32 = u.value32;
524 return VINF_SUCCESS;
525 }
526
527 void SetUInt64(uint64_t u64)
528 {
529 type = VMMDevHGCMParmType_64bit;
530 u.value64 = u64;
531 }
532
533 int GetUInt64(uint64_t *pu64)
534 {
535 AssertMsgReturnStmt(type == VMMDevHGCMParmType_64bit, ("type=%d\n", type),
536 *pu64 = UINT32_MAX /* shut up gcc */, VERR_WRONG_PARAMETER_TYPE);
537 *pu64 = u.value64;
538 return VINF_SUCCESS;
539 }
540
541 void SetPtr(void *pv, uint32_t cb)
542 {
543 type = VMMDevHGCMParmType_LinAddr;
544 u.Pointer.size = cb;
545 u.Pointer.u.linearAddr = (uintptr_t)pv;
546 }
547# endif /* __cplusplus */
548} HGCMFunctionParameter;
549# pragma pack()
550AssertCompileSize(HGCMFunctionParameter, 4+8);
551# endif /* !VBOX_WITH_64_BITS_GUESTS */
552
553/** @} */
554
555#endif /* !VBOX_INCLUDED_VMMDevCoreTypes_h */
556
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use