VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_protocol.h@ 41109

Last change on this file since 41109 was 39291, checked in by vboxsync, 13 years ago

more corrections

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.3 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_PROTOCOL_H
8#define CR_PROTOCOL_H
9
10#include <iprt/cdefs.h>
11#ifdef DEBUG_misha
12#include "cr_error.h"
13#endif
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/*For now guest is allowed to connect host opengl service if protocol version matches exactly*/
20/*Note: that after any change to this file, or glapi_parser\apispec.txt version should be changed*/
21#define CR_PROTOCOL_VERSION_MAJOR 9
22#define CR_PROTOCOL_VERSION_MINOR 1
23
24typedef enum {
25 /* first message types is 'wGL\001', so we can immediately
26 recognize bad message types */
27 CR_MESSAGE_OPCODES = 0x77474c01,
28 CR_MESSAGE_WRITEBACK,
29 CR_MESSAGE_READBACK,
30 CR_MESSAGE_READ_PIXELS,
31 CR_MESSAGE_MULTI_BODY,
32 CR_MESSAGE_MULTI_TAIL,
33 CR_MESSAGE_FLOW_CONTROL,
34 CR_MESSAGE_OOB,
35 CR_MESSAGE_NEWCLIENT,
36 CR_MESSAGE_GATHER,
37 CR_MESSAGE_ERROR,
38 CR_MESSAGE_CRUT,
39 CR_MESSAGE_REDIR_PTR
40} CRMessageType;
41
42typedef union {
43 /* pointers are usually 4 bytes, but on 64-bit machines (Alpha,
44 * SGI-n64, etc.) they are 8 bytes. Pass network pointers around
45 * as an opaque array of bytes, since the interpretation & size of
46 * the pointer only matter to the machine which emitted the
47 * pointer (and will eventually receive the pointer back again) */
48 unsigned int ptrAlign[2];
49 unsigned char ptrSize[8];
50 /* hack to make this packet big */
51 /* unsigned int junk[512]; */
52} CRNetworkPointer;
53
54#ifdef DEBUG_misha
55#define CRDBGPTR_SETZ(_p) crMemset((_p), 0, sizeof (CRNetworkPointer))
56#define CRDBGPTR_CHECKZ(_p) do { \
57 CRNetworkPointer _ptr = {0}; \
58 CRASSERT(!crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \
59 } while (0)
60#define CRDBGPTR_CHECKNZ(_p) do { \
61 CRNetworkPointer _ptr = {0}; \
62 CRASSERT(crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \
63 } while (0)
64# if 0
65# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { \
66 crDebug(_tStr "%d:0x%08x%08x", (_id), (_p)->ptrAlign[1], (_p)->ptrAlign[0]); \
67 } while (0)
68# else
69# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { } while (0)
70# endif
71#define CRDBGPTR_PRINTWB(_id, _p) _CRDBGPTR_PRINT("wbptr:", _id, _p)
72#define CRDBGPTR_PRINTRB(_id, _p) _CRDBGPTR_PRINT("rbptr:", _id, _p)
73#else
74#define CRDBGPTR_SETZ(_p) do { } while (0)
75#define CRDBGPTR_CHECKZ(_p) do { } while (0)
76#define CRDBGPTR_CHECKNZ(_p) do { } while (0)
77#define CRDBGPTR_PRINTWB(_id, _p) do { } while (0)
78#define CRDBGPTR_PRINTRB(_id, _p) do { } while (0)
79#endif
80
81#ifdef VBOX_WITH_CRHGSMI
82typedef struct CRVBOXHGSMI_CMDDATA {
83 struct VBOXVDMACMD_CHROMIUM_CMD *pCmd;
84 int *pCmdRc;
85 char *pWriteback;
86 unsigned int *pcbWriteback;
87 unsigned int cbWriteback;
88} CRVBOXHGSMI_CMDDATA, *PCRVBOXHGSMI_CMDDATA;
89
90#ifdef DEBUG
91# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { \
92 CRASSERT(!(_pData)->pCmd == !(_pData)->pCmdRc); \
93 CRASSERT(!(_pData)->pWriteback == !(_pData)->pcbWriteback); \
94 CRASSERT(!(_pData)->pWriteback == !(_pData)->cbWriteback); \
95 if ((_pData)->pWriteback) \
96 { \
97 CRASSERT((_pData)->pCmd); \
98 } \
99 } while (0)
100
101# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { \
102 CRASSERT(!(_pData)->pCmd); \
103 CRASSERT(!(_pData)->pCmdRc); \
104 CRASSERT(!(_pData)->pWriteback); \
105 CRASSERT(!(_pData)->pcbWriteback); \
106 CRASSERT(!(_pData)->cbWriteback); \
107 } while (0)
108
109# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { \
110 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
111 CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SET(_pData)); \
112 } while (0)
113
114# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { \
115 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
116 CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData)); \
117 } while (0)
118#else
119# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { } while (0)
120# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { } while (0)
121# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { } while (0)
122# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { } while (0)
123#endif
124
125#define CRVBOXHGSMI_CMDDATA_IS_SET(_pData) (!!(_pData)->pCmd)
126#define CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData) (!!(_pData)->pWriteback)
127
128#define CRVBOXHGSMI_CMDDATA_CLEANUP(_pData) do { \
129 crMemset(_pData, 0, sizeof (CRVBOXHGSMI_CMDDATA)); \
130 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \
131 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
132 } while (0)
133
134#define CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr) do { \
135 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \
136 (_pData)->pCmd = (_pCmd); \
137 (_pData)->pCmdRc = &(_pHdr)->result; \
138 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
139 } while (0)
140
141#define CRVBOXHGSMI_CMDDATA_SETWB(_pData, _pCmd, _pHdr, _pWb, _cbWb, _pcbWb) do { \
142 CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr); \
143 (_pData)->pWriteback = (_pWb); \
144 (_pData)->pcbWriteback = (_pcbWb); \
145 (_pData)->cbWriteback = (_cbWb); \
146 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
147 } while (0)
148
149#define CRVBOXHGSMI_CMDDATA_RC(_pData, _rc) do { \
150 *(_pData)->pCmdRc = (_rc); \
151 } while (0)
152#endif
153
154typedef struct {
155 CRMessageType type;
156 unsigned int conn_id;
157} CRMessageHeader;
158
159typedef struct CRMessageOpcodes {
160 CRMessageHeader header;
161 unsigned int numOpcodes;
162} CRMessageOpcodes;
163
164typedef struct CRMessageRedirPtr {
165 CRMessageHeader header;
166 CRMessageHeader* pMessage;
167#ifdef VBOX_WITH_CRHGSMI
168 CRVBOXHGSMI_CMDDATA CmdData;
169#endif
170} CRMessageRedirPtr;
171
172typedef struct CRMessageWriteback {
173 CRMessageHeader header;
174 CRNetworkPointer writeback_ptr;
175} CRMessageWriteback;
176
177typedef struct CRMessageReadback {
178 CRMessageHeader header;
179 CRNetworkPointer writeback_ptr;
180 CRNetworkPointer readback_ptr;
181} CRMessageReadback;
182
183typedef struct CRMessageMulti {
184 CRMessageHeader header;
185} CRMessageMulti;
186
187typedef struct CRMessageFlowControl {
188 CRMessageHeader header;
189 unsigned int credits;
190} CRMessageFlowControl;
191
192typedef struct CRMessageReadPixels {
193 CRMessageHeader header;
194 int width, height;
195 unsigned int bytes_per_row;
196 unsigned int stride;
197 int alignment;
198 int skipRows;
199 int skipPixels;
200 int rowLength;
201 int format;
202 int type;
203 CRNetworkPointer pixels;
204} CRMessageReadPixels;
205
206typedef struct CRMessageNewClient {
207 CRMessageHeader header;
208} CRMessageNewClient;
209
210typedef struct CRMessageGather {
211 CRMessageHeader header;
212 unsigned long offset;
213 unsigned long len;
214} CRMessageGather;
215
216typedef union {
217 CRMessageHeader header;
218 CRMessageOpcodes opcodes;
219 CRMessageRedirPtr redirptr;
220 CRMessageWriteback writeback;
221 CRMessageReadback readback;
222 CRMessageReadPixels readPixels;
223 CRMessageMulti multi;
224 CRMessageFlowControl flowControl;
225 CRMessageNewClient newclient;
226 CRMessageGather gather;
227} CRMessage;
228
229DECLEXPORT(void) crNetworkPointerWrite( CRNetworkPointer *dst, void *src );
230
231#ifdef __cplusplus
232}
233#endif
234
235#endif /* CR_PROTOCOL_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