VirtualBox

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

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

GC phys/virt to HC virt functions are no longer accessible in our PDM interface.
Rewrote disassembly functions to use the mapping functions.

Code that runs in EMT (like CSAM/PATM) can still use the old conversion functions. Easier to use
and (far) less overhead.

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