VirtualBox

source: vbox/trunk/include/VBox/VBoxVideoGuest.h@ 64387

Last change on this file since 64387 was 64185, checked in by vboxsync, 8 years ago

bugref:8614: Additions/common/VBoxVideo: make the code more self-contained: break the VBoxVideo.h dependency on VMMDev.h by moving VBVA and mouse cursor flags to VBoxVideo.h. Now there is a dependency the other way, but I do not think that is such a problem.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.4 KB
Line 
1/** @file
2 * VBox Host Guest Shared Memory Interface (HGSMI).
3 * OS-independent guest structures.
4 */
5
6/*
7 * Copyright (C) 2006-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28#ifndef ___VBox_VBoxVideoGuest_h___
29#define ___VBox_VBoxVideoGuest_h___
30
31#include <VBox/HGSMI/HGSMI.h>
32#include <VBox/HGSMI/HGSMIChSetup.h>
33#include <VBox/VBoxVideo.h>
34
35#include <iprt/err.h> /* The functions in here return IPRT errors. */
36
37#ifdef VBOX_XPDM_MINIPORT
38# include <iprt/nt/miniport.h>
39# include <ntddvdeo.h> /* sdk, clean */
40# include <iprt/nt/Video.h>
41#elif defined VBOX_GUESTR3XORGMOD
42# include <compiler.h>
43#else
44# include <iprt/asm-amd64-x86.h>
45#endif
46
47#ifdef VBOX_WDDM_MINIPORT
48# include "wddm/VBoxMPShgsmi.h"
49 typedef VBOXSHGSMI HGSMIGUESTCMDHEAP;
50# define HGSMIGUESTCMDHEAP_GET(_p) (&(_p)->Heap)
51#else
52 typedef HGSMIHEAP HGSMIGUESTCMDHEAP;
53# define HGSMIGUESTCMDHEAP_GET(_p) (_p)
54#endif
55
56RT_C_DECLS_BEGIN
57
58/**
59 * Structure grouping the context needed for submitting commands to the host
60 * via HGSMI
61 */
62typedef struct HGSMIGUESTCOMMANDCONTEXT
63{
64 /** Information about the memory heap located in VRAM from which data
65 * structures to be sent to the host are allocated. */
66 HGSMIGUESTCMDHEAP heapCtx;
67 /** The I/O port used for submitting commands to the host by writing their
68 * offsets into the heap. */
69 RTIOPORT port;
70} HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
71
72
73/**
74 * Structure grouping the context needed for receiving commands from the host
75 * via HGSMI
76 */
77typedef struct HGSMIHOSTCOMMANDCONTEXT
78{
79 /** Information about the memory area located in VRAM in which the host
80 * places data structures to be read by the guest. */
81 HGSMIAREA areaCtx;
82 /** Convenience structure used for matching host commands to handlers. */
83 /** @todo handlers are registered individually in code rather than just
84 * passing a static structure in order to gain extra flexibility. There is
85 * currently no expected usage case for this though. Is the additional
86 * complexity really justified? */
87 HGSMICHANNELINFO channels;
88 /** Flag to indicate that one thread is currently processing the command
89 * queue. */
90 volatile bool fHostCmdProcessing;
91 /* Pointer to the VRAM location where the HGSMI host flags are kept. */
92 volatile HGSMIHOSTFLAGS *pfHostFlags;
93 /** The I/O port used for receiving commands from the host as offsets into
94 * the memory area and sending back confirmations (command completion,
95 * IRQ acknowlegement). */
96 RTIOPORT port;
97} HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT;
98
99
100/**
101 * Structure grouping the context needed for sending graphics acceleration
102 * information to the host via VBVA. Each screen has its own VBVA buffer.
103 */
104typedef struct VBVABUFFERCONTEXT
105{
106 /** Offset of the buffer in the VRAM section for the screen */
107 uint32_t offVRAMBuffer;
108 /** Length of the buffer in bytes */
109 uint32_t cbBuffer;
110 /** This flag is set if we wrote to the buffer faster than the host could
111 * read it. */
112 bool fHwBufferOverflow;
113 /** The VBVA record that we are currently preparing for the host, NULL if
114 * none. */
115 struct VBVARECORD *pRecord;
116 /** Pointer to the VBVA buffer mapped into the current address space. Will
117 * be NULL if VBVA is not enabled. */
118 struct VBVABUFFER *pVBVA;
119} VBVABUFFERCONTEXT, *PVBVABUFFERCONTEXT;
120
121/** @name Helper functions
122 * @{ */
123/** Write an 8-bit value to an I/O port. */
124DECLINLINE(void) VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value)
125{
126#ifdef VBOX_XPDM_MINIPORT
127 VideoPortWritePortUchar((PUCHAR)Port, Value);
128#elif defined VBOX_GUESTR3XORGMOD
129 outb(Port, Value);
130#else /** @todo make these explicit */
131 ASMOutU8(Port, Value);
132#endif
133}
134
135/** Write a 16-bit value to an I/O port. */
136DECLINLINE(void) VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value)
137{
138#ifdef VBOX_XPDM_MINIPORT
139 VideoPortWritePortUshort((PUSHORT)Port,Value);
140#elif defined VBOX_GUESTR3XORGMOD
141 outw(Port, Value);
142#else
143 ASMOutU16(Port, Value);
144#endif
145}
146
147/** Write a 32-bit value to an I/O port. */
148DECLINLINE(void) VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value)
149{
150#ifdef VBOX_XPDM_MINIPORT
151 VideoPortWritePortUlong((PULONG)Port,Value);
152#elif defined VBOX_GUESTR3XORGMOD
153 outl(Port, Value);
154#else
155 ASMOutU32(Port, Value);
156#endif
157}
158
159/** Read an 8-bit value from an I/O port. */
160DECLINLINE(uint8_t) VBoxVideoCmnPortReadUchar(RTIOPORT Port)
161{
162#ifdef VBOX_XPDM_MINIPORT
163 return VideoPortReadPortUchar((PUCHAR)Port);
164#elif defined VBOX_GUESTR3XORGMOD
165 return inb(Port);
166#else
167 return ASMInU8(Port);
168#endif
169}
170
171/** Read a 16-bit value from an I/O port. */
172DECLINLINE(uint16_t) VBoxVideoCmnPortReadUshort(RTIOPORT Port)
173{
174#ifdef VBOX_XPDM_MINIPORT
175 return VideoPortReadPortUshort((PUSHORT)Port);
176#elif defined VBOX_GUESTR3XORGMOD
177 return inw(Port);
178#else
179 return ASMInU16(Port);
180#endif
181}
182
183/** Read a 32-bit value from an I/O port. */
184DECLINLINE(uint32_t) VBoxVideoCmnPortReadUlong(RTIOPORT Port)
185{
186#ifdef VBOX_XPDM_MINIPORT
187 return VideoPortReadPortUlong((PULONG)Port);
188#elif defined VBOX_GUESTR3XORGMOD
189 return inl(Port);
190#else
191 return ASMInU32(Port);
192#endif
193}
194
195/** @} */
196
197/** @name Base HGSMI APIs
198 * @{ */
199
200/** Acknowlege an IRQ. */
201DECLINLINE(void) VBoxHGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx)
202{
203 VBoxVideoCmnPortWriteUlong(pCtx->port, HGSMIOFFSET_VOID);
204}
205
206DECLHIDDEN(void) VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx,
207 void *pvMem);
208DECLHIDDEN(void) VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx);
209DECLHIDDEN(bool) VBoxHGSMIIsSupported(void);
210DECLHIDDEN(void *) VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,
211 HGSMISIZE cbData,
212 uint8_t u8Ch,
213 uint16_t u16Op);
214DECLHIDDEN(void) VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx,
215 void *pvBuffer);
216DECLHIDDEN(int) VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx,
217 void *pvBuffer);
218DECLHIDDEN(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,
219 uint32_t *poffVRAMBaseMapping,
220 uint32_t *pcbMapping,
221 uint32_t *poffGuestHeapMemory,
222 uint32_t *pcbGuestHeapMemory,
223 uint32_t *poffHostFlags);
224DECLHIDDEN(int) VBoxHGSMIReportFlagsLocation(PHGSMIGUESTCOMMANDCONTEXT pCtx,
225 HGSMIOFFSET offLocation);
226DECLHIDDEN(int) VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
227 uint32_t fCaps);
228/** @todo we should provide a cleanup function too as part of the API */
229DECLHIDDEN(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
230 void *pvGuestHeapMemory,
231 uint32_t cbGuestHeapMemory,
232 uint32_t offVRAMGuestHeapMemory,
233 const HGSMIENV *pEnv);
234DECLHIDDEN(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
235 uint32_t cbVRAM,
236 uint32_t offVRAMBaseMapping,
237 uint32_t *poffVRAMHostArea,
238 uint32_t *pcbHostArea);
239DECLHIDDEN(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
240 void *pvBaseMapping,
241 uint32_t offHostFlags,
242 void *pvHostAreaMapping,
243 uint32_t offVRAMHostArea,
244 uint32_t cbHostArea);
245DECLHIDDEN(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
246 HGSMIOFFSET offVRAMFlagsLocation,
247 uint32_t fCaps,
248 uint32_t offVRAMHostArea,
249 uint32_t cbHostArea);
250DECLHIDDEN(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx,
251 uint32_t u32Index, uint32_t *pulValue);
252DECLHIDDEN(int) VBoxQueryConfHGSMIDef(PHGSMIGUESTCOMMANDCONTEXT pCtx,
253 uint32_t u32Index, uint32_t u32DefValue, uint32_t *pulValue);
254DECLHIDDEN(int) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
255 uint32_t fFlags,
256 uint32_t cHotX,
257 uint32_t cHotY,
258 uint32_t cWidth,
259 uint32_t cHeight,
260 uint8_t *pPixels,
261 uint32_t cbLength);
262DECLHIDDEN(int) VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pCtx, bool fReportPosition, uint32_t x, uint32_t y,
263 uint32_t *pxHost, uint32_t *pyHost);
264
265/** @} */
266
267/** @name VBVA APIs
268 * @{ */
269DECLHIDDEN(bool) VBoxVBVAEnable(PVBVABUFFERCONTEXT pCtx,
270 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
271 struct VBVABUFFER *pVBVA, int32_t cScreen);
272DECLHIDDEN(void) VBoxVBVADisable(PVBVABUFFERCONTEXT pCtx,
273 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
274 int32_t cScreen);
275DECLHIDDEN(bool) VBoxVBVABufferBeginUpdate(PVBVABUFFERCONTEXT pCtx,
276 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
277DECLHIDDEN(void) VBoxVBVABufferEndUpdate(PVBVABUFFERCONTEXT pCtx);
278DECLHIDDEN(bool) VBoxVBVAWrite(PVBVABUFFERCONTEXT pCtx,
279 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
280 const void *pv, uint32_t cb);
281DECLHIDDEN(bool) VBoxVBVAOrderSupported(PVBVABUFFERCONTEXT pCtx, unsigned code);
282DECLHIDDEN(void) VBoxVBVASetupBufferContext(PVBVABUFFERCONTEXT pCtx,
283 uint32_t offVRAMBuffer,
284 uint32_t cbBuffer);
285
286/** @} */
287
288/** @name Modesetting APIs
289 * @{ */
290
291DECLHIDDEN(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx);
292DECLHIDDEN(uint32_t) VBoxVideoGetVRAMSize(void);
293DECLHIDDEN(bool) VBoxVideoAnyWidthAllowed(void);
294DECLHIDDEN(uint16_t) VBoxHGSMIGetScreenFlags(PHGSMIGUESTCOMMANDCONTEXT pCtx);
295
296struct VBVAINFOVIEW;
297/**
298 * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise
299 * the @a VBVAINFOVIEW structure for each screen.
300 *
301 * @returns iprt status code
302 * @param pvData context data for the callback, passed to @a
303 * VBoxHGSMISendViewInfo along with the callback
304 * @param pInfo array of @a VBVAINFOVIEW structures to be filled in
305 * @todo explicitly pass the array size
306 */
307typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO(void *pvData,
308 struct VBVAINFOVIEW *pInfo,
309 uint32_t cViews);
310/** Pointer to a FNHGSMIFILLVIEWINFO callback */
311typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
312
313DECLHIDDEN(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
314 uint32_t u32Count,
315 PFNHGSMIFILLVIEWINFO pfnFill,
316 void *pvData);
317DECLHIDDEN(void) VBoxVideoSetModeRegisters(uint16_t cWidth, uint16_t cHeight,
318 uint16_t cVirtWidth, uint16_t cBPP,
319 uint16_t fFlags,
320 uint16_t cx, uint16_t cy);
321DECLHIDDEN(bool) VBoxVideoGetModeRegisters(uint16_t *pcWidth,
322 uint16_t *pcHeight,
323 uint16_t *pcVirtWidth,
324 uint16_t *pcBPP,
325 uint16_t *pfFlags);
326DECLHIDDEN(void) VBoxVideoDisableVBE(void);
327DECLHIDDEN(void) VBoxHGSMIProcessDisplayInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
328 uint32_t cDisplay,
329 int32_t cOriginX,
330 int32_t cOriginY,
331 uint32_t offStart,
332 uint32_t cbPitch,
333 uint32_t cWidth,
334 uint32_t cHeight,
335 uint16_t cBPP,
336 uint16_t fFlags);
337DECLHIDDEN(int) VBoxHGSMIUpdateInputMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx, int32_t cOriginX, int32_t cOriginY,
338 uint32_t cWidth, uint32_t cHeight);
339DECLHIDDEN(int) VBoxHGSMIGetModeHints(PHGSMIGUESTCOMMANDCONTEXT pCtx,
340 unsigned cScreens, VBVAMODEHINT *paHints);
341
342/** @} */
343
344RT_C_DECLS_END
345
346#endif
347
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