VirtualBox

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

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

Multimonitor support.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.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 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef __VBox_VBoxGuest_h__
22#define __VBox_VBoxGuest_h__
23
24#include <iprt/cdefs.h>
25#include <iprt/types.h>
26#include <VBox/err.h>
27#include <VBox/ostypes.h>
28
29/*******************************************************************************
30* Defined Constants And Macros *
31*******************************************************************************/
32
33/** @todo The following is a temporary fix for the problem of accessing
34 hypervisor pointers from within guest additions */
35
36/** Hypervisor linear pointer size type */
37typedef uint32_t vmmDevHypPtr;
38/** Hypervisor physical pointer size type */
39typedef uint32_t vmmDevHypPhys;
40
41#ifdef __WIN__
42/** The support service name. */
43#define VBOXGUEST_SERVICE_NAME "VBoxGuest"
44/** Win32 Device name. */
45#define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
46/** Global name for Win2k+ */
47#define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
48/** Win32 driver name */
49#define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
50/** device name */
51#define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
52#else /* !__WIN__ */
53#define VBOXGUEST_DEVICE_NAME "/dev/vboxadd"
54#endif
55
56/** VirtualBox vendor ID */
57#define VBOX_PCI_VENDORID (0x80ee)
58
59/** VMMDev PCI card identifiers */
60#define VMMDEV_VENDORID VBOX_PCI_VENDORID
61#define VMMDEV_DEVICEID (0xcafe)
62
63/** VirtualBox graphics card identifiers */
64#define VBOX_VENDORID VBOX_PCI_VENDORID
65#define VBOX_VESA_VENDORID VBOX_PCI_VENDORID
66#define VBOX_DEVICEID (0xbeef)
67#define VBOX_VESA_DEVICEID (0xbeef)
68
69/**
70 * VBoxGuest port definitions
71 * @{
72 */
73
74/** guest can (== wants to) handle absolute coordinates */
75#define VBOXGUEST_MOUSE_GUEST_CAN_ABSOLUTE BIT(0)
76/** host can (== wants to) send absolute coordinates */
77#define VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE BIT(1)
78/** guest can *NOT* switch to software cursor and therefore depends on the host cursor */
79#define VBOXGUEST_MOUSE_GUEST_NEEDS_HOST_CURSOR BIT(2)
80/** host does NOT provide support for drawing the cursor itself (e.g. L4 console) */
81#define VBOXGUEST_MOUSE_HOST_CANNOT_HWPOINTER BIT(3)
82
83/** fictive start address of the hypervisor physical memory for MmMapIoSpace */
84#define HYPERVISOR_PHYSICAL_START 0xf8000000
85
86/*
87 * VMMDev Generic Request Interface
88 */
89
90/** port for generic request interface */
91#define PORT_VMMDEV_REQUEST_OFFSET 0
92
93/** Current version of the VMMDev interface.
94 *
95 * Additions are allowed to work only if
96 * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
97 * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
98 */
99#define VMMDEV_VERSION_MAJOR (0x1)
100#define VMMDEV_VERSION_MINOR (0x4)
101#define VMMDEV_VERSION ((VMMDEV_VERSION_MAJOR << 16) | VMMDEV_VERSION_MINOR)
102
103/**
104 * VMMDev request types.
105 * @note when updating this, adjust vmmdevGetRequestSize() as well
106 */
107typedef enum
108{
109 VMMDevReq_InvalidRequest = 0,
110 VMMDevReq_GetMouseStatus = 1,
111 VMMDevReq_SetMouseStatus = 2,
112 VMMDevReq_SetPointerShape = 3,
113 /** @todo implement on host side */
114 VMMDevReq_GetHostVersion = 4,
115 VMMDevReq_Idle = 5,
116 VMMDevReq_GetHostTime = 10,
117 VMMDevReq_GetHypervisorInfo = 20,
118 VMMDevReq_SetHypervisorInfo = 21,
119 VMMDevReq_SetPowerStatus = 30,
120 VMMDevReq_AcknowledgeEvents = 41,
121 VMMDevReq_CtlGuestFilterMask = 42,
122 VMMDevReq_ReportGuestInfo = 50,
123 VMMDevReq_GetDisplayChangeRequest = 51,
124 VMMDevReq_VideoModeSupported = 52,
125 VMMDevReq_GetHeightReduction = 53,
126 VMMDevReq_GetDisplayChangeRequest2 = 54,
127#ifdef VBOX_HGCM
128 VMMDevReq_HGCMConnect = 60,
129 VMMDevReq_HGCMDisconnect = 61,
130 VMMDevReq_HGCMCall = 62,
131#endif
132 VMMDevReq_VideoAccelEnable = 70,
133 VMMDevReq_VideoAccelFlush = 71,
134 VMMDevReq_QueryCredentials = 100,
135 VMMDevReq_ReportCredentialsJudgement = 101,
136 VMMDevReq_SizeHack = 0x7fffffff
137} VMMDevRequestType;
138
139/** Version of VMMDevRequestHeader structure. */
140#define VMMDEV_REQUEST_HEADER_VERSION (0x10001)
141
142#pragma pack(4)
143/** generic VMMDev request header */
144typedef struct
145{
146 /** size of the structure in bytes (including body). Filled by caller */
147 uint32_t size;
148 /** version of the structure. Filled by caller */
149 uint32_t version;
150 /** type of the request */
151 VMMDevRequestType requestType;
152 /** return code. Filled by VMMDev */
153 int32_t rc;
154 /** reserved fields */
155 uint32_t reserved1;
156 uint32_t reserved2;
157} VMMDevRequestHeader;
158
159/** mouse status request structure */
160typedef struct
161{
162 /** header */
163 VMMDevRequestHeader header;
164 /** mouse feature mask */
165 uint32_t mouseFeatures;
166 /** mouse x position */
167 uint32_t pointerXPos;
168 /** mouse y position */
169 uint32_t pointerYPos;
170} VMMDevReqMouseStatus;
171
172/** Note VBOX_MOUSE_POINTER_* flags are used in guest video driver,
173 * values must be <= 0x8000 and must not be changed.
174 */
175
176/** pointer is visible */
177#define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
178/** pointer has alpha channel */
179#define VBOX_MOUSE_POINTER_ALPHA (0x0002)
180/** pointerData contains new pointer shape */
181#define VBOX_MOUSE_POINTER_SHAPE (0x0004)
182
183/** mouse pointer shape/visibility change request */
184typedef struct
185{
186 /** header */
187 VMMDevRequestHeader header;
188 /** VBOX_MOUSE_POINTER_* bit flags */
189 uint32_t fFlags;
190 /** x coordinate of hot spot */
191 uint32_t xHot;
192 /** y coordinate of hot spot */
193 uint32_t yHot;
194 /** width of the pointer in pixels */
195 uint32_t width;
196 /** height of the pointer in scanlines */
197 uint32_t height;
198 /** Pointer data.
199 *
200 ****
201 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
202 *
203 * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
204 * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
205 *
206 * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
207 * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
208 * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
209 *
210 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
211 * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
212 * end of any scanline are undefined.
213 *
214 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
215 * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
216 * Bytes in the gap between the AND and the XOR mask are undefined.
217 * XOR mask scanlines have no gap between them and size of XOR mask is:
218 * cXor = width * 4 * height.
219 ****
220 *
221 * Preallocate 4 bytes for accessing actual data as p->pointerData
222 */
223 char pointerData[4];
224} VMMDevReqMousePointer;
225
226/** host version request structure */
227typedef struct
228{
229 /** header */
230 VMMDevRequestHeader header;
231 /** major version */
232 uint32_t major;
233 /** minor version */
234 uint32_t minor;
235 /** build number */
236 uint32_t build;
237} VMMDevReqHostVersion;
238
239/** idle request structure */
240typedef struct
241{
242 /** header */
243 VMMDevRequestHeader header;
244} VMMDevReqIdle;
245
246/** host time request structure */
247typedef struct
248{
249 /** header */
250 VMMDevRequestHeader header;
251 /** time in milliseconds since unix epoch. Filled by VMMDev. */
252 uint64_t time;
253} VMMDevReqHostTime;
254
255/** hypervisor info structure */
256typedef struct
257{
258 /** header */
259 VMMDevRequestHeader header;
260 /** guest virtual address of proposed hypervisor start */
261 vmmDevHypPtr hypervisorStart;
262 /** hypervisor size in bytes */
263 uint32_t hypervisorSize;
264} VMMDevReqHypervisorInfo;
265
266/** system power requests */
267typedef enum
268{
269 VMMDevPowerState_Invalid = 0,
270 VMMDevPowerState_Pause = 1,
271 VMMDevPowerState_PowerOff = 2,
272 VMMDevPowerState_SaveState = 3,
273 VMMDevPowerState_SizeHack = 0x7fffffff
274} VMMDevPowerState;
275
276/** system power status structure */
277typedef struct
278{
279 /** header */
280 VMMDevRequestHeader header;
281 /** power state request */
282 VMMDevPowerState powerState;
283} VMMDevPowerStateRequest;
284
285/** pending events structure */
286typedef struct
287{
288 /** header */
289 VMMDevRequestHeader header;
290 /** pending event bitmap */
291 uint32_t events;
292} VMMDevEvents;
293
294/** guest filter mask control */
295typedef struct
296{
297 /** header */
298 VMMDevRequestHeader header;
299 /** mask of events to be added to filter */
300 uint32_t u32OrMask;
301 /** mask of events to be removed from filter */
302 uint32_t u32NotMask;
303} VMMDevCtlGuestFilterMask;
304
305/** guest information structure */
306typedef struct VBoxGuestInfo
307{
308 /** The VMMDev interface version expected by additions. */
309 uint32_t additionsVersion;
310 /** guest OS type */
311 OSType osType;
312 /** @todo */
313} VBoxGuestInfo;
314
315/** guest information structure */
316typedef struct
317{
318 /** header */
319 VMMDevRequestHeader header;
320 /** Guest information. */
321 VBoxGuestInfo guestInfo;
322} VMMDevReportGuestInfo;
323
324/** display change request structure */
325typedef struct
326{
327 /** header */
328 VMMDevRequestHeader header;
329 /** horizontal pixel resolution (0 = do not change) */
330 uint32_t xres;
331 /** vertical pixel resolution (0 = do not change) */
332 uint32_t yres;
333 /** bits per pixel (0 = do not change) */
334 uint32_t bpp;
335 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
336 * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
337 */
338 uint32_t eventAck;
339} VMMDevDisplayChangeRequest;
340
341typedef struct
342{
343 /** header */
344 VMMDevRequestHeader header;
345 /** horizontal pixel resolution (0 = do not change) */
346 uint32_t xres;
347 /** vertical pixel resolution (0 = do not change) */
348 uint32_t yres;
349 /** bits per pixel (0 = do not change) */
350 uint32_t bpp;
351 /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
352 * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
353 */
354 uint32_t eventAck;
355 /** 0 for primary display, 1 for the first secondary, etc. */
356 uint32_t display;
357} VMMDevDisplayChangeRequest2;
358
359/** video mode supported request structure */
360typedef struct
361{
362 /** header */
363 VMMDevRequestHeader header;
364 /** horizontal pixel resolution (input) */
365 uint32_t width;
366 /** vertical pixel resolution (input) */
367 uint32_t height;
368 /** bits per pixel (input) */
369 uint32_t bpp;
370 /** supported flag (output) */
371 bool fSupported;
372} VMMDevVideoModeSupportedRequest;
373
374/** video modes height reduction request structure */
375typedef struct
376{
377 /** header */
378 VMMDevRequestHeader header;
379 /** height reduction in pixels (output) */
380 uint32_t heightReduction;
381} VMMDevGetHeightReductionRequest;
382
383#pragma pack()
384
385#ifdef VBOX_HGCM
386
387/** HGCM flags.
388 * @{
389 */
390#define VBOX_HGCM_REQ_DONE (0x1)
391#define VBOX_HGCM_REQ_CANCELLED (0x2)
392/** @} */
393
394#pragma pack(4)
395typedef struct _VMMDevHGCMRequestHeader
396{
397 /** Request header. */
398 VMMDevRequestHeader header;
399
400 /** HGCM flags. */
401 uint32_t fu32Flags;
402
403 /** Result code. */
404 int32_t result;
405} VMMDevHGCMRequestHeader;
406
407/** HGCM service location types. */
408typedef enum
409{
410 VMMDevHGCMLoc_Invalid = 0,
411 VMMDevHGCMLoc_LocalHost = 1,
412 VMMDevHGCMLoc_LocalHost_Existing = 2,
413 VMMDevHGCMLoc_SizeHack = 0x7fffffff
414} HGCMServiceLocationType;
415
416typedef struct
417{
418 char achName[128];
419} HGCMServiceLocationHost;
420
421typedef struct HGCMSERVICELOCATION
422{
423 /** Type of the location. */
424 HGCMServiceLocationType type;
425
426 union
427 {
428 HGCMServiceLocationHost host;
429 } u;
430} HGCMServiceLocation;
431
432typedef struct
433{
434 /* request header */
435 VMMDevHGCMRequestHeader header;
436
437 /** IN: Description of service to connect to. */
438 HGCMServiceLocation loc;
439
440 /** OUT: Client identifier assigned by local instance of HGCM. */
441 uint32_t u32ClientID;
442} VMMDevHGCMConnect;
443
444typedef struct
445{
446 /* request header */
447 VMMDevHGCMRequestHeader header;
448
449 /** IN: Client identifier. */
450 uint32_t u32ClientID;
451} VMMDevHGCMDisconnect;
452
453typedef enum
454{
455 VMMDevHGCMParmType_Invalid = 0,
456 VMMDevHGCMParmType_32bit = 1,
457 VMMDevHGCMParmType_64bit = 2,
458 VMMDevHGCMParmType_PhysAddr = 3,
459 VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
460 VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read) */
461 VMMDevHGCMParmType_LinAddr_Out= 6, /**< Out (write) */
462 VMMDevHGCMParmType_SizeHack = 0x7fffffff
463} HGCMFunctionParameterType;
464
465typedef struct _HGCMFUNCTIONPARAMETER
466{
467 HGCMFunctionParameterType type;
468 union
469 {
470 uint32_t value32;
471 uint64_t value64;
472 struct
473 {
474 uint32_t size;
475
476 union
477 {
478 vmmDevHypPhys physAddr;
479 vmmDevHypPtr linearAddr;
480 } u;
481 } Pointer;
482 } u;
483} HGCMFunctionParameter;
484
485typedef struct
486{
487 /* request header */
488 VMMDevHGCMRequestHeader header;
489
490 /** IN: Client identifier. */
491 uint32_t u32ClientID;
492 /** IN: Service function number. */
493 uint32_t u32Function;
494 /** IN: Number of parameters. */
495 uint32_t cParms;
496 /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
497} VMMDevHGCMCall;
498#pragma pack()
499
500#define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((char *)a + sizeof (VMMDevHGCMCall)))
501
502#define VBOX_HGCM_MAX_PARMS 256
503
504#endif /* VBOX_HGCM */
505
506
507#define VBVA_F_STATUS_ACCEPTED (0x01)
508#define VBVA_F_STATUS_ENABLED (0x02)
509
510#pragma pack(4)
511
512typedef struct _VMMDevVideoAccelEnable
513{
514 /* request header */
515 VMMDevRequestHeader header;
516
517 /** 0 - disable, !0 - enable. */
518 uint32_t u32Enable;
519
520 /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
521 * The host will refuse to enable VBVA if the size is not equal to
522 * VBVA_RING_BUFFER_SIZE.
523 */
524 uint32_t cbRingBuffer;
525
526 /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
527 uint32_t fu32Status;
528
529} VMMDevVideoAccelEnable;
530
531typedef struct _VMMDevVideoAccelFlush
532{
533 /* request header */
534 VMMDevRequestHeader header;
535
536} VMMDevVideoAccelFlush;
537
538#pragma pack()
539
540#pragma pack(1)
541
542/** VBVA command header. */
543typedef struct _VBVACMDHDR
544{
545 /** Coordinates of affected rectangle. */
546 int16_t x;
547 int16_t y;
548 uint16_t w;
549 uint16_t h;
550} VBVACMDHDR;
551
552/* VBVA order codes. Must be >= 0, because the VRDP server internally
553 * uses negative values to mark some operations.
554 * Values are important since they are used as an index in the
555 * "supported orders" bit mask.
556 */
557#define VBVA_VRDP_DIRTY_RECT (0)
558#define VBVA_VRDP_SOLIDRECT (1)
559#define VBVA_VRDP_SOLIDBLT (2)
560#define VBVA_VRDP_DSTBLT (3)
561#define VBVA_VRDP_SCREENBLT (4)
562#define VBVA_VRDP_PATBLTBRUSH (5)
563#define VBVA_VRDP_MEMBLT (6)
564#define VBVA_VRDP_CACHED_BITMAP (7)
565#define VBVA_VRDP_DELETED_BITMAP (8)
566#define VBVA_VRDP_LINE (9)
567#define VBVA_VRDP_BOUNDS (10)
568#define VBVA_VRDP_REPEAT (11)
569#define VBVA_VRDP_POLYLINE (12)
570#define VBVA_VRDP_ELLIPSE (13)
571#define VBVA_VRDP_SAVESCREEN (14)
572
573#define VBVA_VRDP_INDEX_TO_BIT(__index) (1 << (__index))
574
575/* 128 bit bitmap hash. */
576typedef uint8_t VRDPBITMAPHASH[16];
577
578typedef struct _VRDPORDERPOINT
579{
580 int16_t x;
581 int16_t y;
582} VRDPORDERPOINT;
583
584typedef struct _VRDPORDERPOLYPOINTS
585{
586 uint8_t c;
587 VRDPORDERPOINT a[16];
588} VRDPORDERPOLYPOINTS;
589
590typedef struct _VRDPORDERAREA
591{
592 int16_t x;
593 int16_t y;
594 uint16_t w;
595 uint16_t h;
596} VRDPORDERAREA;
597
598typedef struct _VRDPORDERBOUNDS
599{
600 VRDPORDERPOINT pt1;
601 VRDPORDERPOINT pt2;
602} VRDPORDERBOUNDS;
603
604typedef struct _VRDPORDERREPEAT
605{
606 VRDPORDERBOUNDS bounds;
607} VRDPORDERREPEAT;
608
609
610/* Header for bitmap bits in VBVA VRDP operations. */
611typedef struct _VRDPDATABITS
612{
613 /* Size of bitmap data without the header. */
614 uint32_t cb;
615 int16_t x;
616 int16_t y;
617 uint16_t cWidth;
618 uint16_t cHeight;
619 uint8_t cbPixel;
620} VRDPDATABITS;
621
622typedef struct _VRDPORDERSOLIDRECT
623{
624 int16_t x;
625 int16_t y;
626 uint16_t w;
627 uint16_t h;
628 uint32_t rgb;
629} VRDPORDERSOLIDRECT;
630
631typedef struct _VRDPORDERSOLIDBLT
632{
633 int16_t x;
634 int16_t y;
635 uint16_t w;
636 uint16_t h;
637 uint32_t rgb;
638 uint8_t rop;
639} VRDPORDERSOLIDBLT;
640
641typedef struct _VRDPORDERDSTBLT
642{
643 int16_t x;
644 int16_t y;
645 uint16_t w;
646 uint16_t h;
647 uint8_t rop;
648} VRDPORDERDSTBLT;
649
650typedef struct _VRDPORDERSCREENBLT
651{
652 int16_t x;
653 int16_t y;
654 uint16_t w;
655 uint16_t h;
656 int16_t xSrc;
657 int16_t ySrc;
658 uint8_t rop;
659} VRDPORDERSCREENBLT;
660
661typedef struct _VRDPORDERPATBLTBRUSH
662{
663 int16_t x;
664 int16_t y;
665 uint16_t w;
666 uint16_t h;
667 int8_t xSrc;
668 int8_t ySrc;
669 uint32_t rgbFG;
670 uint32_t rgbBG;
671 uint8_t rop;
672 uint8_t pattern[8];
673} VRDPORDERPATBLTBRUSH;
674
675typedef struct _VRDPORDERMEMBLT
676{
677 int16_t x;
678 int16_t y;
679 uint16_t w;
680 uint16_t h;
681 int16_t xSrc;
682 int16_t ySrc;
683 uint8_t rop;
684 VRDPBITMAPHASH hash;
685} VRDPORDERMEMBLT;
686
687typedef struct _VRDPORDERCACHEDBITMAP
688{
689 VRDPBITMAPHASH hash;
690 /* VRDPDATABITS and the bitmap data follows. */
691} VRDPORDERCACHEDBITMAP;
692
693typedef struct _VRDPORDERDELETEDBITMAP
694{
695 VRDPBITMAPHASH hash;
696} VRDPORDERDELETEDBITMAP;
697
698typedef struct _VRDPORDERLINE
699{
700 int16_t x1;
701 int16_t y1;
702 int16_t x2;
703 int16_t y2;
704 int16_t xBounds1;
705 int16_t yBounds1;
706 int16_t xBounds2;
707 int16_t yBounds2;
708 uint8_t mix;
709 uint32_t rgb;
710} VRDPORDERLINE;
711
712typedef struct _VRDPORDERPOLYLINE
713{
714 VRDPORDERPOINT ptStart;
715 uint8_t mix;
716 uint32_t rgb;
717 VRDPORDERPOLYPOINTS points;
718} VRDPORDERPOLYLINE;
719
720typedef struct _VRDPORDERELLIPSE
721{
722 VRDPORDERPOINT pt1;
723 VRDPORDERPOINT pt2;
724 uint8_t mix;
725 uint8_t fillMode;
726 uint32_t rgb;
727} VRDPORDERELLIPSE;
728
729typedef struct _VRDPORDERSAVESCREEN
730{
731 VRDPORDERPOINT pt1;
732 VRDPORDERPOINT pt2;
733 uint8_t ident;
734 uint8_t restore;
735} VRDPORDERSAVESCREEN;
736#pragma pack()
737
738/* The VBVA ring buffer is suitable for transferring large (< 2gb) amount of data.
739 * For example big bitmaps which do not fit to the buffer.
740 *
741 * Guest starts writing to the buffer by initializing a record entry in the
742 * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
743 * written. As data is written to the ring buffer, the guest increases off32End
744 * for the record.
745 *
746 * The host reads the aRecords on flushes and processes all completed records.
747 * When host encounters situation when only a partial record presents and
748 * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE - VBVA_RING_BUFFER_THRESHOLD,
749 * the host fetched all record data and updates off32Head. After that on each flush
750 * the host continues fetching the data until the record is completed.
751 *
752 */
753
754#define VBVA_RING_BUFFER_SIZE (_4M - _1K)
755#define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
756
757#define VBVA_MAX_RECORDS (64)
758
759#define VBVA_F_MODE_ENABLED (0x00000001)
760#define VBVA_F_MODE_VRDP (0x00000002)
761#define VBVA_F_MODE_VRDP_RESET (0x00000004)
762#define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
763
764#define VBVA_F_RECORD_PARTIAL (0x80000000)
765
766#pragma pack(1)
767typedef struct _VBVARECORD
768{
769 /** The length of the record. Changed by guest. */
770 uint32_t cbRecord;
771} VBVARECORD;
772
773typedef struct _VBVAMEMORY
774{
775 /** VBVA_F_MODE_* */
776 uint32_t fu32ModeFlags;
777
778 /** The offset where the data start in the buffer. */
779 uint32_t off32Data;
780 /** The offset where next data must be placed in the buffer. */
781 uint32_t off32Free;
782
783 /** The ring buffer for data. */
784 uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
785
786 /** The queue of record descriptions. */
787 VBVARECORD aRecords[VBVA_MAX_RECORDS];
788 uint32_t indexRecordFirst;
789 uint32_t indexRecordFree;
790
791 /* RDP orders supported by the client. The guest reports only them
792 * and falls back to DIRTY rects for not supported ones.
793 *
794 * (1 << VBVA_VRDP_*)
795 */
796 uint32_t fu32SupportedOrders;
797
798} VBVAMEMORY;
799#pragma pack()
800
801/** @} */
802
803
804/**
805 * VMMDev RAM
806 * @{
807 */
808
809#pragma pack(1)
810/** Layout of VMMDEV RAM region that contains information for guest */
811typedef struct
812{
813 /** size */
814 uint32_t u32Size;
815 /** version */
816 uint32_t u32Version;
817
818 union {
819 /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
820 struct {
821 bool fHaveEvents;
822 } V1_04;
823
824 struct {
825 /** Pending events flags, set by host. */
826 uint32_t u32HostEvents;
827 /** Mask of events the guest wants to see, set by guest. */
828 uint32_t u32GuestEventMask;
829 } V1_03;
830 } V;
831
832 VBVAMEMORY vbvaMemory;
833
834} VMMDevMemory;
835#pragma pack()
836
837/** Version of VMMDevMemory structure. */
838#define VMMDEV_MEMORY_VERSION (1)
839
840/** @} */
841
842
843/**
844 * VMMDev events.
845 * @{
846 */
847
848/** Host mouse capabilities has been changed. */
849#define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED BIT(0)
850/** HGCM event. */
851#define VMMDEV_EVENT_HGCM BIT(1)
852/** A display change request has been issued. */
853#define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST BIT(2)
854/** Credentials are available for judgement. */
855#define VMMDEV_EVENT_JUDGE_CREDENTIALS BIT(3)
856/** The guest has been restored. */
857#define VMMDEV_EVENT_RESTORED BIT(4)
858
859/** @} */
860
861
862/**
863 * VBoxGuest IOCTL codes and structures.
864 * @{
865 * IOCTL function numbers start from 2048, because MSDN says the
866 * second parameter of CTL_CODE macro (function) must be <= 2048 and <= 4095 for IHVs.
867 * The IOCTL number algorithm corresponds to CTL_CODE on Windows but for Linux IOCTLs,
868 * we also encode the data size, so we need an additional parameter.
869 */
870#if defined(__WIN__)
871#define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
872 ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
873#else /* unix: */
874#define IOCTL_CODE(DeviceType, Function, Method_ignored, Access_ignored, DataSize) \
875 ( (3 << 30) | ((DeviceType) << 8) | (Function) | ((DataSize) << 16) )
876#define METHOD_BUFFERED 0
877#define FILE_WRITE_ACCESS 0x0002
878#define FILE_DEVICE_UNKNOWN 0x00000022
879#endif
880
881/** IOCTL to VBoxGuest to query the VMMDev IO port region start. */
882#define IOCTL_VBOXGUEST_GETVMMDEVPORT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestPortInfo))
883
884#pragma pack(4)
885typedef struct _VBoxGuestPortInfo
886{
887 uint32_t portAddress;
888 VMMDevMemory *pVMMDevMemory;
889} VBoxGuestPortInfo;
890
891/** IOCTL to VBoxGuest to wait for a VMMDev host notification */
892#define IOCTL_VBOXGUEST_WAITEVENT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2049, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestWaitEventInfo))
893
894/**
895 * Result codes for VBoxGuestWaitEventInfo::u32Result
896 * @{
897 */
898/** Successful completion, an event occured. */
899#define VBOXGUEST_WAITEVENT_OK (0)
900/** Successful completion, timed out. */
901#define VBOXGUEST_WAITEVENT_TIMEOUT (1)
902/** Wait was interrupted. */
903#define VBOXGUEST_WAITEVENT_INTERRUPTED (2)
904/** An error occured while processing the request. */
905#define VBOXGUEST_WAITEVENT_ERROR (3)
906/** @} */
907
908/** Input and output buffers layout of the IOCTL_VBOXGUEST_WAITEVENT */
909typedef struct _VBoxGuestWaitEventInfo
910{
911 /** timeout in milliseconds */
912 uint32_t u32TimeoutIn;
913 /** events to wait for */
914 uint32_t u32EventMaskIn;
915 /** result code */
916 uint32_t u32Result;
917 /** events occured */
918 uint32_t u32EventFlagsOut;
919} VBoxGuestWaitEventInfo;
920
921/** IOCTL to VBoxGuest to perform a VMM request */
922#define IOCTL_VBOXGUEST_VMMREQUEST IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2050, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VMMDevRequestHeader))
923
924/** IOCTL to VBoxGuest to control event filter mask */
925
926typedef struct _VBoxGuestFilterMaskInfo
927{
928 uint32_t u32OrMask;
929 uint32_t u32NotMask;
930} VBoxGuestFilterMaskInfo;
931#pragma pack()
932
933#define IOCTL_VBOXGUEST_CTL_FILTER_MASK IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2051, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof (VBoxGuestFilterMaskInfo))
934
935#ifdef VBOX_HGCM
936/* These structures are shared between the driver and other binaries,
937 * therefore packing must be defined explicitely.
938 */
939#pragma pack(1)
940typedef struct _VBoxGuestHGCMConnectInfo
941{
942 uint32_t result; /**< OUT */
943 HGCMServiceLocation Loc; /**< IN */
944 uint32_t u32ClientID; /**< OUT */
945} VBoxGuestHGCMConnectInfo;
946
947typedef struct _VBoxGuestHGCMDisconnectInfo
948{
949 uint32_t result; /**< OUT */
950 uint32_t u32ClientID; /**< IN */
951} VBoxGuestHGCMDisconnectInfo;
952
953typedef struct _VBoxGuestHGCMCallInfo
954{
955 uint32_t result; /**< OUT Host HGCM return code.*/
956 uint32_t u32ClientID; /**< IN The id of the caller. */
957 uint32_t u32Function; /**< IN Function number. */
958 uint32_t cParms; /**< IN How many parms. */
959 /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
960} VBoxGuestHGCMCallInfo;
961#pragma pack()
962
963#define IOCTL_VBOXGUEST_HGCM_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3072, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMConnectInfo))
964#define IOCTL_VBOXGUEST_HGCM_DISCONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3073, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMDisconnectInfo))
965#define IOCTL_VBOXGUEST_HGCM_CALL IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3074, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMCallInfo))
966#define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3075, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(uint32_t))
967
968#define VBOXGUEST_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
969
970#endif /* VBOX_HGCM */
971
972/*
973 * Credentials request flags and structure
974 */
975
976#define VMMDEV_CREDENTIALS_STRLEN 128
977
978/** query from host whether credentials are present */
979#define VMMDEV_CREDENTIALS_QUERYPRESENCE BIT(1)
980/** read credentials from host (can be combined with clear) */
981#define VMMDEV_CREDENTIALS_READ BIT(2)
982/** clear credentials on host (can be combined with read) */
983#define VMMDEV_CREDENTIALS_CLEAR BIT(3)
984/** read credentials for judgement in the guest */
985#define VMMDEV_CREDENTIALS_READJUDGE BIT(8)
986/** clear credentials for judegement on the host */
987#define VMMDEV_CREDENTIALS_CLEARJUDGE BIT(9)
988/** report credentials acceptance by guest */
989#define VMMDEV_CREDENTIALS_JUDGE_OK BIT(10)
990/** report credentials denial by guest */
991#define VMMDEV_CREDENTIALS_JUDGE_DENY BIT(11)
992/** report that no judgement could be made by guest */
993#define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT BIT(12)
994
995/** flag telling the guest that credentials are present */
996#define VMMDEV_CREDENTIALS_PRESENT BIT(16)
997/** flag telling guest that local logons should be prohibited */
998#define VMMDEV_CREDENTIALS_NOLOCALLOGON BIT(17)
999
1000/** credentials request structure */
1001#pragma pack(4)
1002typedef struct _VMMDevCredentials
1003{
1004 /* request header */
1005 VMMDevRequestHeader header;
1006 /* request flags (in/out) */
1007 uint32_t u32Flags;
1008 /* user name (UTF-8) (out) */
1009 char szUserName[VMMDEV_CREDENTIALS_STRLEN];
1010 /* password (UTF-8) (out) */
1011 char szPassword[VMMDEV_CREDENTIALS_STRLEN];
1012 /* domain name (UTF-8) (out) */
1013 char szDomain[VMMDEV_CREDENTIALS_STRLEN];
1014} VMMDevCredentials;
1015#pragma pack()
1016
1017/** inline helper to determine the request size for the given operation */
1018DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
1019{
1020 switch (requestType)
1021 {
1022 case VMMDevReq_GetMouseStatus:
1023 case VMMDevReq_SetMouseStatus:
1024 return sizeof(VMMDevReqMouseStatus);
1025 case VMMDevReq_SetPointerShape:
1026 return sizeof(VMMDevReqMousePointer);
1027 case VMMDevReq_GetHostVersion:
1028 return sizeof(VMMDevReqHostVersion);
1029 case VMMDevReq_Idle:
1030 return sizeof(VMMDevReqIdle);
1031 case VMMDevReq_GetHostTime:
1032 return sizeof(VMMDevReqHostTime);
1033 case VMMDevReq_GetHypervisorInfo:
1034 case VMMDevReq_SetHypervisorInfo:
1035 return sizeof(VMMDevReqHypervisorInfo);
1036 case VMMDevReq_SetPowerStatus:
1037 return sizeof(VMMDevPowerStateRequest);
1038 case VMMDevReq_AcknowledgeEvents:
1039 return sizeof(VMMDevEvents);
1040 case VMMDevReq_ReportGuestInfo:
1041 return sizeof(VMMDevReportGuestInfo);
1042 case VMMDevReq_GetDisplayChangeRequest:
1043 return sizeof(VMMDevDisplayChangeRequest);
1044 case VMMDevReq_GetDisplayChangeRequest2:
1045 return sizeof(VMMDevDisplayChangeRequest2);
1046 case VMMDevReq_VideoModeSupported:
1047 return sizeof(VMMDevVideoModeSupportedRequest);
1048 case VMMDevReq_GetHeightReduction:
1049 return sizeof(VMMDevGetHeightReductionRequest);
1050#ifdef VBOX_HGCM
1051 case VMMDevReq_HGCMConnect:
1052 return sizeof(VMMDevHGCMConnect);
1053 case VMMDevReq_HGCMDisconnect:
1054 return sizeof(VMMDevHGCMDisconnect);
1055 case VMMDevReq_HGCMCall:
1056 return sizeof(VMMDevHGCMCall);
1057#endif
1058 case VMMDevReq_VideoAccelEnable:
1059 return sizeof(VMMDevVideoAccelEnable);
1060 case VMMDevReq_VideoAccelFlush:
1061 return sizeof(VMMDevVideoAccelFlush);
1062 case VMMDevReq_QueryCredentials:
1063 return sizeof(VMMDevCredentials);
1064 default:
1065 return 0;
1066 }
1067}
1068
1069/**
1070 * Initializes a request structure.
1071 *
1072 */
1073DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
1074{
1075 uint32_t requestSize;
1076 if (!req)
1077 return VERR_INVALID_PARAMETER;
1078 requestSize = (uint32_t)vmmdevGetRequestSize(type);
1079 if (!requestSize)
1080 return VERR_INVALID_PARAMETER;
1081 req->size = requestSize;
1082 req->version = VMMDEV_REQUEST_HEADER_VERSION;
1083 req->requestType = type;
1084 req->rc = VERR_GENERAL_FAILURE;
1085 req->reserved1 = 0;
1086 req->reserved2 = 0;
1087 return VINF_SUCCESS;
1088}
1089
1090/** @} */
1091
1092#endif /* __VBox_VBoxGuest_h__ */
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