hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
/**************************************************************************/ /*!
@File
@Title          Server side synchronisation interface
@Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description    Describes the server side synchronisation functions
@License        Dual MIT/GPLv2
 
The contents of this file are subject to the MIT license as set out below.
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
 
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
 
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
 
This License is also included in this distribution in the file called
"MIT-COPYING".
 
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ /***************************************************************************/
 
#include "server_sync_primitive.h"
#include "img_types.h"
#include "device.h"
#include "devicemem.h"
#include "pdump.h"
#include "pvrsrv_error.h"
#include "connection_server.h"
 
#ifndef _SYNC_SERVER_H_
#define _SYNC_SERVER_H_
 
typedef struct _SERVER_OP_COOKIE_ SERVER_OP_COOKIE;
typedef struct _SYNC_PRIMITIVE_BLOCK_ SYNC_PRIMITIVE_BLOCK;
typedef struct _SERVER_SYNC_EXPORT_ SERVER_SYNC_EXPORT;
typedef struct _SYNC_CONNECTION_DATA_ SYNC_CONNECTION_DATA;
typedef struct SYNC_RECORD* SYNC_RECORD_HANDLE;
 
typedef struct _SYNC_ADDR_LIST_
{
   IMG_UINT32 ui32NumSyncs;
   PRGXFWIF_UFO_ADDR *pasFWAddrs;
} SYNC_ADDR_LIST;
 
PVRSRV_ERROR
SyncPrimitiveBlockToFWAddr(SYNC_PRIMITIVE_BLOCK *psSyncPrimBlock,
                       IMG_UINT32 ui32Offset,
                       PRGXFWIF_UFO_ADDR *psAddrOut);
 
void
SyncAddrListInit(SYNC_ADDR_LIST *psList);
 
void
SyncAddrListDeinit(SYNC_ADDR_LIST *psList);
 
PVRSRV_ERROR
SyncAddrListPopulate(SYNC_ADDR_LIST *psList,
                       IMG_UINT32 ui32NumSyncs,
                       SYNC_PRIMITIVE_BLOCK **apsSyncPrimBlock,
                       IMG_UINT32 *paui32SyncOffset);
 
PVRSRV_ERROR
PVRSRVAllocSyncPrimitiveBlockKM(CONNECTION_DATA *psConnection,
                                PVRSRV_DEVICE_NODE * psDevNode,
                               SYNC_PRIMITIVE_BLOCK **ppsSyncBlk,
                               IMG_UINT32 *puiSyncPrimVAddr,
                               IMG_UINT32 *puiSyncPrimBlockSize,
                               PMR        **ppsSyncPMR);
 
PVRSRV_ERROR
PVRSRVExportSyncPrimitiveBlockKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk,
                                DEVMEM_EXPORTCOOKIE **psExportCookie);
 
PVRSRV_ERROR
PVRSRVUnexportSyncPrimitiveBlockKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk);
 
PVRSRV_ERROR
PVRSRVFreeSyncPrimitiveBlockKM(SYNC_PRIMITIVE_BLOCK *ppsSyncBlk);
 
PVRSRV_ERROR
PVRSRVSyncPrimSetKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Index,
                   IMG_UINT32 ui32Value);
 
PVRSRV_ERROR
PVRSRVServerSyncPrimSetKM(SERVER_SYNC_PRIMITIVE *psServerSync, IMG_UINT32 ui32Value);
 
#if defined(SUPPORT_INSECURE_EXPORT)
PVRSRV_ERROR
PVRSRVSyncPrimServerExportKM(SERVER_SYNC_PRIMITIVE *psSync,
                           SERVER_SYNC_EXPORT **ppsExport);
 
PVRSRV_ERROR
PVRSRVSyncPrimServerUnexportKM(SERVER_SYNC_EXPORT *psExport);
 
PVRSRV_ERROR
PVRSRVSyncPrimServerImportKM(CONNECTION_DATA *psConnection,
                            PVRSRV_DEVICE_NODE *psDevNode,
                            SERVER_SYNC_EXPORT *psExport,
                            SERVER_SYNC_PRIMITIVE **ppsSync,
                            IMG_UINT32 *pui32SyncPrimVAddr);
#endif
 
#if defined(SUPPORT_SECURE_EXPORT)
PVRSRV_ERROR
PVRSRVSyncPrimServerSecureExportKM(CONNECTION_DATA *psConnection,
                                   PVRSRV_DEVICE_NODE * psDevNode,
                                  SERVER_SYNC_PRIMITIVE *psSync,
                                  IMG_SECURE_TYPE *phSecure,
                                  SERVER_SYNC_EXPORT **ppsExport,
                                  CONNECTION_DATA **ppsSecureConnection);
 
PVRSRV_ERROR
PVRSRVSyncPrimServerSecureUnexportKM(SERVER_SYNC_EXPORT *psExport);
 
PVRSRV_ERROR
PVRSRVSyncPrimServerSecureImportKM(CONNECTION_DATA *psConnection,
                                  PVRSRV_DEVICE_NODE *psDevNode,
                                  IMG_SECURE_TYPE hSecure,
                                  SERVER_SYNC_PRIMITIVE **ppsSync,
                                  IMG_UINT32 *pui32SyncPrimVAddr);
#endif
 
IMG_UINT32 PVRSRVServerSyncRequesterRegisterKM(IMG_UINT32 *pui32SyncRequesterID);
void PVRSRVServerSyncRequesterUnregisterKM(IMG_UINT32 ui32SyncRequesterID);
 
PVRSRV_ERROR
PVRSRVSyncAllocEventKM(IMG_BOOL bServerSync,
                       IMG_UINT32 ui32FWAddr,
                       IMG_UINT32 ui32ClassNameSize,
                       const IMG_CHAR *pszClassName);
 
PVRSRV_ERROR
PVRSRVSyncFreeEventKM(IMG_UINT32 ui32FWAddr);
 
PVRSRV_ERROR
PVRSRVSyncRecordAddKM(CONNECTION_DATA *psConnection,
                     PVRSRV_DEVICE_NODE *psDevNode,
                     SYNC_RECORD_HANDLE *phRecord,
                     SYNC_PRIMITIVE_BLOCK *hServerSyncPrimBlock,
                     IMG_UINT32 ui32FwBlockAddr,
                     IMG_UINT32 ui32SyncOffset,
                     IMG_BOOL bServerSync,
                     IMG_UINT32 ui32ClassNameSize,
                     const IMG_CHAR *pszClassName);
 
PVRSRV_ERROR
PVRSRVSyncRecordRemoveByHandleKM(
           SYNC_RECORD_HANDLE hRecord);
 
PVRSRV_ERROR
PVRSRVServerSyncAllocKM(CONNECTION_DATA * psConnection,
                        PVRSRV_DEVICE_NODE *psDevNode,
                       SERVER_SYNC_PRIMITIVE **ppsSync,
                       IMG_UINT32 *pui32SyncPrimVAddr,
                       IMG_UINT32 ui32ClassNameSize,
                       const IMG_CHAR *szClassName);
PVRSRV_ERROR
PVRSRVServerSyncFreeKM(SERVER_SYNC_PRIMITIVE *psSync);
 
PVRSRV_ERROR
PVRSRVServerSyncGetStatusKM(IMG_UINT32 ui32SyncCount,
                           SERVER_SYNC_PRIMITIVE **papsSyncs,
                           IMG_UINT32 *pui32UID,
                           IMG_UINT32 *pui32FWAddr,
                           IMG_UINT32 *pui32CurrentOp,
                           IMG_UINT32 *pui32NextOp);
 
PVRSRV_ERROR
PVRSRVServerSyncQueueSWOpKM(SERVER_SYNC_PRIMITIVE *psSync,
                         IMG_UINT32 *pui32FenceValue,
                         IMG_UINT32 *pui32UpdateValue,
                         IMG_UINT32 ui32SyncRequesterID,
                         IMG_BOOL bUpdate,
                         IMG_BOOL *pbFenceRequired);
 
PVRSRV_ERROR
PVRSRVServerSyncQueueHWOpKM(SERVER_SYNC_PRIMITIVE *psSync,
                              IMG_BOOL bUpdate,
                              IMG_UINT32 *pui32FenceValue,
                              IMG_UINT32 *pui32UpdateValue);
 
IMG_BOOL
ServerSyncFenceIsMet(SERVER_SYNC_PRIMITIVE *psSync,
                    IMG_UINT32 ui32FenceValue);
 
void
ServerSyncCompleteOp(SERVER_SYNC_PRIMITIVE *psSync,
                    IMG_BOOL bDoUpdate,
                    IMG_UINT32 ui32UpdateValue);
 
 
PVRSRV_ERROR
PVRSRVSyncPrimOpCreateKM(IMG_UINT32 ui32SyncBlockCount,
                        SYNC_PRIMITIVE_BLOCK **papsSyncPrimBlock,
                        IMG_UINT32 ui32ClientSyncCount,
                        IMG_UINT32 *paui32SyncBlockIndex,
                        IMG_UINT32 *paui32Index,
                        IMG_UINT32 ui32ServerSyncCount,
                        SERVER_SYNC_PRIMITIVE **papsServerSync,
                        SERVER_OP_COOKIE **ppsServerCookie);
 
PVRSRV_ERROR
PVRSRVSyncPrimOpTakeKM(SERVER_OP_COOKIE *psServerCookie,
                          IMG_UINT32 ui32ClientSyncCount,
                          IMG_UINT32 *paui32Flags,
                          IMG_UINT32 *paui32FenceValue,
                          IMG_UINT32 *paui32UpdateValue,
                          IMG_UINT32 ui32ServerSyncCount,
                          IMG_UINT32 *paui32ServerFlags);
 
PVRSRV_ERROR
PVRSRVSyncPrimOpReadyKM(SERVER_OP_COOKIE *psServerCookie,
                       IMG_BOOL *pbReady);
 
PVRSRV_ERROR
PVRSRVSyncPrimOpCompleteKM(SERVER_OP_COOKIE *psServerCookie);
 
PVRSRV_ERROR
PVRSRVSyncPrimOpDestroyKM(SERVER_OP_COOKIE *psServerCookie);
 
IMG_UINT32 ServerSyncGetId(SERVER_SYNC_PRIMITIVE *psSync);
 
PVRSRV_ERROR
ServerSyncGetFWAddr(SERVER_SYNC_PRIMITIVE *psSync, IMG_UINT32 *pui32SyncAddr);
 
IMG_UINT32 ServerSyncGetValue(SERVER_SYNC_PRIMITIVE *psSync);
 
IMG_UINT32 ServerSyncGetNextValue(SERVER_SYNC_PRIMITIVE *psSync);
 
#if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING)
void SyncRecordLookup(PVRSRV_DEVICE_NODE *psDevNode, IMG_UINT32 ui32FwAddr,
                     IMG_CHAR * pszSyncInfo, size_t len);
#endif
 
void ServerSyncDumpPending(void);
 
PVRSRV_ERROR SyncRegisterConnection(SYNC_CONNECTION_DATA **ppsSyncConnectionData);
void SyncUnregisterConnection(SYNC_CONNECTION_DATA *ppsSyncConnectionData);
void SyncConnectionPDumpSyncBlocks(SYNC_CONNECTION_DATA *ppsSyncConnectionData);
 
PVRSRV_ERROR ServerSyncInit(PVRSRV_DEVICE_NODE *psDevNode);
void ServerSyncDeinit(PVRSRV_DEVICE_NODE *psDevNode);
 
#if defined(PDUMP)
PVRSRV_ERROR
PVRSRVSyncPrimPDumpKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset);
 
PVRSRV_ERROR
PVRSRVSyncPrimPDumpValueKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset, 
                           IMG_UINT32 ui32Value);
 
PVRSRV_ERROR
PVRSRVSyncPrimPDumpPolKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset,
                        IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask,
                        PDUMP_POLL_OPERATOR eOperator,
                        PDUMP_FLAGS_T uiDumpFlags);
 
PVRSRV_ERROR
PVRSRVSyncPrimOpPDumpPolKM(SERVER_OP_COOKIE *psServerCookie,
                        PDUMP_POLL_OPERATOR eOperator,
                        PDUMP_FLAGS_T ui32PDumpFlags);
 
PVRSRV_ERROR
PVRSRVSyncPrimPDumpCBPKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT64 ui32Offset,
                        IMG_UINT64 uiWriteOffset, IMG_UINT64 uiPacketSize,
                        IMG_UINT64 uiBufferSize);
 
#else    /* PDUMP */
 
#ifdef INLINE_IS_PRAGMA
#pragma inline(PVRSRVSyncPrimPDumpKM)
#endif
static INLINE PVRSRV_ERROR
PVRSRVSyncPrimPDumpKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset)
{
   PVR_UNREFERENCED_PARAMETER(psSyncBlk);
   PVR_UNREFERENCED_PARAMETER(ui32Offset);
   return PVRSRV_OK;
}
 
#ifdef INLINE_IS_PRAGMA
#pragma inline(PVRSRVSyncPrimPDumpValueKM)
#endif
static INLINE PVRSRV_ERROR
PVRSRVSyncPrimPDumpValueKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset, 
                           IMG_UINT32 ui32Value)
{
   PVR_UNREFERENCED_PARAMETER(psSyncBlk);
   PVR_UNREFERENCED_PARAMETER(ui32Offset);
   PVR_UNREFERENCED_PARAMETER(ui32Value);
   return PVRSRV_OK;
}
 
#ifdef INLINE_IS_PRAGMA
#pragma inline(PVRSRVSyncPrimPDumpPolKM)
#endif
static INLINE PVRSRV_ERROR
PVRSRVSyncPrimPDumpPolKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset,
                        IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask,
                        PDUMP_POLL_OPERATOR eOperator,
                        PDUMP_FLAGS_T uiDumpFlags)
{
   PVR_UNREFERENCED_PARAMETER(psSyncBlk);
   PVR_UNREFERENCED_PARAMETER(ui32Offset);
   PVR_UNREFERENCED_PARAMETER(ui32Value);
   PVR_UNREFERENCED_PARAMETER(ui32Mask);
   PVR_UNREFERENCED_PARAMETER(eOperator);
   PVR_UNREFERENCED_PARAMETER(uiDumpFlags);
   return PVRSRV_OK;
}
 
#ifdef INLINE_IS_PRAGMA
#pragma inline(PVRSRVSyncPrimOpPDumpPolKM)
#endif
static INLINE PVRSRV_ERROR
PVRSRVSyncPrimOpPDumpPolKM(SERVER_OP_COOKIE *psServerCookie,
                        PDUMP_POLL_OPERATOR eOperator,
                        PDUMP_FLAGS_T uiDumpFlags)
{
   PVR_UNREFERENCED_PARAMETER(psServerCookie);
   PVR_UNREFERENCED_PARAMETER(eOperator);
   PVR_UNREFERENCED_PARAMETER(uiDumpFlags);
   return PVRSRV_OK;
}
 
#ifdef INLINE_IS_PRAGMA
#pragma inline(PVRSRVSyncPrimPDumpCBPKM)
#endif
static INLINE PVRSRV_ERROR
PVRSRVSyncPrimPDumpCBPKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT64 ui32Offset,
                        IMG_UINT64 uiWriteOffset, IMG_UINT64 uiPacketSize,
                        IMG_UINT64 uiBufferSize)
{
   PVR_UNREFERENCED_PARAMETER(psSyncBlk);
   PVR_UNREFERENCED_PARAMETER(ui32Offset);
   PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
   PVR_UNREFERENCED_PARAMETER(uiPacketSize);
   PVR_UNREFERENCED_PARAMETER(uiBufferSize);
   return PVRSRV_OK;
}
#endif    /* PDUMP */
#endif    /*_SYNC_SERVER_H_ */