VirtualBox

source: vbox/trunk/include/VBox/VBoxGuest.h@ 7415

Last change on this file since 7415 was 7409, checked in by vboxsync, 17 years ago

VMMDev: added VMMDEV_GUEST_SUPPORTS_GRAPHICS capability, enabled by default, to distinguish cases where the guest additions are loaded but graphics are not supported

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 48.6 KB
Line 
1/** @file
2 * VBoxGuest - VirtualBox Guest Additions interface
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_VBoxGuest_h
27#define ___VBox_VBoxGuest_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31#include <VBox/err.h>
32#include <VBox/ostypes.h>
33
34/*******************************************************************************
35* Defined Constants And Macros *
36*******************************************************************************/
37
38/** @todo The following is a temporary fix for the problem of accessing
39 hypervisor pointers from within guest additions */
40
41/** Hypervisor linear pointer size type */
42typedef RTGCPTR vmmDevHypPtr;
43/** Hypervisor physical pointer size type */
44typedef RTGCPHYS32 vmmDevHypPhys;
45
46#if defined(RT_OS_LINUX)
47/** The support device name. */
48# define VBOXGUEST_DEVICE_NAME "/dev/vboxadd"
49
50#elif defined(RT_OS_OS2)
51/** The support device name. */
52# define VBOXGUEST_DEVICE_NAME "\\Dev\\VBoxGst$"
53
54#elif defined(RT_OS_SOLARIS)
55/** The support device name. */
56# define VBOXGUEST_DEVICE_NAME "/devices/pci@0,0/pci80ee,cafe@4:vboxguest"
57
58#elif defined(RT_OS_WINDOWS)
59/** The support service name. */
60# define VBOXGUEST_SERVICE_NAME "VBoxGuest"
61/** Win32 Device name. */
62# define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
63/** Global name for Win2k+ */
64# define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
65/** Win32 driver name */
66# define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
67/** device name */
68# define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
69
70#else
71/* PORTME */
72#endif
73
74/** VirtualBox vendor ID */
75#define VBOX_PCI_VENDORID (0x80ee)
76
77/** VMMDev PCI card identifiers */
78#define VMMDEV_VENDORID VBOX_PCI_VENDORID
79#define VMMDEV_DEVICEID (0xcafe)
80
81/** VirtualBox graphics card identifiers */
82#define VBOX_VENDORID VBOX_PCI_VENDORID
83#define VBOX_VESA_VENDORID VBOX_PCI_VENDORID
84#define VBOX_DEVICEID (0xbeef)
85#define VBOX_VESA_DEVICEID (0xbeef)
86
87/**
88 * VBoxGuest port definitions
89 * @{
90 */
91
92/** guest can (== wants to) handle absolute coordinates */
93#define VBOXGUEST_MOUSE_GUEST_CAN_ABSOLUTE RT_BIT(0)
94/** host can (== wants to) send absolute coordinates */
95#define VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE RT_BIT(1)
96/** guest can *NOT* switch to software cursor and therefore depends on the host cursor */
97#define VBOXGUEST_MOUSE_GUEST_NEEDS_HOST_CURSOR RT_BIT(2)
98/** host does NOT provide support for drawing the cursor itself (e.g. L4 console) */
99#define VBOXGUEST_MOUSE_HOST_CANNOT_HWPOINTER RT_BIT(3)
100
101/** fictive start address of the hypervisor physical memory for MmMapIoSpace */
102#define HYPERVISOR_PHYSICAL_START 0xf8000000
103
104/*
105 * VMMDev Generic Request Interface
106 */
107
108/** port for generic request interface */
109#define PORT_VMMDEV_REQUEST_OFFSET 0
110
111/** Current version of the VMMDev interface.
112 *
113 * Additions are allowed to work only if
114 * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
115 * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
116 *
117 * @remark These defines also live in the 16-bit and assembly versions of this header.
118 */
119#define VMMDEV_VERSION 0x00010004
120#define VMMDEV_VERSION_MAJOR (VMMDEV_VERSION >> 16)
121#define VMMDEV_VERSION_MINOR (VMMDEV_VERSION & 0xffff)
122
123/* Maximum request packet size */
124#define VMMDEV_MAX_VMMDEVREQ_SIZE _1M
125
126/**
127 * VMMDev request types.
128 * @note when updating this, adjust vmmdevGetRequestSize() as well
129 */
130typedef enum
131{
132 VMMDevReq_InvalidRequest = 0,
133 VMMDevReq_GetMouseStatus = 1,
134 VMMDevReq_SetMouseStatus = 2,
135 VMMDevReq_SetPointerShape = 3,
136 /** @todo implement on host side */
137 VMMDevReq_GetHostVersion = 4,
138 VMMDevReq_Idle = 5,
139 VMMDevReq_GetHostTime = 10,
140 VMMDevReq_GetHypervisorInfo = 20,
141 VMMDevReq_SetHypervisorInfo = 21,
142 VMMDevReq_SetPowerStatus = 30,
143 VMMDevReq_AcknowledgeEvents = 41,
144 VMMDevReq_CtlGuestFilterMask = 42,
145 VMMDevReq_ReportGuestInfo = 50,
146 VMMDevReq_GetDisplayChangeRequest = 51,
147 VMMDevReq_VideoModeSupported = 52,
148 VMMDevReq_GetHeightReduction = 53,
149 VMMDevReq_GetDisplayChangeRequest2 = 54,
150 VMMDevReq_ReportGuestCapabilities = 55,
151 VMMDevReq_SetGuestCapabilities = 56,
152#ifdef VBOX_HGCM
153 VMMDevReq_HGCMConnect = 60,
154 VMMDevReq_HGCMDisconnect = 61,
155 VMMDevReq_HGCMCall = 62,
156#endif
157 VMMDevReq_VideoAccelEnable = 70,
158 VMMDevReq_VideoAccelFlush = 71,
159 VMMDevReq_VideoSetVisibleRegion = 72,
160 VMMDevReq_GetSeamlessChangeRequest = 73,
161 VMMDevReq_QueryCredentials = 100,
162 VMMDevReq_ReportCredentialsJudgement = 101,
163 VMMDevReq_ReportGuestStats = 110,
164 VMMDevReq_GetMemBalloonChangeRequest = 111,
165 VMMDevReq_GetStatisticsChangeRequest = 112,
166 VMMDevReq_ChangeMemBalloon = 113,
167 VMMDevReq_GetVRDPChangeRequest = 150,
168 VMMDevReq_LogString = 200,
169 VMMDevReq_SizeHack = 0x7fffffff
170} VMMDevRequestType;
171
172/** Version of VMMDevRequestHeader structure. */
173#define VMMDEV_REQUEST_HEADER_VERSION (0x10001)
174
175#pragma pack(4)
176/** generic VMMDev request header */
177typedef struct
178{
179 /** size of the structure in bytes (including body). Filled by caller */
180 uint32_t size;
181 /** version of the structure. Filled by caller */
182 uint32_t version;
183 /** type of the request */
184 VMMDevRequestType requestType;
185 /** return code. Filled by VMMDev */
186 int32_t rc;
187 /** reserved fields */
188 uint32_t reserved1;
189 uint32_t reserved2;
190} VMMDevRequestHeader;
191
192/** mouse status request structure */
193typedef struct
194{
195 /** header */
196 VMMDevRequestHeader header;
197 /** mouse feature mask */
198 uint32_t mouseFeatures;
199 /** mouse x position */
200 uint32_t pointerXPos;
201 /** mouse y position */
202 uint32_t pointerYPos;
203} VMMDevReqMouseStatus;
204
205/** Note VBOX_MOUSE_POINTER_* flags are used in guest video driver,
206 * values must be <= 0x8000 and must not be changed.
207 */
208
209/** pointer is visible */
210#define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
211/** pointer has alpha channel */
212#define VBOX_MOUSE_POINTER_ALPHA (0x0002)
213/** pointerData contains new pointer shape */
214#define VBOX_MOUSE_POINTER_SHAPE (0x0004)
215
216/** mouse pointer shape/visibility change request */
217typedef struct
218{
219 /** header */
220 VMMDevRequestHeader header;
221 /** VBOX_MOUSE_POINTER_* bit flags */
222 uint32_t fFlags;
223 /** x coordinate of hot spot */
224 uint32_t xHot;
225 /** y coordinate of hot spot */
226 uint32_t yHot;
227 /** width of the pointer in pixels */
228 uint32_t width;
229 /** height of the pointer in scanlines */
230 uint32_t height;
231 /** Pointer data.
232 *
233 ****
234 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
235 *
236 * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
237 * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
238 *
239 * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
240 * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
241 * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
242 *
243 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
244 * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
245 * end of any scanline are undefined.
246 *
247 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
248 * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
249 * Bytes in the gap between the AND and the XOR mask are undefined.
250 * XOR mask scanlines have no gap between them and size of XOR mask is:
251 * cXor = width * 4 * height.
252 ****
253 *
254 * Preallocate 4 bytes for accessing actual data as p->pointerData
255 */
256 char pointerData[4];
257} VMMDevReqMousePointer;
258
259/** string log request structure */
260typedef struct
261{
262 /** header */
263 VMMDevRequestHeader header;
264 /** variable length string data */
265 char szString[1];
266} VMMDevReqLogString;
267
268/** host version request structure */
269typedef struct
270{
271 /** header */
272 VMMDevRequestHeader header;
273 /** major version */
274 uint32_t major;
275 /** minor version */
276 uint32_t minor;
277 /** build number */
278 uint32_t build;
279} VMMDevReqHostVersion;
280
281/** guest capabilites structure */
282typedef struct
283{
284 /** header */
285 VMMDevRequestHeader header;
286 /** capabilities (VMMDEV_GUEST_*) */
287 uint32_t caps;
288} VMMDevReqGuestCapabilities;
289
290/** guest capabilites structure */
291typedef struct
292{
293 /** header */
294 VMMDevRequestHeader header;
295 /** mask of capabilities to be added */
296 uint32_t u32OrMask;
297 /** mask of capabilities to be removed */
298 uint32_t u32NotMask;
299} VMMDevReqGuestCapabilities2;
300
301/** idle request structure */
302typedef struct
303{
304 /** header */
305 VMMDevRequestHeader header;
306} VMMDevReqIdle;
307
308/** host time request structure */
309typedef struct
310{
311 /** header */
312 VMMDevRequestHeader header;
313 /** time in milliseconds since unix epoch. Filled by VMMDev. */
314 uint64_t time;
315} VMMDevReqHostTime;
316
317/** hypervisor info structure */
318typedef struct
319{
320 /** header */
321 VMMDevRequestHeader header;
322 /** guest virtual address of proposed hypervisor start */
323 vmmDevHypPtr hypervisorStart;
324 /** hypervisor size in bytes */
325 uint32_t hypervisorSize;
326} VMMDevReqHypervisorInfo;
327
328/** system power requests */
329typedef enum
330{
331 VMMDevPowerState_Invalid = 0,
332 VMMDevPowerState_Pause = 1,
333 VMMDevPowerState_PowerOff = 2,
334 VMMDevPowerState_SaveState = 3,
335 VMMDevPowerState_SizeHack = 0x7fffffff
336} VMMDevPowerState;
337
338/** system power status structure */
339typedef struct
340{
341 /** header */
342 VMMDevRequestHeader header;
343 /** power state request */
344 VMMDevPowerState powerState;
345} VMMDevPowerStateRequest;
346
347/** pending events structure */
348typedef struct
349{
350 /** header */
351 VMMDevRequestHeader header;
352 /** pending event bitmap */
353 uint32_t events;
354} VMMDevEvents;
355
356/** guest filter mask control */
357typedef struct
358{
359 /** header */
360 VMMDevRequestHeader header;
361 /** mask of events to be added to filter */
362 uint32_t u32OrMask;
363 /** mask of events to be removed from filter */
364 uint32_t u32NotMask;
365} VMMDevCtlGuestFilterMask;
366
367/** guest information structure */
368typedef struct VBoxGuestInfo
369{
370 /** The VMMDev interface version expected by additions. */
371 uint32_t additionsVersion;
372 /** guest OS type */
373 VBOXOSTYPE osType;
374 /** @todo */
375} VBoxGuestInfo;
376
377/** guest information structure */
378typedef struct
379{
380 /** header */
381 VMMDevRequestHeader header;
382 /** Guest information. */
383 VBoxGuestInfo guestInfo;
384} VMMDevReportGuestInfo;
385
386/** guest statistics values */
387#define VBOX_GUEST_STAT_CPU_LOAD_IDLE RT_BIT(0)
388#define VBOX_GUEST_STAT_CPU_LOAD_KERNEL RT_BIT(1)
389#define VBOX_GUEST_STAT_CPU_LOAD_USER RT_BIT(2)
390#define VBOX_GUEST_STAT_THREADS RT_BIT(3)
391#define VBOX_GUEST_STAT_PROCESSES RT_BIT(4)
392#define VBOX_GUEST_STAT_HANDLES RT_BIT(5)
393#define VBOX_GUEST_STAT_MEMORY_LOAD RT_BIT(6)
394#define VBOX_GUEST_STAT_PHYS_MEM_TOTAL RT_BIT(7)
395#define VBOX_GUEST_STAT_PHYS_MEM_AVAIL RT_BIT(8)
396#define VBOX_GUEST_STAT_PHYS_MEM_BALLOON RT_BIT(9)
397#define VBOX_GUEST_STAT_MEM_COMMIT_TOTAL RT_BIT(10)
398#define VBOX_GUEST_STAT_MEM_KERNEL_TOTAL RT_BIT(11)
399#define VBOX_GUEST_STAT_MEM_KERNEL_PAGED RT_BIT(12)
400#define VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED RT_BIT(13)
401#define VBOX_GUEST_STAT_MEM_SYSTEM_CACHE RT_BIT(14)
402#define VBOX_GUEST_STAT_PAGE_FILE_SIZE RT_BIT(15)
403
404
405/** guest statistics structure */
406typedef struct VBoxGuestStatistics
407{
408 /** Virtual CPU id */
409 uint32_t u32CpuId;
410 /** Reported statistics */
411 uint32_t u32StatCaps;
412 /** Idle CPU load (0-100) for last interval */
413 uint32_t u32CpuLoad_Idle;
414 /** Kernel CPU load (0-100) for last interval */
415 uint32_t u32CpuLoad_Kernel;
416 /** User CPU load (0-100) for last interval */
417 uint32_t u32CpuLoad_User;
418 /** Nr of threads */
419 uint32_t u32Threads;
420 /** Nr of processes */
421 uint32_t u32Processes;
422 /** Nr of handles */
423 uint32_t u32Handles;
424 /** Memory load (0-100) */
425 uint32_t u32MemoryLoad;
426 /** Page size of guest system */
427 uint32_t u32PageSize;
428 /** Total physical memory (in 4kb pages) */
429 uint32_t u32PhysMemTotal;
430 /** Available physical memory (in 4kb pages) */
431 uint32_t u32PhysMemAvail;
432 /** Ballooned physical memory (in 4kb pages) */
433 uint32_t u32PhysMemBalloon;
434 /** Total number of committed memory (which is not necessarily in-use) (in 4kb pages) */
435 uint32_t u32MemCommitTotal;
436 /** Total amount of memory used by the kernel (in 4kb pages) */
437 uint32_t u32MemKernelTotal;
438 /** Total amount of paged memory used by the kernel (in 4kb pages) */
439 uint32_t u32MemKernelPaged;
440 /** Total amount of nonpaged memory used by the kernel (in 4kb pages) */
441 uint32_t u32MemKernelNonPaged;
442 /** Total amount of memory used for the system cache (in 4kb pages) */
443 uint32_t u32MemSystemCache;
444 /** Pagefile size (in 4kb pages) */
445 uint32_t u32PageFileSize;
446} VBoxGuestStatistics;
447
448/** guest statistics command structure */
449typedef struct
450{
451 /** header */
452 VMMDevRequestHeader header;
453 /** Guest information. */
454 VBoxGuestStatistics guestStats;
455} VMMDevReportGuestStats;
456
457/** memory balloon change request structure */
458#define VMMDEV_MAX_MEMORY_BALLOON(PhysMemTotal) ((90*PhysMemTotal)/100)
459
460typedef struct
461{
462 /** header */
463 VMMDevRequestHeader header;
464 uint32_t u32BalloonSize; /* balloon size in megabytes */
465 uint32_t u32PhysMemSize; /* guest ram size in megabytes */
466 uint32_t eventAck;
467} VMMDevGetMemBalloonChangeRequest;
468
469/** inflate/deflate memory balloon structure */
470#define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (_1M/4096)
471#define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE (VMMDEV_MEMORY_BALLOON_CHUNK_PAGES*4096)
472
473typedef struct
474{
475 /** header */
476 VMMDevRequestHeader header;
477 uint32_t cPages;
478 uint32_t fInflate; /* true = inflate, false = defalte */
479 /** Physical address (RTGCPHYS) of each page, variable size. */
480 RTGCPHYS aPhysPage[1];
481} VMMDevChangeMemBalloon;
482
483/** guest statistics interval change request structure */
484typedef struct
485{
486 /** header */
487 VMMDevRequestHeader header;
488 uint32_t u32StatInterval; /* interval in seconds */
489 uint32_t eventAck;
490} VMMDevGetStatisticsChangeRequest;
491
492/** display change request structure */
493typedef struct
494{
495 /** header */
496 VMMDevRequestHeader header;
497 /** horizontal pixel resolution (0 = do not change) */
498 uint32_t xres;
499 /** vertical pixel resolution (0 = do not change) */
500 uint32_t yres;
501 /** bits per pixel (0 = do not change) */
502 uint32_t bpp;
503 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
504 * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
505 */
506 uint32_t eventAck;
507} VMMDevDisplayChangeRequest;
508
509typedef struct
510{
511 /** header */
512 VMMDevRequestHeader header;
513 /** horizontal pixel resolution (0 = do not change) */
514 uint32_t xres;
515 /** vertical pixel resolution (0 = do not change) */
516 uint32_t yres;
517 /** bits per pixel (0 = do not change) */
518 uint32_t bpp;
519 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
520 * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
521 */
522 uint32_t eventAck;
523 /** 0 for primary display, 1 for the first secondary, etc. */
524 uint32_t display;
525} VMMDevDisplayChangeRequest2;
526
527/** video mode supported request structure */
528typedef struct
529{
530 /** header */
531 VMMDevRequestHeader header;
532 /** horizontal pixel resolution (input) */
533 uint32_t width;
534 /** vertical pixel resolution (input) */
535 uint32_t height;
536 /** bits per pixel (input) */
537 uint32_t bpp;
538 /** supported flag (output) */
539 bool fSupported;
540} VMMDevVideoModeSupportedRequest;
541
542/** video modes height reduction request structure */
543typedef struct
544{
545 /** header */
546 VMMDevRequestHeader header;
547 /** height reduction in pixels (output) */
548 uint32_t heightReduction;
549} VMMDevGetHeightReductionRequest;
550
551#define VRDP_EXPERIENCE_LEVEL_ZERO 0 /* Theming disabled. */
552#define VRDP_EXPERIENCE_LEVEL_LOW 1 /* Full window dragging and desktop wallpaper disabled. */
553#define VRDP_EXPERIENCE_LEVEL_MEDIUM 2 /* Font smoothing, gradients. */
554#define VRDP_EXPERIENCE_LEVEL_HIGH 3 /* Animation effects disabled. */
555#define VRDP_EXPERIENCE_LEVEL_FULL 4 /* Everything enabled. */
556
557typedef struct
558{
559 /** header */
560 VMMDevRequestHeader header;
561 /** Whether VRDP is active or not */
562 uint8_t u8VRDPActive;
563 /** The configured experience level for active VRDP. */
564 uint32_t u32VRDPExperienceLevel;
565} VMMDevVRDPChangeRequest;
566
567
568
569#pragma pack()
570
571#ifdef VBOX_HGCM
572
573/** HGCM flags.
574 * @{
575 */
576#define VBOX_HGCM_REQ_DONE (0x1)
577#define VBOX_HGCM_REQ_CANCELLED (0x2)
578/** @} */
579
580#pragma pack(4)
581typedef struct _VMMDevHGCMRequestHeader
582{
583 /** Request header. */
584 VMMDevRequestHeader header;
585
586 /** HGCM flags. */
587 uint32_t fu32Flags;
588
589 /** Result code. */
590 int32_t result;
591} VMMDevHGCMRequestHeader;
592
593/** HGCM service location types. */
594typedef enum
595{
596 VMMDevHGCMLoc_Invalid = 0,
597 VMMDevHGCMLoc_LocalHost = 1,
598 VMMDevHGCMLoc_LocalHost_Existing = 2,
599 VMMDevHGCMLoc_SizeHack = 0x7fffffff
600} HGCMServiceLocationType;
601
602typedef struct
603{
604 char achName[128];
605} HGCMServiceLocationHost;
606
607typedef struct HGCMSERVICELOCATION
608{
609 /** Type of the location. */
610 HGCMServiceLocationType type;
611
612 union
613 {
614 HGCMServiceLocationHost host;
615 } u;
616} HGCMServiceLocation;
617
618typedef struct
619{
620 /* request header */
621 VMMDevHGCMRequestHeader header;
622
623 /** IN: Description of service to connect to. */
624 HGCMServiceLocation loc;
625
626 /** OUT: Client identifier assigned by local instance of HGCM. */
627 uint32_t u32ClientID;
628} VMMDevHGCMConnect;
629
630typedef struct
631{
632 /* request header */
633 VMMDevHGCMRequestHeader header;
634
635 /** IN: Client identifier. */
636 uint32_t u32ClientID;
637} VMMDevHGCMDisconnect;
638
639typedef enum
640{
641 VMMDevHGCMParmType_Invalid = 0,
642 VMMDevHGCMParmType_32bit = 1,
643 VMMDevHGCMParmType_64bit = 2,
644 VMMDevHGCMParmType_PhysAddr = 3,
645 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
646 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */
647 VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */
648 VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */
649 VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */
650 VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */
651 VMMDevHGCMParmType_SizeHack = 0x7fffffff
652} HGCMFunctionParameterType;
653
654typedef struct _HGCMFUNCTIONPARAMETER
655{
656 HGCMFunctionParameterType type;
657 union
658 {
659 uint32_t value32;
660 uint64_t value64;
661 struct
662 {
663 uint32_t size;
664
665 union
666 {
667 vmmDevHypPhys physAddr;
668 vmmDevHypPtr linearAddr;
669 } u;
670 } Pointer;
671 } u;
672} HGCMFunctionParameter;
673
674typedef struct
675{
676 /* request header */
677 VMMDevHGCMRequestHeader header;
678
679 /** IN: Client identifier. */
680 uint32_t u32ClientID;
681 /** IN: Service function number. */
682 uint32_t u32Function;
683 /** IN: Number of parameters. */
684 uint32_t cParms;
685 /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
686} VMMDevHGCMCall;
687#pragma pack()
688
689#define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((char *)a + sizeof (VMMDevHGCMCall)))
690
691#define VBOX_HGCM_MAX_PARMS 32
692
693#endif /* VBOX_HGCM */
694
695
696#define VBVA_F_STATUS_ACCEPTED (0x01)
697#define VBVA_F_STATUS_ENABLED (0x02)
698
699#pragma pack(4)
700
701typedef struct _VMMDevVideoAccelEnable
702{
703 /* request header */
704 VMMDevRequestHeader header;
705
706 /** 0 - disable, !0 - enable. */
707 uint32_t u32Enable;
708
709 /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
710 * The host will refuse to enable VBVA if the size is not equal to
711 * VBVA_RING_BUFFER_SIZE.
712 */
713 uint32_t cbRingBuffer;
714
715 /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
716 uint32_t fu32Status;
717
718} VMMDevVideoAccelEnable;
719
720typedef struct _VMMDevVideoAccelFlush
721{
722 /* request header */
723 VMMDevRequestHeader header;
724
725} VMMDevVideoAccelFlush;
726
727
728typedef struct _VMMDevVideoSetVisibleRegion
729{
730 /* request header */
731 VMMDevRequestHeader header;
732
733 /** Number of rectangles */
734 uint32_t cRect;
735
736 /** Rectangle array */
737 RTRECT Rect;
738} VMMDevVideoSetVisibleRegion;
739
740
741/** Seamless mode */
742typedef enum
743{
744 VMMDev_Seamless_Disabled = 0, /* normal mode; entire guest desktop displayed */
745 VMMDev_Seamless_Visible_Region = 1, /* visible region mode; only top-level guest windows displayed */
746 VMMDev_Seamless_Host_Window = 2 /* windowed mode; each top-level guest window is represented in a host window */
747} VMMDevSeamlessMode;
748
749typedef struct
750{
751 /** header */
752 VMMDevRequestHeader header;
753
754 /** New seamless mode */
755 VMMDevSeamlessMode mode;
756 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST.
757 * Values: 0 - just querying, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST - event acknowledged.
758 */
759 uint32_t eventAck;
760} VMMDevSeamlessChangeRequest;
761
762#pragma pack()
763
764#pragma pack(1)
765/** VBVA command header. */
766typedef struct _VBVACMDHDR
767{
768 /** Coordinates of affected rectangle. */
769 int16_t x;
770 int16_t y;
771 uint16_t w;
772 uint16_t h;
773} VBVACMDHDR;
774#pragma pack()
775
776/* The VBVA ring buffer is suitable for transferring large (< 2gb) amount of data.
777 * For example big bitmaps which do not fit to the buffer.
778 *
779 * Guest starts writing to the buffer by initializing a record entry in the
780 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
781 * written. As data is written to the ring buffer, the guest increases off32End
782 * for the record.
783 *
784 * The host reads the aRecords on flushes and processes all completed records.
785 * When host encounters situation when only a partial record presents and
786 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE - VBVA_RING_BUFFER_THRESHOLD,
787 * the host fetched all record data and updates off32Head. After that on each flush
788 * the host continues fetching the data until the record is completed.
789 *
790 */
791
792#define VBVA_RING_BUFFER_SIZE (_4M - _1K)
793#define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
794
795#define VBVA_MAX_RECORDS (64)
796
797#define VBVA_F_MODE_ENABLED (0x00000001)
798#define VBVA_F_MODE_VRDP (0x00000002)
799#define VBVA_F_MODE_VRDP_RESET (0x00000004)
800#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
801
802#define VBVA_F_RECORD_PARTIAL (0x80000000)
803
804#pragma pack(1)
805typedef struct _VBVARECORD
806{
807 /** The length of the record. Changed by guest. */
808 uint32_t cbRecord;
809} VBVARECORD;
810
811typedef struct _VBVAMEMORY
812{
813 /** VBVA_F_MODE_* */
814 uint32_t fu32ModeFlags;
815
816 /** The offset where the data start in the buffer. */
817 uint32_t off32Data;
818 /** The offset where next data must be placed in the buffer. */
819 uint32_t off32Free;
820
821 /** The ring buffer for data. */
822 uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
823
824 /** The queue of record descriptions. */
825 VBVARECORD aRecords[VBVA_MAX_RECORDS];
826 uint32_t indexRecordFirst;
827 uint32_t indexRecordFree;
828
829 /* RDP orders supported by the client. The guest reports only them
830 * and falls back to DIRTY rects for not supported ones.
831 *
832 * (1 << VBVA_VRDP_*)
833 */
834 uint32_t fu32SupportedOrders;
835
836} VBVAMEMORY;
837#pragma pack()
838
839/** @} */
840
841
842/**
843 * VMMDev RAM
844 * @{
845 */
846
847#pragma pack(1)
848/** Layout of VMMDEV RAM region that contains information for guest */
849typedef struct
850{
851 /** size */
852 uint32_t u32Size;
853 /** version */
854 uint32_t u32Version;
855
856 union {
857 /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
858 struct {
859 bool fHaveEvents;
860 } V1_04;
861
862 struct {
863 /** Pending events flags, set by host. */
864 uint32_t u32HostEvents;
865 /** Mask of events the guest wants to see, set by guest. */
866 uint32_t u32GuestEventMask;
867 } V1_03;
868 } V;
869
870 VBVAMEMORY vbvaMemory;
871
872} VMMDevMemory;
873#pragma pack()
874
875/** Version of VMMDevMemory structure. */
876#define VMMDEV_MEMORY_VERSION (1)
877
878/** @} */
879
880
881/**
882 * VMMDev events.
883 * @{
884 */
885
886/** Host mouse capabilities has been changed. */
887#define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED RT_BIT(0)
888/** HGCM event. */
889#define VMMDEV_EVENT_HGCM RT_BIT(1)
890/** A display change request has been issued. */
891#define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST RT_BIT(2)
892/** Credentials are available for judgement. */
893#define VMMDEV_EVENT_JUDGE_CREDENTIALS RT_BIT(3)
894/** The guest has been restored. */
895#define VMMDEV_EVENT_RESTORED RT_BIT(4)
896/** Seamless mode state changed */
897#define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST RT_BIT(5)
898/** Memory balloon size changed */
899#define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST RT_BIT(6)
900/** Statistics interval changed */
901#define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST RT_BIT(7)
902/** VRDP status changed. */
903#define VMMDEV_EVENT_VRDP RT_BIT(8)
904
905/** @} */
906
907
908/**
909 * VBoxGuest IOCTL codes and structures.
910 *
911 * The range 0..15 is for basic driver communication.
912 * The range 16..31 is for HGCM communcation.
913 * The range 32..47 is reserved for future use.
914 * The range 48..63 is for OS specific communcation.
915 * The 7th bit is reserved for future hacks.
916 * The 8th bit is reserved for distinguishing between 32-bit and 64-bit
917 * processes in future 64-bit guest additions.
918 *
919 * While windows IOCTL function number has to start at 2048 and stop at 4096 there
920 * never was any need to do this for everyone. A simple ((Function) | 0x800) would
921 * have sufficed. On Linux we're now intruding upon the type field. Fortunately
922 * this hasn't caused any trouble because the FILE_DEVICE_UNKNOWN value was set
923 * to 0x22 (if it were 0x2C it would not have worked soo smoothly). The situation
924 * would've been the same for *BSD and Darwin since they seems to share common
925 * _IOC() heritage.
926 *
927 * However, on good old OS/2 we only have 8-bit handy for the function number. The
928 * result from using the old IOCTL function numbers her would've been overlapping
929 * between the two ranges.
930 *
931 * To fix this problem and get rid of all the unnecessary windowsy crap that I
932 * bet was copied from my SUPDRVIOC.h once upon a time (although the concept of
933 * prefixing macros with the purpose of avoid clashes with system stuff and
934 * to indicate exactly how owns them seems to have been lost somewhere along
935 * the way), I've introduced a VBOXGUEST_IOCTL_CODE for defining generic IN/OUT
936 * IOCtls on new ports of the additions.
937 *
938 * @remarks When creating new IOCtl interfaces keep in mind that not all OSes supports
939 * reporting back the output size. (This got messed up a little bit in VBoxDrv.)
940 *
941 * The request size is also a little bit tricky as it's passed as part of the
942 * request code on unix. The size field is 14 bits on Linux, 12 bits on *BSD,
943 * 13 bits Darwin, and 8-bits on Solaris. All the BSDs and Darwin kernels
944 * will make use of the size field, while Linux and Solaris will not. We're of
945 * course using the size to validate and/or map/lock the request, so it has
946 * to be valid.
947 *
948 * For Solaris we will have to do something special though, 255 isn't
949 * sufficent for all we need. A 4KB restriction (BSD) is probably not
950 * too problematic (yet) as a general one.
951 *
952 * More info can be found in SUPDRVIOC.h and related sources.
953 *
954 * @remarks If adding interfaces that only has input or only has output, some new macros
955 * needs to be created so the most efficient IOCtl data buffering method can be
956 * used.
957 * @{
958 */
959#ifdef RT_ARCH_AMD64
960# define VBOXGUEST_IOCTL_FLAG 128
961#elif defined(RT_ARCH_X86)
962# define VBOXGUEST_IOCTL_FLAG 0
963#else
964# error "dunno which arch this is!"
965#endif
966
967/** Ring-3 request wrapper for big requests.
968 *
969 * This is necessary because the ioctl number scheme on many Unixy OSes (esp. Solaris)
970 * only allows a relatively small size to be encoded into the request. So, for big
971 * request this generic form is used instead. */
972typedef struct VBGLBIGREQ
973{
974 /** Magic value (VBGLBIGREQ_MAGIC). */
975 uint32_t u32Magic;
976 /** The size of the data buffer. */
977 uint32_t cbData;
978 /** The user address of the data buffer. */
979 RTR3PTR pvDataR3;
980} VBGLBIGREQ;
981/** Pointer to a request wrapper for solaris guests. */
982typedef VBGLBIGREQ *PVBGLBIGREQ;
983/** Pointer to a const request wrapper for solaris guests. */
984typedef const VBGLBIGREQ *PCVBGLBIGREQ;
985
986/** The VBGLBIGREQ::u32Magic value (Ryuu Murakami). */
987#define VBGLBIGREQ_MAGIC 0x19520219
988
989
990#if defined(RT_OS_WINDOWS)
991 /* legacy encoding. */
992# define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
993 ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
994
995#elif defined(RT_OS_OS2)
996 /* No automatic buffering, size not encoded. */
997# define VBOXGUEST_IOCTL_CATEGORY 0xc2
998# define VBOXGUEST_IOCTL_CODE(Function, Size) ((unsigned char)(Function))
999# define VBOXGUEST_IOCTL_CATEGORY_FAST 0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
1000# define VBOXGUEST_IOCTL_CODE_FAST(Function) ((unsigned char)(Function))
1001# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) (Code)
1002
1003#elif defined(RT_OS_SOLARIS)
1004 /* No automatic buffering, size limited to 255 bytes => use VBGLBIGREQ for everything. */
1005# include <sys/ioccom.h>
1006# define VBOXGUEST_IOCTL_CODE(Function, Size) _IOWRN('V', (Function) | VBOXGUEST_IOCTL_FLAG, sizeof(VBGLBIGREQ))
1007# define VBOXGUEST_IOCTL_CODE_FAST(Function) _IO( 'V', (Function) | VBOXGUEST_IOCTL_FLAG)
1008# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) (Code)
1009
1010#elif defined(RT_OS_LINUX)
1011 /* No automatic buffering, size limited to 16KB. */
1012# include <linux/ioctl.h>
1013# define VBOXGUEST_IOCTL_CODE(Function, Size) _IOC(_IOC_READ|_IOC_WRITE, 'V', (Function) | VBOXGUEST_IOCTL_FLAG, (Size))
1014# define VBOXGUEST_IOCTL_CODE_FAST(Function) _IO( 'V', (Function) | VBOXGUEST_IOCTL_FLAG)
1015# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) VBOXGUEST_IOCTL_CODE(_IOC_NR((Code)), 0)
1016
1017#elif 0 /* BSD style - needs some adjusting since _IORW takes a type and not a size. */
1018# include <sys/ioccom.h>
1019# define VBOXGUEST_IOCTL_CODE(Function, Size) _IORW('V', (Function) | VBOXGUEST_IOCTL_FLAG, (Size))
1020# define VBOXGUEST_IOCTL_CODE_FAST(Function) _IO( 'V', (Function) | VBOXGUEST_IOCTL_FLAG)
1021# define VBOXGUEST_IOCTL_STRIP_SIZE(Code) IOCBASECMD(Code)
1022
1023#else
1024/* PORTME */
1025#endif
1026
1027/** IOCTL to VBoxGuest to query the VMMDev IO port region start. */
1028#ifdef VBOXGUEST_IOCTL_CODE
1029# define VBOXGUEST_IOCTL_GETVMMDEVPORT VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
1030# define IOCTL_VBOXGUEST_GETVMMDEVPORT VBOXGUEST_IOCTL_GETVMMDEVPORT
1031#else
1032# define IOCTL_VBOXGUEST_GETVMMDEVPORT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestPortInfo))
1033#endif
1034
1035#pragma pack(4)
1036typedef struct _VBoxGuestPortInfo
1037{
1038 uint32_t portAddress;
1039 VMMDevMemory *pVMMDevMemory;
1040} VBoxGuestPortInfo;
1041
1042/** IOCTL to VBoxGuest to wait for a VMMDev host notification */
1043#ifdef VBOXGUEST_IOCTL_CODE
1044# define VBOXGUEST_IOCTL_WAITEVENT VBOXGUEST_IOCTL_CODE(2, sizeof(VBoxGuestWaitEventInfo))
1045# define IOCTL_VBOXGUEST_WAITEVENT VBOXGUEST_IOCTL_WAITEVENT
1046#else
1047# define IOCTL_VBOXGUEST_WAITEVENT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2049, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestWaitEventInfo))
1048#endif
1049
1050/** IOCTL to VBoxGuest to interrupt (cancel) any pending WAITEVENTs and return.
1051 * Handled inside the guest additions and not seen by the host at all.
1052 * @see VBOXGUEST_IOCTL_WAITEVENT */
1053#ifdef VBOXGUEST_IOCTL_CODE
1054# define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS VBOXGUEST_IOCTL_CODE(5, 0)
1055#else
1056# define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2054, METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
1057#endif
1058
1059/**
1060 * Result codes for VBoxGuestWaitEventInfo::u32Result
1061 * @{
1062 */
1063/** Successful completion, an event occured. */
1064#define VBOXGUEST_WAITEVENT_OK (0)
1065/** Successful completion, timed out. */
1066#define VBOXGUEST_WAITEVENT_TIMEOUT (1)
1067/** Wait was interrupted. */
1068#define VBOXGUEST_WAITEVENT_INTERRUPTED (2)
1069/** An error occured while processing the request. */
1070#define VBOXGUEST_WAITEVENT_ERROR (3)
1071/** @} */
1072
1073/** Input and output buffers layout of the IOCTL_VBOXGUEST_WAITEVENT */
1074typedef struct _VBoxGuestWaitEventInfo
1075{
1076 /** timeout in milliseconds */
1077 uint32_t u32TimeoutIn;
1078 /** events to wait for */
1079 uint32_t u32EventMaskIn;
1080 /** result code */
1081 uint32_t u32Result;
1082 /** events occured */
1083 uint32_t u32EventFlagsOut;
1084} VBoxGuestWaitEventInfo;
1085
1086/** IOCTL to VBoxGuest to perform a VMM request
1087 * @remark The data buffer for this IOCtl has an variable size, keep this in mind
1088 * on systems where this matters. */
1089#ifdef VBOXGUEST_IOCTL_CODE
1090# define VBOXGUEST_IOCTL_VMMREQUEST(Size) VBOXGUEST_IOCTL_CODE(3, (Size))
1091# define IOCTL_VBOXGUEST_VMMREQUEST VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevRequestHeader))
1092#else
1093# define IOCTL_VBOXGUEST_VMMREQUEST IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2050, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VMMDevRequestHeader))
1094#endif
1095
1096/** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
1097typedef struct _VBoxGuestFilterMaskInfo
1098{
1099 uint32_t u32OrMask;
1100 uint32_t u32NotMask;
1101} VBoxGuestFilterMaskInfo;
1102#pragma pack()
1103
1104/** IOCTL to VBoxGuest to control event filter mask. */
1105#ifdef VBOXGUEST_IOCTL_CODE
1106# define VBOXGUEST_IOCTL_CTL_FILTER_MASK VBOXGUEST_IOCTL_CODE(4, sizeof(VBoxGuestFilterMaskInfo))
1107# define IOCTL_VBOXGUEST_CTL_FILTER_MASK VBOXGUEST_IOCTL_CTL_FILTER_MASK
1108#else
1109# define IOCTL_VBOXGUEST_CTL_FILTER_MASK IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2051, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof (VBoxGuestFilterMaskInfo))
1110#endif
1111
1112/** IOCTL to VBoxGuest to check memory ballooning. */
1113#ifdef VBOXGUEST_IOCTL_CODE
1114# define VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK VBOXGUEST_IOCTL_CODE(4, 100)
1115# define IOCTL_VBOXGUEST_CTL_CHECK_BALLOON VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK
1116#else
1117# define IOCTL_VBOXGUEST_CTL_CHECK_BALLOON IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2052, METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
1118#endif
1119
1120/** IOCTL to VBoxGuest to perform backdoor logging. */
1121#ifdef VBOXGUEST_IOCTL_CODE
1122# define VBOXGUEST_IOCTL_LOG(Size) VBOXGUEST_IOCTL_CODE(6, (Size))
1123#else
1124# define VBOXGUEST_IOCTL_LOG(Size) IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2055, METHOD_BUFFERED, FILE_WRITE_ACCESS, (Size))
1125#endif
1126
1127
1128#ifdef VBOX_HGCM
1129/* These structures are shared between the driver and other binaries,
1130 * therefore packing must be defined explicitely.
1131 */
1132#pragma pack(1)
1133typedef struct _VBoxGuestHGCMConnectInfo
1134{
1135 uint32_t result; /**< OUT */
1136 HGCMServiceLocation Loc; /**< IN */
1137 uint32_t u32ClientID; /**< OUT */
1138} VBoxGuestHGCMConnectInfo;
1139
1140typedef struct _VBoxGuestHGCMDisconnectInfo
1141{
1142 uint32_t result; /**< OUT */
1143 uint32_t u32ClientID; /**< IN */
1144} VBoxGuestHGCMDisconnectInfo;
1145
1146typedef struct _VBoxGuestHGCMCallInfo
1147{
1148 uint32_t result; /**< OUT Host HGCM return code.*/
1149 uint32_t u32ClientID; /**< IN The id of the caller. */
1150 uint32_t u32Function; /**< IN Function number. */
1151 uint32_t cParms; /**< IN How many parms. */
1152 /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
1153} VBoxGuestHGCMCallInfo;
1154#pragma pack()
1155
1156#ifdef VBOXGUEST_IOCTL_CODE
1157# define VBOXGUEST_IOCTL_HGCM_CONNECT VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
1158# define IOCTL_VBOXGUEST_HGCM_CONNECT VBOXGUEST_IOCTL_HGCM_CONNECT
1159# define VBOXGUEST_IOCTL_HGCM_DISCONNECT VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
1160# define IOCTL_VBOXGUEST_HGCM_DISCONNECT VBOXGUEST_IOCTL_HGCM_DISCONNECT
1161# define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18, (Size))
1162# define IOCTL_VBOXGUEST_HGCM_CALL VBOXGUEST_IOCTL_HGCM_CALL(sizeof(VBoxGuestHGCMCallInfo))
1163# define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CODE(19, sizeof(uint32_t))
1164# define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CLIPBOARD_CONNECT
1165#else
1166# define IOCTL_VBOXGUEST_HGCM_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3072, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMConnectInfo))
1167# define IOCTL_VBOXGUEST_HGCM_DISCONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3073, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMDisconnectInfo))
1168# define IOCTL_VBOXGUEST_HGCM_CALL IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3074, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMCallInfo))
1169# define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3075, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(uint32_t))
1170#endif
1171
1172#define VBOXGUEST_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
1173
1174#endif /* VBOX_HGCM */
1175
1176/*
1177 * Credentials request flags and structure
1178 */
1179
1180#define VMMDEV_CREDENTIALS_STRLEN 128
1181
1182/** query from host whether credentials are present */
1183#define VMMDEV_CREDENTIALS_QUERYPRESENCE RT_BIT(1)
1184/** read credentials from host (can be combined with clear) */
1185#define VMMDEV_CREDENTIALS_READ RT_BIT(2)
1186/** clear credentials on host (can be combined with read) */
1187#define VMMDEV_CREDENTIALS_CLEAR RT_BIT(3)
1188/** read credentials for judgement in the guest */
1189#define VMMDEV_CREDENTIALS_READJUDGE RT_BIT(8)
1190/** clear credentials for judegement on the host */
1191#define VMMDEV_CREDENTIALS_CLEARJUDGE RT_BIT(9)
1192/** report credentials acceptance by guest */
1193#define VMMDEV_CREDENTIALS_JUDGE_OK RT_BIT(10)
1194/** report credentials denial by guest */
1195#define VMMDEV_CREDENTIALS_JUDGE_DENY RT_BIT(11)
1196/** report that no judgement could be made by guest */
1197#define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT RT_BIT(12)
1198
1199/** flag telling the guest that credentials are present */
1200#define VMMDEV_CREDENTIALS_PRESENT RT_BIT(16)
1201/** flag telling guest that local logons should be prohibited */
1202#define VMMDEV_CREDENTIALS_NOLOCALLOGON RT_BIT(17)
1203
1204/** credentials request structure */
1205#pragma pack(4)
1206typedef struct _VMMDevCredentials
1207{
1208 /* request header */
1209 VMMDevRequestHeader header;
1210 /* request flags (in/out) */
1211 uint32_t u32Flags;
1212 /* user name (UTF-8) (out) */
1213 char szUserName[VMMDEV_CREDENTIALS_STRLEN];
1214 /* password (UTF-8) (out) */
1215 char szPassword[VMMDEV_CREDENTIALS_STRLEN];
1216 /* domain name (UTF-8) (out) */
1217 char szDomain[VMMDEV_CREDENTIALS_STRLEN];
1218} VMMDevCredentials;
1219#pragma pack()
1220
1221/** inline helper to determine the request size for the given operation */
1222DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
1223{
1224 switch (requestType)
1225 {
1226 case VMMDevReq_GetMouseStatus:
1227 case VMMDevReq_SetMouseStatus:
1228 return sizeof(VMMDevReqMouseStatus);
1229 case VMMDevReq_SetPointerShape:
1230 return sizeof(VMMDevReqMousePointer);
1231 case VMMDevReq_GetHostVersion:
1232 return sizeof(VMMDevReqHostVersion);
1233 case VMMDevReq_Idle:
1234 return sizeof(VMMDevReqIdle);
1235 case VMMDevReq_GetHostTime:
1236 return sizeof(VMMDevReqHostTime);
1237 case VMMDevReq_GetHypervisorInfo:
1238 case VMMDevReq_SetHypervisorInfo:
1239 return sizeof(VMMDevReqHypervisorInfo);
1240 case VMMDevReq_SetPowerStatus:
1241 return sizeof(VMMDevPowerStateRequest);
1242 case VMMDevReq_AcknowledgeEvents:
1243 return sizeof(VMMDevEvents);
1244 case VMMDevReq_ReportGuestInfo:
1245 return sizeof(VMMDevReportGuestInfo);
1246 case VMMDevReq_GetDisplayChangeRequest:
1247 return sizeof(VMMDevDisplayChangeRequest);
1248 case VMMDevReq_GetDisplayChangeRequest2:
1249 return sizeof(VMMDevDisplayChangeRequest2);
1250 case VMMDevReq_VideoModeSupported:
1251 return sizeof(VMMDevVideoModeSupportedRequest);
1252 case VMMDevReq_GetHeightReduction:
1253 return sizeof(VMMDevGetHeightReductionRequest);
1254 case VMMDevReq_ReportGuestCapabilities:
1255 return sizeof(VMMDevReqGuestCapabilities);
1256#ifdef VBOX_HGCM
1257 case VMMDevReq_HGCMConnect:
1258 return sizeof(VMMDevHGCMConnect);
1259 case VMMDevReq_HGCMDisconnect:
1260 return sizeof(VMMDevHGCMDisconnect);
1261 case VMMDevReq_HGCMCall:
1262 return sizeof(VMMDevHGCMCall);
1263#endif
1264 case VMMDevReq_VideoAccelEnable:
1265 return sizeof(VMMDevVideoAccelEnable);
1266 case VMMDevReq_VideoAccelFlush:
1267 return sizeof(VMMDevVideoAccelFlush);
1268 case VMMDevReq_VideoSetVisibleRegion:
1269 return sizeof(VMMDevVideoSetVisibleRegion);
1270 case VMMDevReq_GetSeamlessChangeRequest:
1271 return sizeof(VMMDevSeamlessChangeRequest);
1272 case VMMDevReq_QueryCredentials:
1273 return sizeof(VMMDevCredentials);
1274 case VMMDevReq_ReportGuestStats:
1275 return sizeof(VMMDevReportGuestStats);
1276 case VMMDevReq_GetMemBalloonChangeRequest:
1277 return sizeof(VMMDevGetMemBalloonChangeRequest);
1278 case VMMDevReq_GetStatisticsChangeRequest:
1279 return sizeof(VMMDevGetStatisticsChangeRequest);
1280 case VMMDevReq_ChangeMemBalloon:
1281 return sizeof(VMMDevChangeMemBalloon);
1282 case VMMDevReq_GetVRDPChangeRequest:
1283 return sizeof(VMMDevVRDPChangeRequest);
1284 case VMMDevReq_LogString:
1285 return sizeof(VMMDevReqLogString);
1286 default:
1287 return 0;
1288 }
1289}
1290
1291/**
1292 * Initializes a request structure.
1293 *
1294 */
1295DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
1296{
1297 uint32_t requestSize;
1298 if (!req)
1299 return VERR_INVALID_PARAMETER;
1300 requestSize = (uint32_t)vmmdevGetRequestSize(type);
1301 if (!requestSize)
1302 return VERR_INVALID_PARAMETER;
1303 req->size = requestSize;
1304 req->version = VMMDEV_REQUEST_HEADER_VERSION;
1305 req->requestType = type;
1306 req->rc = VERR_GENERAL_FAILURE;
1307 req->reserved1 = 0;
1308 req->reserved2 = 0;
1309 return VINF_SUCCESS;
1310}
1311
1312
1313#ifdef RT_OS_OS2
1314
1315/**
1316 * The data buffer layout for the IDC entry point (AttachDD).
1317 *
1318 * @remark This is defined in multiple 16-bit headers / sources.
1319 * Some places it's called VBGOS2IDC to short things a bit.
1320 */
1321typedef struct VBOXGUESTOS2IDCCONNECT
1322{
1323 /** VMMDEV_VERSION. */
1324 uint32_t u32Version;
1325 /** Opaque session handle. */
1326 uint32_t u32Session;
1327
1328 /**
1329 * The 32-bit service entry point.
1330 *
1331 * @returns VBox status code.
1332 * @param u32Session The above session handle.
1333 * @param iFunction The requested function.
1334 * @param pvData The input/output data buffer. The caller ensures that this
1335 * cannot be swapped out, or that it's acceptable to take a
1336 * page in fault in the current context. If the request doesn't
1337 * take input or produces output, apssing NULL is okay.
1338 * @param cbData The size of the data buffer.
1339 * @param pcbDataReturned Where to store the amount of data that's returned.
1340 * This can be NULL if pvData is NULL.
1341 */
1342 DECLCALLBACKMEMBER(int, pfnServiceEP)(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned);
1343
1344 /** The 16-bit service entry point for C code (cdecl).
1345 *
1346 * It's the same as the 32-bit entry point, but the types has
1347 * changed to 16-bit equivalents.
1348 *
1349 * @code
1350 * int far cdecl
1351 * VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction,
1352 * void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);
1353 * @endcode
1354 */
1355 RTFAR16 fpfnServiceEP;
1356
1357 /** The 16-bit service entry point for Assembly code (register).
1358 *
1359 * This is just a wrapper around fpfnServiceEP to simplify calls
1360 * from 16-bit assembly code.
1361 *
1362 * @returns (e)ax: VBox status code; cx: The amount of data returned.
1363 *
1364 * @param u32Session eax - The above session handle.
1365 * @param iFunction dl - The requested function.
1366 * @param pvData es:bx - The input/output data buffer.
1367 * @param cbData cx - The size of the data buffer.
1368 */
1369 RTFAR16 fpfnServiceAsmEP;
1370} VBOXGUESTOS2IDCCONNECT;
1371/** Pointer to VBOXGUESTOS2IDCCONNECT buffer. */
1372typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUESTOS2IDCCONNECT;
1373
1374/** OS/2 specific: IDC client disconnect request.
1375 *
1376 * This takes no input and it doesn't return anything. Obviously this
1377 * is only recognized if it arrives thru the IDC service EP.
1378 */
1379#define VBOXGUEST_IOCTL_OS2_IDC_DISCONNECT VBOXGUEST_IOCTL_CODE(48, sizeof(uint32_t))
1380
1381#endif /* RT_OS_OS2 */
1382
1383/** @} */
1384
1385
1386#ifdef IN_RING3
1387
1388/** @def VBGLR3DECL
1389 * Ring 3 VBGL declaration.
1390 * @param type The return type of the function declaration.
1391 */
1392#define VBGLR3DECL(type) type VBOXCALL
1393
1394/* General-purpose functions */
1395
1396__BEGIN_DECLS
1397VBGLR3DECL(int) VbglR3Init(void);
1398VBGLR3DECL(void) VbglR3Term(void);
1399# ifdef ___iprt_time_h
1400VBGLR3DECL(int) VbglR3GetHostTime(PRTTIMESPEC pTime);
1401# endif
1402VBGLR3DECL(int) VbglR3InterruptEventWaits(void);
1403VBGLR3DECL(int) VbglR3WriteLog(const char *pch, size_t cb);
1404VBGLR3DECL(int) VbglR3CtlFilterMask(uint32_t fOr, uint32_t fNot);
1405VBGLR3DECL(int) VbglR3Daemonize(bool fNoChDir, bool fNoClose);
1406
1407/** @name Shared clipboard
1408 * @{ */
1409VBGLR3DECL(int) VbglR3ClipboardConnect(uint32_t *pu32ClientId);
1410VBGLR3DECL(int) VbglR3ClipboardDisconnect(uint32_t u32ClientId);
1411VBGLR3DECL(int) VbglR3ClipboardGetHostMsg(uint32_t u32ClientId, uint32_t *pMsg, uint32_t *pfFormats);
1412VBGLR3DECL(int) VbglR3ClipboardReadData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb);
1413VBGLR3DECL(int) VbglR3ClipboardReportFormats(uint32_t u32ClientId, uint32_t fFormats);
1414VBGLR3DECL(int) VbglR3ClipboardWriteData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb);
1415/** @} */
1416
1417/** @name Seamless mode
1418 * @{ */
1419VBGLR3DECL(int) VbglR3SeamlessSetCap(bool fState);
1420VBGLR3DECL(int) VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode);
1421VBGLR3DECL(int) VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects);
1422/** @} */
1423
1424/** @name Mouse
1425 * @{ */
1426VBGLR3DECL(int) VbglR3GetMouseStatus(uint32_t *pfFeatures, uint32_t *px, uint32_t *py);
1427VBGLR3DECL(int) VbglR3SetMouseStatus(uint32_t fFeatures);
1428/** @} */
1429
1430/** @name Video
1431 * @{ */
1432VBGLR3DECL(int) VbglR3VideoAccelEnable(bool fEnable);
1433VBGLR3DECL(int) VbglR3VideoAccelFlush(void);
1434VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg);
1435VBGLR3DECL(int) VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq);
1436/** @} */
1437
1438/** @name Display
1439 * @{ */
1440VBGLR3DECL(int) VbglR3GetLastDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy,
1441 uint32_t *pcBits,uint32_t *piDisplay);
1442VBGLR3DECL(int) VbglR3DisplayChangeWaitEvent(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits,
1443 uint32_t *piDisplay);
1444/** @} */
1445
1446
1447__END_DECLS
1448
1449#endif /* IN_RING3 */
1450
1451#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette