VirtualBox

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

Last change on this file since 53530 was 53530, checked in by vboxsync, 10 years ago

Additions/common and Additions/x11: add support for getting video mode hints through the VGA device.

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