VirtualBox

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

Last change on this file since 8312 was 8312, checked in by vboxsync, 16 years ago

Devices/VMMDev, Frontends/VBoxBFE, Main: add a guest request to report the maximum resolution currently supported by the additions - host side

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

© 2023 Oracle
ContactPrivacy policyTerms of Use