VirtualBox

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

Last change on this file since 9387 was 9215, checked in by vboxsync, 17 years ago

Backwards compatibility.

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