VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCr.h@ 68550

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

merging vbglioc r117689: Initial VBoxGuest I/O control changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.3 KB
Line 
1/* $Id: VBoxMPCr.h 68550 2017-08-31 12:09:41Z vboxsync $ */
2/** @file
3 * VBox WDDM Miniport driver
4 */
5
6/*
7 * Copyright (C) 2012-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
18#ifndef ___VBoxMPCr_h__
19#define ___VBoxMPCr_h__
20
21#ifdef VBOX_WITH_CROGL
22
23# include <VBox/VBoxGuestLib.h>
24
25typedef struct VBOXMP_CRCTLCON
26{
27 VBGLCRCTLHANDLE hCrCtl;
28 uint32_t cCrCtlRefs;
29} VBOXMP_CRCTLCON, *PVBOXMP_CRCTLCON;
30
31void VBoxMpCrCtlConInit(void);
32
33bool VBoxMpCrCtlConIs3DSupported(void);
34
35int VBoxMpCrCtlConConnect(PVBOXMP_DEVEXT pDevExt, PVBOXMP_CRCTLCON pCrCtlCon,
36 uint32_t crVersionMajor, uint32_t crVersionMinor,
37 uint32_t *pu32ClientID);
38int VBoxMpCrCtlConDisconnect(PVBOXMP_DEVEXT pDevExt, PVBOXMP_CRCTLCON pCrCtlCon, uint32_t u32ClientID);
39int VBoxMpCrCtlConCall(PVBOXMP_CRCTLCON pCrCtlCon, struct VBGLIOCHGCMCALL *pData, uint32_t cbData);
40int VBoxMpCrCtlConCallUserData(PVBOXMP_CRCTLCON pCrCtlCon, struct VBGLIOCHGCMCALL *pData, uint32_t cbData);
41
42# include <cr_pack.h>
43
44typedef struct VBOXMP_CRSHGSMICON_BUFDR
45{
46 uint32_t cbBuf;
47 void *pvBuf;
48} VBOXMP_CRSHGSMICON_BUFDR, *PVBOXMP_CRSHGSMICON_BUFDR;
49
50typedef struct VBOXMP_CRSHGSMICON_BUFDR_CACHE
51{
52 volatile PVBOXMP_CRSHGSMICON_BUFDR pBufDr;
53} VBOXMP_CRSHGSMICON_BUFDR_CACHE, *PVBOXMP_CRSHGSMICON_BUFDR_CACHE;
54
55typedef struct VBOXMP_CRSHGSMITRANSPORT
56{
57 PVBOXMP_DEVEXT pDevExt;
58 VBOXMP_CRSHGSMICON_BUFDR_CACHE WbDrCache;
59} VBOXMP_CRSHGSMITRANSPORT, *PVBOXMP_CRSHGSMITRANSPORT;
60
61/** the rx buffer passed here is only valid in the context of the callback.
62 * the callee must NOT free it or use outside of the callback context.
63 * */
64typedef DECLCALLBACK(void) FNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEREADASYNC_COMPLETION(PVBOXMP_CRSHGSMITRANSPORT pCon, int rc, void *pvRx, uint32_t cbRx, void *pvCtx);
65typedef FNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEREADASYNC_COMPLETION *PFNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEREADASYNC_COMPLETION;
66
67typedef DECLCALLBACK(void) FNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEASYNC_COMPLETION(PVBOXMP_CRSHGSMITRANSPORT pCon, int rc, void *pvCtx);
68typedef FNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEASYNC_COMPLETION *PFNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEASYNC_COMPLETION;
69
70int VBoxMpCrShgsmiTransportCreate(PVBOXMP_CRSHGSMITRANSPORT pCon, PVBOXMP_DEVEXT pDevExt);
71void VBoxMpCrShgsmiTransportTerm(PVBOXMP_CRSHGSMITRANSPORT pCon);
72void* VBoxMpCrShgsmiTransportCmdCreateWriteReadAsync(PVBOXMP_CRSHGSMITRANSPORT pCon, uint32_t u32ClientID, void *pvBuffer, uint32_t cbBuffer,
73 PFNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEREADASYNC_COMPLETION pfnCompletion, uint32_t cbContextData);
74void* VBoxMpCrShgsmiTransportCmdCreateWriteAsync(PVBOXMP_CRSHGSMITRANSPORT pCon, uint32_t u32ClientID, void *pvBuffer, uint32_t cbBuffer,
75 PFNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEASYNC_COMPLETION pfnCompletion, uint32_t cbContextData);
76int VBoxMpCrShgsmiTransportCmdSubmitWriteReadAsync(PVBOXMP_CRSHGSMITRANSPORT pCon, void *pvContext);
77int VBoxMpCrShgsmiTransportCmdSubmitWriteAsync(PVBOXMP_CRSHGSMITRANSPORT pCon, void *pvContext);
78void VBoxMpCrShgsmiTransportCmdTermWriteReadAsync(PVBOXMP_CRSHGSMITRANSPORT pCon, void *pvContext);
79void VBoxMpCrShgsmiTransportCmdTermWriteAsync(PVBOXMP_CRSHGSMITRANSPORT pCon, void *pvContext);
80
81void* VBoxMpCrShgsmiTransportBufAlloc(PVBOXMP_CRSHGSMITRANSPORT pCon, uint32_t cbBuffer);
82void VBoxMpCrShgsmiTransportBufFree(PVBOXMP_CRSHGSMITRANSPORT pCon, void* pvBuffer);
83
84typedef struct VBOXMP_CRPACKER
85{
86 CRPackContext CrPacker;
87 CRPackBuffer CrBuffer;
88} VBOXMP_CRPACKER, *PVBOXMP_CRPACKER;
89
90DECLINLINE(void) VBoxMpCrPackerInit(PVBOXMP_CRPACKER pPacker)
91{
92 memset(pPacker, 0, sizeof (*pPacker));
93}
94
95DECLINLINE(void) VBoxMpCrPackerTerm(PVBOXMP_CRPACKER pPacker)
96{
97 RT_NOREF(pPacker);
98}
99
100DECLINLINE(void) VBoxMpCrPackerTxBufferInit(PVBOXMP_CRPACKER pPacker, void *pvBuffer, uint32_t cbBuffer, uint32_t cCommands)
101{
102 crPackInitBuffer(&pPacker->CrBuffer, pvBuffer, cbBuffer, cbBuffer, cCommands);
103 crPackSetBuffer(&pPacker->CrPacker, &pPacker->CrBuffer);
104}
105
106DECLINLINE(CRMessageOpcodes*) vboxMpCrPackerPrependHeader( const CRPackBuffer *pBuffer, uint32_t *cbData, void **ppvPackBuffer)
107{
108 UINT num_opcodes;
109 CRMessageOpcodes *hdr;
110
111 Assert(pBuffer);
112 Assert(pBuffer->opcode_current < pBuffer->opcode_start);
113 Assert(pBuffer->opcode_current >= pBuffer->opcode_end);
114 Assert(pBuffer->data_current > pBuffer->data_start);
115 Assert(pBuffer->data_current <= pBuffer->data_end);
116
117 num_opcodes = (UINT)(pBuffer->opcode_start - pBuffer->opcode_current);
118 hdr = (CRMessageOpcodes *)
119 ( pBuffer->data_start - ( ( num_opcodes + 3 ) & ~0x3 ) - sizeof(*hdr) );
120
121 Assert((void *) hdr >= pBuffer->pack);
122
123 hdr->header.type = CR_MESSAGE_OPCODES;
124 hdr->numOpcodes = num_opcodes;
125
126 *cbData = (UINT)(pBuffer->data_current - (unsigned char *) hdr);
127 *ppvPackBuffer = pBuffer->pack;
128
129 return hdr;
130}
131
132DECLINLINE(void*) VBoxMpCrPackerTxBufferComplete(PVBOXMP_CRPACKER pPacker, uint32_t *pcbBuffer, void **ppvPackBuffer)
133{
134 crPackReleaseBuffer(&pPacker->CrPacker);
135 uint32_t cbData;
136 CRMessageOpcodes *pHdr;
137 void *pvPackBuffer;
138 if (pPacker->CrBuffer.opcode_current != pPacker->CrBuffer.opcode_start)
139 pHdr = vboxMpCrPackerPrependHeader(&pPacker->CrBuffer, &cbData, &pvPackBuffer);
140 else
141 {
142 cbData = 0;
143 pHdr = NULL;
144 pvPackBuffer = NULL;
145 }
146 *pcbBuffer = cbData;
147 *ppvPackBuffer = pvPackBuffer;
148 return pHdr;
149}
150
151DECLINLINE(uint32_t) VBoxMpCrPackerTxBufferGetFreeBufferSize(PVBOXMP_CRPACKER pPacker)
152{
153 return (uint32_t)(pPacker->CrBuffer.data_end - pPacker->CrBuffer.data_start);
154}
155
156DECLINLINE(void) vboxMpCrUnpackerRxWriteback(CRMessageWriteback *pWb)
157{
158 int *pWriteback;
159 memcpy(&pWriteback, &(pWb->writeback_ptr), sizeof (pWriteback));
160 (*pWriteback)--;
161}
162
163DECLINLINE(void) vboxMpCrUnpackerRxReadback(CRMessageReadback *pRb, uint32_t cbRx)
164{
165 int cbPayload = cbRx - sizeof (*pRb);
166 int *pWriteback;
167 void *pDst;
168 memcpy(&pWriteback, &(pRb->writeback_ptr), sizeof (pWriteback));
169 memcpy(&pDst, &(pRb->readback_ptr), sizeof (pDst));
170
171 (*pWriteback)--;
172 memcpy(pDst, ((uint8_t*)pRb) + sizeof (*pRb), cbPayload);
173}
174
175DECLINLINE(int) VBoxMpCrUnpackerRxBufferProcess(void *pvBuffer, uint32_t cbBuffer)
176{
177 CRMessage *pMsg = (CRMessage*)pvBuffer;
178 switch (pMsg->header.type)
179 {
180 case CR_MESSAGE_WRITEBACK:
181 vboxMpCrUnpackerRxWriteback(&(pMsg->writeback));
182 return VINF_SUCCESS;
183 case CR_MESSAGE_READBACK:
184 vboxMpCrUnpackerRxReadback(&(pMsg->readback), cbBuffer);
185 return VINF_SUCCESS;
186 default:
187 WARN(("unknown msg code %d", pMsg->header.type));
188 return VERR_NOT_SUPPORTED;
189 }
190}
191
192DECLINLINE(void*) VBoxMpCrCmdRxReadbackData(CRMessageReadback *pRx)
193{
194 return pRx + 1;
195}
196
197DECLINLINE(uint32_t) VBoxMpCrCmdRxReadbackDataSize(CRMessageReadback *pRx, uint32_t cbRx)
198{
199 RT_NOREF(pRx);
200 return cbRx - sizeof(*pRx);
201}
202int VBoxMpCrCmdRxReadbackHandler(CRMessageReadback *pRx, uint32_t cbRx);
203int VBoxMpCrCmdRxHandler(CRMessageHeader *pRx, uint32_t cbRx);
204
205/* must be called after calling VBoxMpCrCtlConIs3DSupported only */
206uint32_t VBoxMpCrGetHostCaps(void);
207
208#define VBOXMP_CRCMD_HEADER_SIZE sizeof (CRMessageOpcodes)
209/* last +4 below is 4-aligned command opcode size (i.e. ((1 + 3) & ~3)) */
210#define VBOXMP_CRCMD_SIZE_WINDOWPOSITION (20 + 4)
211#define VBOXMP_CRCMD_SIZE_WINDOWVISIBLEREGIONS(_cRects) (16 + (_cRects) * 4 * sizeof (GLint) + 4)
212#define VBOXMP_CRCMD_SIZE_VBOXTEXPRESENT(_cRects) (28 + (_cRects) * 4 * sizeof (GLint) + 4)
213#define VBOXMP_CRCMD_SIZE_WINDOWSHOW (16 + 4)
214#define VBOXMP_CRCMD_SIZE_WINDOWSIZE (20 + 4)
215#define VBOXMP_CRCMD_SIZE_GETCHROMIUMPARAMETERVCR (36 + 4)
216#define VBOXMP_CRCMD_SIZE_CHROMIUMPARAMETERICR (16 + 4)
217#define VBOXMP_CRCMD_SIZE_WINDOWCREATE (256 + 28 + 4)
218#define VBOXMP_CRCMD_SIZE_WINDOWDESTROY (12 + 4)
219#define VBOXMP_CRCMD_SIZE_CREATECONTEXT (256 + 32 + 4)
220#define VBOXMP_CRCMD_SIZE_DESTROYCONTEXT (12 + 4)
221
222#endif /* #ifdef VBOX_WITH_CROGL */
223
224#endif /* #ifndef ___VBoxMPCr_h__ */
225
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette