VirtualBox

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

Last change on this file since 905 was 669, checked in by vboxsync, 18 years ago

WIN32 -> WIN

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