VirtualBox

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

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

Guest r3 lib for x11 mouse. The solaris mouse driver doesn't yet work like it should.

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

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