VirtualBox

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

Last change on this file since 34542 was 34490, checked in by vboxsync, 14 years ago

VBoxVideo: remove leading underscore from structure names and make VBoxVideoGuest.h C-friendly

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.9 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-2008 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
35#ifdef VBOX_XPDM_MINIPORT
36RT_C_DECLS_BEGIN
37# include "miniport.h"
38# include "ntddvdeo.h"
39# include <Video.h>
40RT_C_DECLS_END
41#else
42# include <iprt/asm-amd64-x86.h>
43#endif
44
45RT_C_DECLS_BEGIN
46
47/**
48 * Structure grouping the context needed for submitting commands to the host
49 * via HGSMI
50 */
51typedef struct HGSMIGUESTCOMMANDCONTEXT
52{
53 /** Information about the memory heap located in VRAM from which data
54 * structures to be sent to the host are allocated. */
55 HGSMIHEAP heapCtx;
56 /** The I/O port used for submitting commands to the host by writing their
57 * offsets into the heap. */
58 RTIOPORT port;
59} HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
60
61
62/**
63 * Structure grouping the context needed for receiving commands from the host
64 * via HGSMI
65 */
66typedef struct HGSMIHOSTCOMMANDCONTEXT
67{
68 /** Information about the memory area located in VRAM in which the host
69 * places data structures to be read by the guest. */
70 HGSMIAREA areaCtx;
71 /** Convenience structure used for matching host commands to handlers. */
72 /** @todo handlers are registered individually in code rather than just
73 * passing a static structure in order to gain extra flexibility. There is
74 * currently no expected usage case for this though. Is the additional
75 * complexity really justified? */
76 HGSMICHANNELINFO channels;
77 /** Flag to indicate that one thread is currently processing the command
78 * queue. */
79 volatile bool fHostCmdProcessing;
80 /* Pointer to the VRAM location where the HGSMI host flags are kept. */
81 volatile HGSMIHOSTFLAGS *pfHostFlags;
82 /** The I/O port used for receiving commands from the host as offsets into
83 * the memory area and sending back confirmations (command completion,
84 * IRQ acknowlegement). */
85 RTIOPORT port;
86} HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT;
87
88
89/**
90 * Structure grouping the context needed for sending graphics acceleration
91 * information to the host via VBVA. Each screen has its own VBVA buffer.
92 */
93typedef struct VBVABUFFERCONTEXT
94{
95 /** Offset of the buffer in the VRAM section for the screen */
96 uint32_t offVRAMBuffer;
97 /** Length of the buffer in bytes */
98 uint32_t cbBuffer;
99 /** This flag is set if we wrote to the buffer faster than the host could
100 * read it. */
101 bool fHwBufferOverflow;
102 /** The VBVA record that we are currently preparing for the host, NULL if
103 * none. */
104 struct VBVARECORD *pRecord;
105 /** Pointer to the VBVA buffer mapped into the current address space. Will
106 * be NULL if VBVA is not enabled. */
107 struct VBVABUFFER *pVBVA;
108} VBVABUFFERCONTEXT, *PVBVABUFFERCONTEXT;
109
110/** @name Helper functions
111 * @{ */
112/** Write an 8-bit value to an I/O port. */
113DECLINLINE(void) VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value)
114{
115#ifdef VBOX_XPDM_MINIPORT
116 VideoPortWritePortUchar((PUCHAR)Port, Value);
117#else /** @todo make these explicit */
118 ASMOutU8(Port, Value);
119#endif
120}
121
122/** Write a 16-bit value to an I/O port. */
123DECLINLINE(void) VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value)
124{
125#ifdef VBOX_XPDM_MINIPORT
126 VideoPortWritePortUshort((PUSHORT)Port,Value);
127#else
128 ASMOutU16(Port, Value);
129#endif
130}
131
132/** Write a 32-bit value to an I/O port. */
133DECLINLINE(void) VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value)
134{
135#ifdef VBOX_XPDM_MINIPORT
136 VideoPortWritePortUlong((PULONG)Port,Value);
137#else
138 ASMOutU32(Port, Value);
139#endif
140}
141
142/** Read an 8-bit value from an I/O port. */
143DECLINLINE(uint8_t) VBoxVideoCmnPortReadUchar(RTIOPORT Port)
144{
145#ifdef VBOX_XPDM_MINIPORT
146 return VideoPortReadPortUchar((PUCHAR)Port);
147#else
148 return ASMInU8(Port);
149#endif
150}
151
152/** Read a 16-bit value from an I/O port. */
153DECLINLINE(uint16_t) VBoxVideoCmnPortReadUshort(RTIOPORT Port)
154{
155#ifdef VBOX_XPDM_MINIPORT
156 return VideoPortReadPortUshort((PUSHORT)Port);
157#else
158 return ASMInU16(Port);
159#endif
160}
161
162/** Read a 32-bit value from an I/O port. */
163DECLINLINE(uint32_t) VBoxVideoCmnPortReadUlong(RTIOPORT Port)
164{
165#ifdef VBOX_XPDM_MINIPORT
166 return VideoPortReadPortUlong((PULONG)Port);
167#else
168 return ASMInU32(Port);
169#endif
170}
171
172/** @} */
173
174/** @name Base HGSMI APIs
175 * @{ */
176
177/** Acknowlege an IRQ. */
178DECLINLINE(void) VBoxHGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx)
179{
180 VBoxVideoCmnPortWriteUlong(pCtx->port, HGSMIOFFSET_VOID);
181}
182
183RTDECL(void) VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx,
184 void *pvMem);
185RTDECL(void) VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx);
186RTDECL(bool) VBoxHGSMIIsSupported(void);
187RTDECL(void *) VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,
188 HGSMISIZE cbData,
189 uint8_t u8Ch,
190 uint16_t u16Op);
191RTDECL(void) VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx,
192 void *pvBuffer);
193RTDECL(int) VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx,
194 void *pvBuffer);
195
196typedef struct VBVAINFOVIEW *PVBVAINFOVIEW;
197/**
198 * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise
199 * the @a VBVAINFOVIEW structure for each screen.
200 *
201 * @returns iprt status code
202 * @param pvData context data for the callback, passed to @a
203 * VBoxHGSMISendViewInfo along with the callback
204 * @param pInfo array of @a VBVAINFOVIEW structures to be filled in
205 * @todo explicitly pass the array size
206 */
207typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO (void *pvData,
208 PVBVAINFOVIEW pInfo);
209/** Pointer to a FNHGSMIFILLVIEWINFO callback */
210typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
211
212RTDECL(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
213 uint32_t u32Count,
214 PFNHGSMIFILLVIEWINFO pfnFill,
215 void *pvData);
216RTDECL(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,
217 uint32_t *poffVRAMBaseMapping,
218 uint32_t *pcbMapping,
219 uint32_t *poffGuestHeapMemory,
220 uint32_t *pcbGuestHeapMemory,
221 uint32_t *poffHostFlags);
222/** @todo we should provide a cleanup function too as part of the API */
223RTDECL(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
224 void *pvGuestHeapMemory,
225 uint32_t cbGuestHeapMemory,
226 uint32_t offVRAMGuestHeapMemory);
227RTDECL(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
228 uint32_t cbVRAM,
229 uint32_t offVRAMBaseMapping,
230 uint32_t *poffVRAMHostArea,
231 uint32_t *pcbHostArea);
232RTDECL(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
233 void *pvBaseMapping,
234 uint32_t offHostFlags,
235 void *pvHostAreaMapping,
236 uint32_t offVRAMHostArea,
237 uint32_t cbHostArea);
238RTDECL(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
239 HGSMIOFFSET offVRAMFlagsLocation,
240 uint32_t fCaps,
241 uint32_t offVRAMHostArea,
242 uint32_t cbHostArea);
243RTDECL(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx);
244RTDECL(bool) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
245 uint32_t fFlags,
246 uint32_t cHotX,
247 uint32_t cHotY,
248 uint32_t cWidth,
249 uint32_t cHeight,
250 uint8_t *pPixels,
251 uint32_t cbLength);
252
253/** @} */
254
255/** @name VBVA APIs
256 * @{ */
257RTDECL(bool) VBoxVBVAEnable(PVBVABUFFERCONTEXT pCtx,
258 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
259 struct VBVABUFFER *pVBVA);
260RTDECL(void) VBoxVBVADisable(PVBVABUFFERCONTEXT pCtx,
261 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
262RTDECL(bool) VBoxVBVABufferBeginUpdate(PVBVABUFFERCONTEXT pCtx,
263 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
264RTDECL(void) VBoxVBVABufferEndUpdate(PVBVABUFFERCONTEXT pCtx);
265RTDECL(bool) VBoxVBVAWrite(PVBVABUFFERCONTEXT pCtx,
266 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
267 const void *pv, uint32_t cb);
268RTDECL(bool) VBoxVBVAOrderSupported(PVBVABUFFERCONTEXT pCtx, unsigned code);
269RTDECL(void) VBoxHGSMIProcessDisplayInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
270 uint32_t cDisplay,
271 int32_t cOriginX,
272 int32_t cOriginY,
273 uint32_t offStart,
274 uint32_t cbPitch,
275 uint32_t cWidth,
276 uint32_t cHeight,
277 uint16_t cBPP);
278
279/** @} */
280
281RT_C_DECLS_END
282
283#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