VirtualBox

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

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

Updates

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