[android-sdk/device-ti-proprietary-open.git] / omap5 / sgx_src / eurasia_km / services4 / srvkm / bridged / sgx / bridged_sgx_bridge.c
1 /*************************************************************************/ /*!
2 @Title SGX Common Bridge Module (kernel side)
3 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description Receives calls from the user portion of services and
5 despatches them to functions in the kernel portion.
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
46 #include <stddef.h>
48 #include "img_defs.h"
50 #if defined(SUPPORT_SGX)
52 #include "services.h"
53 #include "pvr_debug.h"
54 #include "pvr_bridge.h"
55 #include "sgx_bridge.h"
56 #include "perproc.h"
57 #include "power.h"
58 #include "pvr_bridge_km.h"
59 #include "sgx_bridge_km.h"
60 #include "sgx_options.h"
62 #if defined(SUPPORT_MSVDX)
63 #include "msvdx_bridge.h"
64 #endif
66 #include "bridged_pvr_bridge.h"
67 #include "bridged_sgx_bridge.h"
68 #include "sgxutils.h"
69 #include "buffer_manager.h"
70 #include "pdump_km.h"
72 static IMG_INT
73 SGXGetClientInfoBW(IMG_UINT32 ui32BridgeID,
74 PVRSRV_BRIDGE_IN_GETCLIENTINFO *psGetClientInfoIN,
75 PVRSRV_BRIDGE_OUT_GETCLIENTINFO *psGetClientInfoOUT,
76 PVRSRV_PER_PROCESS_DATA *psPerProc)
77 {
78 IMG_HANDLE hDevCookieInt;
80 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_GETCLIENTINFO);
82 psGetClientInfoOUT->eError =
83 PVRSRVLookupHandle(psPerProc->psHandleBase,
84 &hDevCookieInt,
85 psGetClientInfoIN->hDevCookie,
86 PVRSRV_HANDLE_TYPE_DEV_NODE);
87 if(psGetClientInfoOUT->eError != PVRSRV_OK)
88 {
89 return 0;
90 }
92 psGetClientInfoOUT->eError =
93 SGXGetClientInfoKM(hDevCookieInt,
94 &psGetClientInfoOUT->sClientInfo);
95 return 0;
96 }
98 static IMG_INT
99 SGXReleaseClientInfoBW(IMG_UINT32 ui32BridgeID,
100 PVRSRV_BRIDGE_IN_RELEASECLIENTINFO *psReleaseClientInfoIN,
101 PVRSRV_BRIDGE_RETURN *psRetOUT,
102 PVRSRV_PER_PROCESS_DATA *psPerProc)
103 {
104 PVRSRV_SGXDEV_INFO *psDevInfo;
105 IMG_HANDLE hDevCookieInt;
107 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_RELEASECLIENTINFO);
109 psRetOUT->eError =
110 PVRSRVLookupHandle(psPerProc->psHandleBase,
111 &hDevCookieInt,
112 psReleaseClientInfoIN->hDevCookie,
113 PVRSRV_HANDLE_TYPE_DEV_NODE);
114 if(psRetOUT->eError != PVRSRV_OK)
115 {
116 return 0;
117 }
119 psDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookieInt)->pvDevice;
121 PVR_ASSERT(psDevInfo->ui32ClientRefCount > 0);
123 /*
124 * psDevInfo->ui32ClientRefCount can be zero if an error occurred before SGXGetClientInfo is called
125 */
126 if (psDevInfo->ui32ClientRefCount > 0)
127 {
128 psDevInfo->ui32ClientRefCount--;
129 }
131 psRetOUT->eError = PVRSRV_OK;
133 return 0;
134 }
137 static IMG_INT
138 SGXGetInternalDevInfoBW(IMG_UINT32 ui32BridgeID,
139 PVRSRV_BRIDGE_IN_GETINTERNALDEVINFO *psSGXGetInternalDevInfoIN,
140 PVRSRV_BRIDGE_OUT_GETINTERNALDEVINFO *psSGXGetInternalDevInfoOUT,
141 PVRSRV_PER_PROCESS_DATA *psPerProc)
142 {
143 IMG_HANDLE hDevCookieInt;
144 #if defined (SUPPORT_SID_INTERFACE)
145 SGX_INTERNAL_DEVINFO_KM sSGXInternalDevInfo;
146 #endif
148 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_GETINTERNALDEVINFO);
150 psSGXGetInternalDevInfoOUT->eError =
151 PVRSRVLookupHandle(psPerProc->psHandleBase,
152 &hDevCookieInt,
153 psSGXGetInternalDevInfoIN->hDevCookie,
154 PVRSRV_HANDLE_TYPE_DEV_NODE);
155 if(psSGXGetInternalDevInfoOUT->eError != PVRSRV_OK)
156 {
157 return 0;
158 }
160 psSGXGetInternalDevInfoOUT->eError =
161 SGXGetInternalDevInfoKM(hDevCookieInt,
162 #if defined (SUPPORT_SID_INTERFACE)
163 &sSGXInternalDevInfo);
164 #else
165 &psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo);
166 #endif
168 /*
169 * Handle is not allocated in batch mode, as there is no resource
170 * allocation to undo if the handle allocation fails.
171 */
172 psSGXGetInternalDevInfoOUT->eError =
173 PVRSRVAllocHandle(psPerProc->psHandleBase,
174 &psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle,
175 #if defined (SUPPORT_SID_INTERFACE)
176 sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle,
177 #else
178 psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle,
179 #endif
180 PVRSRV_HANDLE_TYPE_MEM_INFO,
181 PVRSRV_HANDLE_ALLOC_FLAG_SHARED);
183 return 0;
184 }
187 static IMG_INT
188 SGXDoKickBW(IMG_UINT32 ui32BridgeID,
189 PVRSRV_BRIDGE_IN_DOKICK *psDoKickIN,
190 PVRSRV_BRIDGE_RETURN *psRetOUT,
191 PVRSRV_PER_PROCESS_DATA *psPerProc)
192 {
193 IMG_HANDLE hDevCookieInt;
194 IMG_UINT32 i;
195 IMG_INT ret = 0;
196 IMG_UINT32 ui32NumDstSyncs;
197 #if defined (SUPPORT_SID_INTERFACE)
198 SGX_CCB_KICK_KM sCCBKickKM = {{0}};
199 IMG_HANDLE ahSyncInfoHandles[16];
200 #else
201 IMG_HANDLE *phKernelSyncInfoHandles = IMG_NULL;
202 #endif
204 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DOKICK);
206 psRetOUT->eError =
207 PVRSRVLookupHandle(psPerProc->psHandleBase,
208 &hDevCookieInt,
209 psDoKickIN->hDevCookie,
210 PVRSRV_HANDLE_TYPE_DEV_NODE);
212 if(psRetOUT->eError != PVRSRV_OK)
213 {
214 return 0;
215 }
217 psRetOUT->eError =
218 PVRSRVLookupHandle(psPerProc->psHandleBase,
219 #if defined (SUPPORT_SID_INTERFACE)
220 &sCCBKickKM.hCCBKernelMemInfo,
221 #else
222 &psDoKickIN->sCCBKick.hCCBKernelMemInfo,
223 #endif
224 psDoKickIN->sCCBKick.hCCBKernelMemInfo,
225 PVRSRV_HANDLE_TYPE_MEM_INFO);
227 if(psRetOUT->eError != PVRSRV_OK)
228 {
229 return 0;
230 }
232 #if defined (SUPPORT_SID_INTERFACE)
233 if (psDoKickIN->sCCBKick.ui32NumDstSyncObjects > 16)
234 {
235 return 0;
236 }
238 if(psDoKickIN->sCCBKick.hTA3DSyncInfo != 0)
239 #else
240 if(psDoKickIN->sCCBKick.hTA3DSyncInfo != IMG_NULL)
241 #endif
242 {
243 psRetOUT->eError =
244 PVRSRVLookupHandle(psPerProc->psHandleBase,
245 #if defined (SUPPORT_SID_INTERFACE)
246 &sCCBKickKM.hTA3DSyncInfo,
247 #else
248 &psDoKickIN->sCCBKick.hTA3DSyncInfo,
249 #endif
250 psDoKickIN->sCCBKick.hTA3DSyncInfo,
251 PVRSRV_HANDLE_TYPE_SYNC_INFO);
253 if(psRetOUT->eError != PVRSRV_OK)
254 {
255 return 0;
256 }
257 }
259 #if defined (SUPPORT_SID_INTERFACE)
260 if(psDoKickIN->sCCBKick.hTASyncInfo != 0)
261 #else
262 if(psDoKickIN->sCCBKick.hTASyncInfo != IMG_NULL)
263 #endif
264 {
265 psRetOUT->eError =
266 PVRSRVLookupHandle(psPerProc->psHandleBase,
267 #if defined (SUPPORT_SID_INTERFACE)
268 &sCCBKickKM.hTASyncInfo,
269 #else
270 &psDoKickIN->sCCBKick.hTASyncInfo,
271 #endif
272 psDoKickIN->sCCBKick.hTASyncInfo,
273 PVRSRV_HANDLE_TYPE_SYNC_INFO);
275 if(psRetOUT->eError != PVRSRV_OK)
276 {
277 return 0;
278 }
279 }
281 #if defined(FIX_HW_BRN_31620)
282 /* We need to lookup the mem context and pass it through */
283 psRetOUT->eError =
284 PVRSRVLookupHandle(psPerProc->psHandleBase,
285 &psDoKickIN->sCCBKick.hDevMemContext,
286 psDoKickIN->sCCBKick.hDevMemContext,
287 PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
289 if(psRetOUT->eError != PVRSRV_OK)
290 {
291 return 0;
292 }
293 #endif
295 #if defined (SUPPORT_SID_INTERFACE)
296 if(psDoKickIN->sCCBKick.h3DSyncInfo != 0)
297 #else
298 if(psDoKickIN->sCCBKick.h3DSyncInfo != IMG_NULL)
299 #endif
300 {
301 psRetOUT->eError =
302 PVRSRVLookupHandle(psPerProc->psHandleBase,
303 #if defined (SUPPORT_SID_INTERFACE)
304 &sCCBKickKM.h3DSyncInfo,
305 #else
306 &psDoKickIN->sCCBKick.h3DSyncInfo,
307 #endif
308 psDoKickIN->sCCBKick.h3DSyncInfo,
309 PVRSRV_HANDLE_TYPE_SYNC_INFO);
311 if(psRetOUT->eError != PVRSRV_OK)
312 {
313 return 0;
314 }
315 }
318 #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS)
319 /* SRC and DST sync details */
320 if (psDoKickIN->sCCBKick.ui32NumTASrcSyncs > SGX_MAX_TA_SRC_SYNCS)
321 {
322 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
323 return 0;
324 }
326 #if defined (SUPPORT_SID_INTERFACE)
327 sCCBKickKM.ui32NumTASrcSyncs = psDoKickIN->sCCBKick.ui32NumTASrcSyncs;
328 #endif
329 for(i=0; i<psDoKickIN->sCCBKick.ui32NumTASrcSyncs; i++)
330 {
331 psRetOUT->eError =
332 PVRSRVLookupHandle(psPerProc->psHandleBase,
333 #if defined (SUPPORT_SID_INTERFACE)
334 &sCCBKickKM.ahTASrcKernelSyncInfo[i],
335 #else
336 &psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i],
337 #endif
338 psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i],
339 PVRSRV_HANDLE_TYPE_SYNC_INFO);
341 if(psRetOUT->eError != PVRSRV_OK)
342 {
343 return 0;
344 }
345 }
347 if (psDoKickIN->sCCBKick.ui32NumTADstSyncs > SGX_MAX_TA_DST_SYNCS)
348 {
349 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
350 return 0;
351 }
353 #if defined (SUPPORT_SID_INTERFACE)
354 sCCBKickKM.ui32NumTADstSyncs = psDoKickIN->sCCBKick.ui32NumTADstSyncs;
355 #endif
356 for(i=0; i<psDoKickIN->sCCBKick.ui32NumTADstSyncs; i++)
357 {
358 psRetOUT->eError =
359 PVRSRVLookupHandle(psPerProc->psHandleBase,
360 #if defined (SUPPORT_SID_INTERFACE)
361 &sCCBKickKM.ahTADstKernelSyncInfo[i],
362 #else
363 &psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i],
364 #endif
365 psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i],
366 PVRSRV_HANDLE_TYPE_SYNC_INFO);
368 if(psRetOUT->eError != PVRSRV_OK)
369 {
370 return 0;
371 }
372 }
374 if (psDoKickIN->sCCBKick.ui32Num3DSrcSyncs > SGX_MAX_3D_SRC_SYNCS)
375 {
376 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
377 return 0;
378 }
380 #if defined (SUPPORT_SID_INTERFACE)
381 sCCBKickKM.ui32Num3DSrcSyncs = psDoKickIN->sCCBKick.ui32Num3DSrcSyncs;
382 #endif
383 for(i=0; i<psDoKickIN->sCCBKick.ui32Num3DSrcSyncs; i++)
384 {
385 psRetOUT->eError =
386 PVRSRVLookupHandle(psPerProc->psHandleBase,
387 #if defined (SUPPORT_SID_INTERFACE)
388 &sCCBKickKM.ah3DSrcKernelSyncInfo[i],
389 #else
390 &psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i],
391 #endif
392 psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i],
393 PVRSRV_HANDLE_TYPE_SYNC_INFO);
395 if(psRetOUT->eError != PVRSRV_OK)
396 {
397 return 0;
398 }
399 }
400 #else/* #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */
401 /* texture dependency details */
402 if (psDoKickIN->sCCBKick.ui32NumSrcSyncs > SGX_MAX_SRC_SYNCS_TA)
403 {
404 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
405 return 0;
406 }
408 #if defined (SUPPORT_SID_INTERFACE)
409 sCCBKickKM.ui32NumSrcSyncs = psDoKickIN->sCCBKick.ui32NumSrcSyncs;
410 #endif
411 for(i=0; i<psDoKickIN->sCCBKick.ui32NumSrcSyncs; i++)
412 {
413 psRetOUT->eError =
414 PVRSRVLookupHandle(psPerProc->psHandleBase,
415 #if defined (SUPPORT_SID_INTERFACE)
416 &sCCBKickKM.ahSrcKernelSyncInfo[i],
417 #else
418 &psDoKickIN->sCCBKick.ahSrcKernelSyncInfo[i],
419 #endif
420 psDoKickIN->sCCBKick.ahSrcKernelSyncInfo[i],
421 PVRSRV_HANDLE_TYPE_SYNC_INFO);
423 if(psRetOUT->eError != PVRSRV_OK)
424 {
425 return 0;
426 }
427 }
428 #endif/* #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) */
430 if (psDoKickIN->sCCBKick.ui32NumTAStatusVals > SGX_MAX_TA_STATUS_VALS)
431 {
432 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
433 return 0;
434 }
435 for (i = 0; i < psDoKickIN->sCCBKick.ui32NumTAStatusVals; i++)
436 {
437 psRetOUT->eError =
438 #if defined(SUPPORT_SGX_NEW_STATUS_VALS)
439 PVRSRVLookupHandle(psPerProc->psHandleBase,
440 #if defined (SUPPORT_SID_INTERFACE)
441 &sCCBKickKM.asTAStatusUpdate[i].hKernelMemInfo,
442 #else
443 &psDoKickIN->sCCBKick.asTAStatusUpdate[i].hKernelMemInfo,
444 #endif
445 psDoKickIN->sCCBKick.asTAStatusUpdate[i].hKernelMemInfo,
446 PVRSRV_HANDLE_TYPE_MEM_INFO);
448 #if defined (SUPPORT_SID_INTERFACE)
449 sCCBKickKM.asTAStatusUpdate[i].sCtlStatus = psDoKickIN->sCCBKick.asTAStatusUpdate[i].sCtlStatus;
450 #endif
452 #else
453 PVRSRVLookupHandle(psPerProc->psHandleBase,
454 #if defined (SUPPORT_SID_INTERFACE)
455 &sCCBKickKM.ahTAStatusSyncInfo[i],
456 #else
457 &psDoKickIN->sCCBKick.ahTAStatusSyncInfo[i],
458 #endif
459 psDoKickIN->sCCBKick.ahTAStatusSyncInfo[i],
460 PVRSRV_HANDLE_TYPE_SYNC_INFO);
461 #endif
462 if(psRetOUT->eError != PVRSRV_OK)
463 {
464 return 0;
465 }
466 }
468 if (psDoKickIN->sCCBKick.ui32Num3DStatusVals > SGX_MAX_3D_STATUS_VALS)
469 {
470 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
471 return 0;
472 }
473 for(i = 0; i < psDoKickIN->sCCBKick.ui32Num3DStatusVals; i++)
474 {
475 psRetOUT->eError =
476 #if defined(SUPPORT_SGX_NEW_STATUS_VALS)
477 PVRSRVLookupHandle(psPerProc->psHandleBase,
478 #if defined (SUPPORT_SID_INTERFACE)
479 &sCCBKickKM.as3DStatusUpdate[i].hKernelMemInfo,
480 #else
481 &psDoKickIN->sCCBKick.as3DStatusUpdate[i].hKernelMemInfo,
482 #endif
483 psDoKickIN->sCCBKick.as3DStatusUpdate[i].hKernelMemInfo,
484 PVRSRV_HANDLE_TYPE_MEM_INFO);
486 #if defined (SUPPORT_SID_INTERFACE)
487 sCCBKickKM.as3DStatusUpdate[i].sCtlStatus = psDoKickIN->sCCBKick.as3DStatusUpdate[i].sCtlStatus;
488 #endif
489 #else
490 PVRSRVLookupHandle(psPerProc->psHandleBase,
491 #if defined (SUPPORT_SID_INTERFACE)
492 &sCCBKickKM.ah3DStatusSyncInfo[i],
493 #else
494 &psDoKickIN->sCCBKick.ah3DStatusSyncInfo[i],
495 #endif
496 psDoKickIN->sCCBKick.ah3DStatusSyncInfo[i],
497 PVRSRV_HANDLE_TYPE_SYNC_INFO);
498 #endif
500 if(psRetOUT->eError != PVRSRV_OK)
501 {
502 return 0;
503 }
504 }
506 ui32NumDstSyncs = psDoKickIN->sCCBKick.ui32NumDstSyncObjects;
508 if(ui32NumDstSyncs > 0)
509 {
510 if(!OSAccessOK(PVR_VERIFY_READ,
511 psDoKickIN->sCCBKick.pahDstSyncHandles,
512 ui32NumDstSyncs * sizeof(IMG_HANDLE)))
513 {
514 PVR_DPF((PVR_DBG_ERROR, "%s: SGXDoKickBW:"
515 " Invalid pasDstSyncHandles pointer", __FUNCTION__));
516 return -EFAULT;
517 }
519 psRetOUT->eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
520 ui32NumDstSyncs * sizeof(IMG_HANDLE),
521 (IMG_VOID **)&phKernelSyncInfoHandles,
522 0,
523 "Array of Synchronization Info Handles");
524 if (psRetOUT->eError != PVRSRV_OK)
525 {
526 return 0;
527 }
529 #if defined (SUPPORT_SID_INTERFACE)
530 sCCBKickKM.pahDstSyncHandles = phKernelSyncInfoHandles;
531 #else
532 if(CopyFromUserWrapper(psPerProc,
533 ui32BridgeID,
534 phKernelSyncInfoHandles,
535 psDoKickIN->sCCBKick.pahDstSyncHandles,
536 ui32NumDstSyncs * sizeof(IMG_HANDLE)) != PVRSRV_OK)
537 {
538 ret = -EFAULT;
539 goto PVRSRV_BRIDGE_SGX_DOKICK_RETURN_RESULT;
540 }
542 /* Set sCCBKick.pahDstSyncHandles to point to the local memory */
543 psDoKickIN->sCCBKick.pahDstSyncHandles = phKernelSyncInfoHandles;
544 #endif
546 for( i = 0; i < ui32NumDstSyncs; i++)
547 {
548 psRetOUT->eError =
549 PVRSRVLookupHandle(psPerProc->psHandleBase,
550 #if defined (SUPPORT_SID_INTERFACE)
551 &sCCBKickKM.pahDstSyncHandles[i],
552 #else
553 &psDoKickIN->sCCBKick.pahDstSyncHandles[i],
554 #endif
555 psDoKickIN->sCCBKick.pahDstSyncHandles[i],
556 PVRSRV_HANDLE_TYPE_SYNC_INFO);
558 if(psRetOUT->eError != PVRSRV_OK)
559 {
560 goto PVRSRV_BRIDGE_SGX_DOKICK_RETURN_RESULT;
561 }
563 }
565 psRetOUT->eError =
566 PVRSRVLookupHandle(psPerProc->psHandleBase,
567 #if defined (SUPPORT_SID_INTERFACE)
568 &sCCBKickKM.hKernelHWSyncListMemInfo,
569 #else
570 &psDoKickIN->sCCBKick.hKernelHWSyncListMemInfo,
571 #endif
572 psDoKickIN->sCCBKick.hKernelHWSyncListMemInfo,
573 PVRSRV_HANDLE_TYPE_MEM_INFO);
575 if(psRetOUT->eError != PVRSRV_OK)
576 {
577 goto PVRSRV_BRIDGE_SGX_DOKICK_RETURN_RESULT;
578 }
579 }
581 #if defined (SUPPORT_SID_INTERFACE)
582 OSMemCopy(&sCCBKickKM.sCommand, &psDoKickIN->sCCBKick.sCommand, sizeof(sCCBKickKM.sCommand));
584 sCCBKickKM.ui32NumDstSyncObjects = psDoKickIN->sCCBKick.ui32NumDstSyncObjects;
585 sCCBKickKM.ui32NumTAStatusVals = psDoKickIN->sCCBKick.ui32NumTAStatusVals;
586 sCCBKickKM.ui32Num3DStatusVals = psDoKickIN->sCCBKick.ui32Num3DStatusVals;
587 sCCBKickKM.bFirstKickOrResume = psDoKickIN->sCCBKick.bFirstKickOrResume;
588 sCCBKickKM.ui32CCBOffset = psDoKickIN->sCCBKick.ui32CCBOffset;
589 sCCBKickKM.bTADependency = psDoKickIN->sCCBKick.bTADependency;
591 #if defined(NO_HARDWARE) || defined(PDUMP)
592 sCCBKickKM.bTerminateOrAbort = psDoKickIN->sCCBKick.bTerminateOrAbort;
593 #endif
594 #if defined(PDUMP)
595 sCCBKickKM.ui32CCBDumpWOff = psDoKickIN->sCCBKick.ui32CCBDumpWOff;
596 #endif
598 #if defined(NO_HARDWARE)
599 sCCBKickKM.ui32WriteOpsPendingVal = psDoKickIN->sCCBKick.ui32WriteOpsPendingVal;
600 #endif
601 #endif /* #if defined (SUPPORT_SID_INTERFACE) */
602 psRetOUT->eError =
603 SGXDoKickKM(hDevCookieInt,
604 #if defined (SUPPORT_SID_INTERFACE)
605 &sCCBKickKM);
606 #else
607 &psDoKickIN->sCCBKick);
608 #endif
610 PVRSRV_BRIDGE_SGX_DOKICK_RETURN_RESULT:
612 if(phKernelSyncInfoHandles)
613 {
614 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
615 ui32NumDstSyncs * sizeof(IMG_HANDLE),
616 (IMG_VOID *)phKernelSyncInfoHandles,
617 0);
618 /*not nulling pointer, out of scope*/
619 }
620 return ret;
621 }
624 static IMG_INT
625 SGXScheduleProcessQueuesBW(IMG_UINT32 ui32BridgeID,
626 PVRSRV_BRIDGE_IN_SGX_SCHEDULE_PROCESS_QUEUES *psScheduleProcQIN,
627 PVRSRV_BRIDGE_RETURN *psRetOUT,
628 PVRSRV_PER_PROCESS_DATA *psPerProc)
629 {
630 IMG_HANDLE hDevCookieInt;
632 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SCHEDULE_PROCESS_QUEUES);
634 psRetOUT->eError =
635 PVRSRVLookupHandle(psPerProc->psHandleBase,
636 &hDevCookieInt,
637 psScheduleProcQIN->hDevCookie,
638 PVRSRV_HANDLE_TYPE_DEV_NODE);
640 if(psRetOUT->eError != PVRSRV_OK)
641 {
642 return 0;
643 }
645 psRetOUT->eError = SGXScheduleProcessQueuesKM(hDevCookieInt);
647 return 0;
648 }
651 #if defined(TRANSFER_QUEUE)
652 static IMG_INT
653 SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID,
654 PVRSRV_BRIDGE_IN_SUBMITTRANSFER *psSubmitTransferIN,
655 PVRSRV_BRIDGE_RETURN *psRetOUT,
656 PVRSRV_PER_PROCESS_DATA *psPerProc)
657 {
658 IMG_HANDLE hDevCookieInt;
659 PVRSRV_TRANSFER_SGX_KICK *psKick;
660 #if defined (SUPPORT_SID_INTERFACE)
661 PVRSRV_TRANSFER_SGX_KICK_KM sKickKM = {0};
662 #endif
663 IMG_UINT32 i;
665 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SUBMITTRANSFER);
666 PVR_UNREFERENCED_PARAMETER(ui32BridgeID);
668 psKick = &psSubmitTransferIN->sKick;
670 #if defined(FIX_HW_BRN_31620)
671 /* We need to lookup the mem context and pass it through */
672 psRetOUT->eError =
673 PVRSRVLookupHandle(psPerProc->psHandleBase,
674 &psKick->hDevMemContext,
675 psKick->hDevMemContext,
676 PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
678 if(psRetOUT->eError != PVRSRV_OK)
679 {
680 return 0;
681 }
682 #endif
684 psRetOUT->eError =
685 PVRSRVLookupHandle(psPerProc->psHandleBase,
686 &hDevCookieInt,
687 psSubmitTransferIN->hDevCookie,
688 PVRSRV_HANDLE_TYPE_DEV_NODE);
689 if(psRetOUT->eError != PVRSRV_OK)
690 {
691 return 0;
692 }
694 psRetOUT->eError =
695 PVRSRVLookupHandle(psPerProc->psHandleBase,
696 #if defined (SUPPORT_SID_INTERFACE)
697 &sKickKM.hCCBMemInfo,
698 #else
699 &psKick->hCCBMemInfo,
700 #endif
701 psKick->hCCBMemInfo,
702 PVRSRV_HANDLE_TYPE_MEM_INFO);
703 if(psRetOUT->eError != PVRSRV_OK)
704 {
705 return 0;
706 }
708 if (psKick->hTASyncInfo != IMG_NULL)
709 {
710 psRetOUT->eError =
711 PVRSRVLookupHandle(psPerProc->psHandleBase,
712 #if defined (SUPPORT_SID_INTERFACE)
713 &sKickKM.hTASyncInfo,
714 #else
715 &psKick->hTASyncInfo,
716 #endif
717 psKick->hTASyncInfo,
718 PVRSRV_HANDLE_TYPE_SYNC_INFO);
719 if(psRetOUT->eError != PVRSRV_OK)
720 {
721 return 0;
722 }
723 }
725 if (psKick->h3DSyncInfo != IMG_NULL)
726 {
727 psRetOUT->eError =
728 PVRSRVLookupHandle(psPerProc->psHandleBase,
729 #if defined (SUPPORT_SID_INTERFACE)
730 &sKickKM.h3DSyncInfo,
731 #else
732 &psKick->h3DSyncInfo,
733 #endif
734 psKick->h3DSyncInfo,
735 PVRSRV_HANDLE_TYPE_SYNC_INFO);
736 if(psRetOUT->eError != PVRSRV_OK)
737 {
738 return 0;
739 }
740 }
742 if (psKick->ui32NumSrcSync > SGX_MAX_TRANSFER_SYNC_OPS)
743 {
744 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
745 return 0;
746 }
747 for (i = 0; i < psKick->ui32NumSrcSync; i++)
748 {
749 psRetOUT->eError =
750 PVRSRVLookupHandle(psPerProc->psHandleBase,
751 #if defined (SUPPORT_SID_INTERFACE)
752 &sKickKM.ahSrcSyncInfo[i],
753 #else
754 &psKick->ahSrcSyncInfo[i],
755 #endif
756 psKick->ahSrcSyncInfo[i],
757 PVRSRV_HANDLE_TYPE_SYNC_INFO);
758 if(psRetOUT->eError != PVRSRV_OK)
759 {
760 return 0;
761 }
762 }
764 if (psKick->ui32NumDstSync > SGX_MAX_TRANSFER_SYNC_OPS)
765 {
766 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
767 return 0;
768 }
769 for (i = 0; i < psKick->ui32NumDstSync; i++)
770 {
771 psRetOUT->eError =
772 PVRSRVLookupHandle(psPerProc->psHandleBase,
773 #if defined (SUPPORT_SID_INTERFACE)
774 &sKickKM.ahDstSyncInfo[i],
775 #else
776 &psKick->ahDstSyncInfo[i],
777 #endif
778 psKick->ahDstSyncInfo[i],
779 PVRSRV_HANDLE_TYPE_SYNC_INFO);
780 if(psRetOUT->eError != PVRSRV_OK)
781 {
782 return 0;
783 }
784 }
786 #if defined (SUPPORT_SID_INTERFACE)
787 sKickKM.sHWTransferContextDevVAddr = psKick->sHWTransferContextDevVAddr;
788 sKickKM.ui32SharedCmdCCBOffset = psKick->ui32SharedCmdCCBOffset;
789 sKickKM.ui32NumSrcSync = psKick->ui32NumSrcSync;
790 sKickKM.ui32NumDstSync = psKick->ui32NumDstSync;
791 sKickKM.ui32Flags = psKick->ui32Flags;
792 sKickKM.ui32PDumpFlags = psKick->ui32PDumpFlags;
793 #if defined(PDUMP)
794 sKickKM.ui32CCBDumpWOff = psKick->ui32CCBDumpWOff;
795 #endif
797 psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, &sKickKM);
798 #else
799 psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, psKick);
800 #endif
802 return 0;
803 }
805 static IMG_INT
806 SGXSetTransferContextPriorityBW(IMG_UINT32 ui32BridgeID,
807 PVRSRV_BRIDGE_IN_SGX_SET_TRANSFER_CONTEXT_PRIORITY *psSGXSetTransferContextPriorityIN,
808 PVRSRV_BRIDGE_RETURN *psRetOUT,
809 PVRSRV_PER_PROCESS_DATA *psPerProc)
810 {
811 IMG_HANDLE hDevCookieInt;
812 IMG_HANDLE hTransferContextInt;
814 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SET_TRANSFER_CONTEXT_PRIORITY);
816 psRetOUT->eError =
817 PVRSRVLookupHandle(psPerProc->psHandleBase,
818 &hDevCookieInt,
819 psSGXSetTransferContextPriorityIN->hDevCookie,
820 PVRSRV_HANDLE_TYPE_DEV_NODE);
822 if(psRetOUT->eError != PVRSRV_OK)
823 {
824 return 0;
825 }
827 psRetOUT->eError =
828 PVRSRVLookupHandle(psPerProc->psHandleBase,
829 &hTransferContextInt,
830 psSGXSetTransferContextPriorityIN->hHWTransferContext,
831 PVRSRV_HANDLE_TYPE_SGX_HW_TRANSFER_CONTEXT);
833 if(psRetOUT->eError != PVRSRV_OK)
834 {
835 return 0;
836 }
838 psRetOUT->eError = SGXSetTransferContextPriorityKM(
839 hDevCookieInt,
840 hTransferContextInt,
841 psSGXSetTransferContextPriorityIN->ui32Priority,
842 psSGXSetTransferContextPriorityIN->ui32OffsetOfPriorityField);
844 return 0;
845 }
847 static IMG_INT
848 SGXSetRenderContextPriorityBW(IMG_UINT32 ui32BridgeID,
849 PVRSRV_BRIDGE_IN_SGX_SET_RENDER_CONTEXT_PRIORITY *psSGXSetRenderContextPriorityIN,
850 PVRSRV_BRIDGE_RETURN *psRetOUT,
851 PVRSRV_PER_PROCESS_DATA *psPerProc)
852 {
853 IMG_HANDLE hDevCookieInt;
854 IMG_HANDLE hRenderContextInt;
856 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SET_RENDER_CONTEXT_PRIORITY);
858 psRetOUT->eError =
859 PVRSRVLookupHandle(psPerProc->psHandleBase,
860 &hDevCookieInt,
861 psSGXSetRenderContextPriorityIN->hDevCookie,
862 PVRSRV_HANDLE_TYPE_DEV_NODE);
864 if(psRetOUT->eError != PVRSRV_OK)
865 {
866 return 0;
867 }
869 psRetOUT->eError =
870 PVRSRVLookupHandle(psPerProc->psHandleBase,
871 &hRenderContextInt,
872 psSGXSetRenderContextPriorityIN->hHWRenderContext,
873 PVRSRV_HANDLE_TYPE_SGX_HW_RENDER_CONTEXT);
875 if(psRetOUT->eError != PVRSRV_OK)
876 {
877 return 0;
878 }
880 psRetOUT->eError = SGXSetRenderContextPriorityKM(
881 hDevCookieInt,
882 hRenderContextInt,
883 psSGXSetRenderContextPriorityIN->ui32Priority,
884 psSGXSetRenderContextPriorityIN->ui32OffsetOfPriorityField);
886 return 0;
887 }
890 #if defined(SGX_FEATURE_2D_HARDWARE)
891 static IMG_INT
892 SGXSubmit2DBW(IMG_UINT32 ui32BridgeID,
893 PVRSRV_BRIDGE_IN_SUBMIT2D *psSubmit2DIN,
894 PVRSRV_BRIDGE_RETURN *psRetOUT,
895 PVRSRV_PER_PROCESS_DATA *psPerProc)
896 {
897 IMG_HANDLE hDevCookieInt;
898 PVRSRV_2D_SGX_KICK *psKick;
899 #if defined (SUPPORT_SID_INTERFACE)
900 PVRSRV_2D_SGX_KICK_KM sKickKM;
901 #endif
902 IMG_UINT32 i;
904 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SUBMIT2D);
905 PVR_UNREFERENCED_PARAMETER(ui32BridgeID);
907 psKick = &psSubmit2DIN->sKick;
909 #if defined(FIX_HW_BRN_31620)
910 /* We need to lookup the mem context and pass it through */
911 psRetOUT->eError =
912 PVRSRVLookupHandle(psPerProc->psHandleBase,
913 &psKick->hDevMemContext,
914 psKick->hDevMemContext,
915 PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
917 if(psRetOUT->eError != PVRSRV_OK)
918 {
919 return 0;
920 }
921 #endif
924 psRetOUT->eError =
925 PVRSRVLookupHandle(psPerProc->psHandleBase,
926 &hDevCookieInt,
927 psSubmit2DIN->hDevCookie,
928 PVRSRV_HANDLE_TYPE_DEV_NODE);
930 if(psRetOUT->eError != PVRSRV_OK)
931 {
932 return 0;
933 }
936 psRetOUT->eError =
937 PVRSRVLookupHandle(psPerProc->psHandleBase,
938 #if defined (SUPPORT_SID_INTERFACE)
939 &sKickKM.hCCBMemInfo,
940 #else
941 &psKick->hCCBMemInfo,
942 #endif
943 psKick->hCCBMemInfo,
944 PVRSRV_HANDLE_TYPE_MEM_INFO);
945 if(psRetOUT->eError != PVRSRV_OK)
946 {
947 return 0;
948 }
950 #if defined (SUPPORT_SID_INTERFACE)
951 if (psKick->hTASyncInfo != 0)
952 #else
953 if (psKick->hTASyncInfo != IMG_NULL)
954 #endif
955 {
956 psRetOUT->eError =
957 PVRSRVLookupHandle(psPerProc->psHandleBase,
958 #if defined (SUPPORT_SID_INTERFACE)
959 &sKickKM.hTASyncInfo,
960 #else
961 &psKick->hTASyncInfo,
962 #endif
963 psKick->hTASyncInfo,
964 PVRSRV_HANDLE_TYPE_SYNC_INFO);
965 if(psRetOUT->eError != PVRSRV_OK)
966 {
967 return 0;
968 }
969 }
970 #if defined (SUPPORT_SID_INTERFACE)
971 else
972 {
973 sKickKM.hTASyncInfo = IMG_NULL;
974 }
975 #endif
977 if (psKick->h3DSyncInfo != IMG_NULL)
978 {
979 psRetOUT->eError =
980 PVRSRVLookupHandle(psPerProc->psHandleBase,
981 #if defined (SUPPORT_SID_INTERFACE)
982 &sKickKM.h3DSyncInfo,
983 #else
984 &psKick->h3DSyncInfo,
985 #endif
986 psKick->h3DSyncInfo,
987 PVRSRV_HANDLE_TYPE_SYNC_INFO);
988 if(psRetOUT->eError != PVRSRV_OK)
989 {
990 return 0;
991 }
992 }
993 #if defined (SUPPORT_SID_INTERFACE)
994 else
995 {
996 sKickKM.h3DSyncInfo = IMG_NULL;
997 }
998 #endif
1000 if (psKick->ui32NumSrcSync > SGX_MAX_2D_SRC_SYNC_OPS)
1001 {
1002 psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1003 return 0;
1004 }
1005 #if defined (SUPPORT_SID_INTERFACE)
1006 for (i = 0; i < SGX_MAX_2D_SRC_SYNC_OPS; i++)
1007 {
1008 if (i < psKick->ui32NumSrcSync)
1009 {
1010 psRetOUT->eError =
1011 PVRSRVLookupHandle(psPerProc->psHandleBase,
1012 &sKickKM.ahSrcSyncInfo[i],
1013 psKick->ahSrcSyncInfo[i],
1014 PVRSRV_HANDLE_TYPE_SYNC_INFO);
1015 if(psRetOUT->eError != PVRSRV_OK)
1016 {
1017 return 0;
1018 }
1019 }
1020 else
1021 {
1022 sKickKM.ahSrcSyncInfo[i] = IMG_NULL;
1023 }
1024 }
1025 #else
1026 for (i = 0; i < psKick->ui32NumSrcSync; i++)
1027 {
1028 psRetOUT->eError =
1029 PVRSRVLookupHandle(psPerProc->psHandleBase,
1030 &psKick->ahSrcSyncInfo[i],
1031 psKick->ahSrcSyncInfo[i],
1032 PVRSRV_HANDLE_TYPE_SYNC_INFO);
1033 if(psRetOUT->eError != PVRSRV_OK)
1034 {
1035 return 0;
1036 }
1037 }
1038 #endif
1040 if (psKick->hDstSyncInfo != IMG_NULL)
1041 {
1042 psRetOUT->eError =
1043 PVRSRVLookupHandle(psPerProc->psHandleBase,
1044 #if defined (SUPPORT_SID_INTERFACE)
1045 &sKickKM.hDstSyncInfo,
1046 #else
1047 &psKick->hDstSyncInfo,
1048 #endif
1049 psKick->hDstSyncInfo,
1050 PVRSRV_HANDLE_TYPE_SYNC_INFO);
1051 if(psRetOUT->eError != PVRSRV_OK)
1052 {
1053 return 0;
1054 }
1055 }
1056 #if defined (SUPPORT_SID_INTERFACE)
1057 else
1058 {
1059 sKickKM.hDstSyncInfo = IMG_NULL;
1060 }
1062 /* copy common members across */
1063 sKickKM.ui32SharedCmdCCBOffset = psKick->ui32SharedCmdCCBOffset;
1064 sKickKM.ui32NumSrcSync = psKick->ui32NumSrcSync;
1065 sKickKM.ui32PDumpFlags = psKick->ui32PDumpFlags;
1066 sKickKM.sHW2DContextDevVAddr = psKick->sHW2DContextDevVAddr;
1067 #if defined(PDUMP)
1068 sKickKM.ui32CCBDumpWOff = psKick->ui32CCBDumpWOff;
1069 #endif
1070 #endif
1072 psRetOUT->eError =
1073 #if defined (SUPPORT_SID_INTERFACE)
1074 SGXSubmit2DKM(hDevCookieInt, &sKickKM);
1075 #else
1076 SGXSubmit2DKM(hDevCookieInt, psKick);
1077 #endif
1079 return 0;
1080 }
1081 #endif /* #if defined(SGX_FEATURE_2D_HARDWARE) */
1082 #endif /* #if defined(TRANSFER_QUEUE) */
1085 static IMG_INT
1086 SGXGetMiscInfoBW(IMG_UINT32 ui32BridgeID,
1087 PVRSRV_BRIDGE_IN_SGXGETMISCINFO *psSGXGetMiscInfoIN,
1088 PVRSRV_BRIDGE_RETURN *psRetOUT,
1089 PVRSRV_PER_PROCESS_DATA *psPerProc)
1090 {
1091 IMG_HANDLE hDevCookieInt;
1092 IMG_HANDLE hDevMemContextInt = 0;
1093 PVRSRV_SGXDEV_INFO *psDevInfo;
1094 SGX_MISC_INFO sMiscInfo;
1095 PVRSRV_DEVICE_NODE *psDeviceNode;
1097 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID,
1098 PVRSRV_BRIDGE_SGX_GETMISCINFO);
1100 psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1101 &hDevCookieInt,
1102 psSGXGetMiscInfoIN->hDevCookie,
1103 PVRSRV_HANDLE_TYPE_DEV_NODE);
1105 if(psRetOUT->eError != PVRSRV_OK)
1106 {
1107 return 0;
1108 }
1110 #if defined(SUPPORT_SGX_EDM_MEMORY_DEBUG)
1111 /* Lookup handle for dev mem context */
1112 if (psSGXGetMiscInfoIN->psMiscInfo->eRequest == SGX_MISC_INFO_REQUEST_MEMREAD)
1113 {
1114 psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1115 &hDevMemContextInt,
1116 psSGXGetMiscInfoIN->psMiscInfo->hDevMemContext,
1117 PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
1119 if(psRetOUT->eError != PVRSRV_OK)
1120 {
1121 return 0;
1122 }
1123 }
1124 #endif
1125 /* device node is required for scheduling a CCB command */
1126 psDeviceNode = hDevCookieInt;
1127 PVR_ASSERT(psDeviceNode != IMG_NULL);
1128 if (psDeviceNode == IMG_NULL)
1129 {
1130 return -EFAULT;
1131 }
1133 psDevInfo = psDeviceNode->pvDevice;
1135 /* Copy psMiscInfo to kernel space */
1136 psRetOUT->eError = CopyFromUserWrapper(psPerProc,
1137 ui32BridgeID,
1138 &sMiscInfo,
1139 psSGXGetMiscInfoIN->psMiscInfo,
1140 sizeof(SGX_MISC_INFO));
1141 if (psRetOUT->eError != PVRSRV_OK)
1142 {
1143 return -EFAULT;
1144 }
1146 {
1147 psRetOUT->eError = SGXGetMiscInfoKM(psDevInfo, &sMiscInfo, psDeviceNode, hDevMemContextInt);
1149 if (psRetOUT->eError != PVRSRV_OK)
1150 {
1151 return 0;
1152 }
1153 }
1155 /* Copy back misc info to user address space */
1156 psRetOUT->eError = CopyToUserWrapper(psPerProc,
1157 ui32BridgeID,
1158 psSGXGetMiscInfoIN->psMiscInfo,
1159 &sMiscInfo,
1160 sizeof(SGX_MISC_INFO));
1161 if (psRetOUT->eError != PVRSRV_OK)
1162 {
1163 return -EFAULT;
1164 }
1165 return 0;
1166 }
1169 static IMG_INT
1170 SGXReadHWPerfCBBW(IMG_UINT32 ui32BridgeID,
1171 PVRSRV_BRIDGE_IN_SGX_READ_HWPERF_CB *psSGXReadHWPerfCBIN,
1172 PVRSRV_BRIDGE_OUT_SGX_READ_HWPERF_CB *psSGXReadHWPerfCBOUT,
1173 PVRSRV_PER_PROCESS_DATA *psPerProc)
1174 {
1175 IMG_HANDLE hDevCookieInt;
1176 PVRSRV_SGX_HWPERF_CB_ENTRY *psAllocated;
1177 IMG_HANDLE hAllocatedHandle;
1178 IMG_UINT32 ui32AllocatedSize;
1180 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_READ_HWPERF_CB);
1182 psSGXReadHWPerfCBOUT->eError =PVRSRVLookupHandle(psPerProc->psHandleBase,
1183 &hDevCookieInt,
1184 psSGXReadHWPerfCBIN->hDevCookie,
1185 PVRSRV_HANDLE_TYPE_DEV_NODE);
1187 if(psSGXReadHWPerfCBOUT->eError != PVRSRV_OK)
1188 {
1189 return 0;
1190 }
1192 ui32AllocatedSize = psSGXReadHWPerfCBIN->ui32ArraySize *
1193 sizeof(psSGXReadHWPerfCBIN->psHWPerfCBData[0]);
1194 ASSIGN_AND_EXIT_ON_ERROR(psSGXReadHWPerfCBOUT->eError,
1195 OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
1196 ui32AllocatedSize,
1197 (IMG_VOID **)&psAllocated,
1198 &hAllocatedHandle,
1199 "Array of Hardware Performance Circular Buffer Data"));
1201 psSGXReadHWPerfCBOUT->eError = SGXReadHWPerfCBKM(hDevCookieInt,
1202 psSGXReadHWPerfCBIN->ui32ArraySize,
1203 psAllocated,
1204 &psSGXReadHWPerfCBOUT->ui32DataCount,
1205 &psSGXReadHWPerfCBOUT->ui32ClockSpeed,
1206 &psSGXReadHWPerfCBOUT->ui32HostTimeStamp);
1207 if (psSGXReadHWPerfCBOUT->eError == PVRSRV_OK)
1208 {
1209 psSGXReadHWPerfCBOUT->eError = CopyToUserWrapper(psPerProc,
1210 ui32BridgeID,
1211 psSGXReadHWPerfCBIN->psHWPerfCBData,
1212 psAllocated,
1213 ui32AllocatedSize);
1214 }
1216 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
1217 ui32AllocatedSize,
1218 psAllocated,
1219 hAllocatedHandle);
1220 /*not nulling pointer, out of scope*/
1222 return 0;
1223 }
1226 static IMG_INT
1227 SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID,
1228 PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *psSGXDevInitPart2IN,
1229 PVRSRV_BRIDGE_OUT_SGXDEVINITPART2 *psSGXDevInitPart2OUT,
1230 PVRSRV_PER_PROCESS_DATA *psPerProc)
1231 {
1232 IMG_HANDLE hDevCookieInt;
1233 #if defined (SUPPORT_SID_INTERFACE)
1234 PVRSRV_ERROR eError = PVRSRV_OK;
1235 #else
1236 PVRSRV_ERROR eError;
1237 #endif
1238 IMG_BOOL bDissociateFailed = IMG_FALSE;
1239 IMG_BOOL bLookupFailed = IMG_FALSE;
1240 IMG_BOOL bReleaseFailed = IMG_FALSE;
1241 IMG_HANDLE hDummy;
1242 IMG_UINT32 i;
1243 #if defined (SUPPORT_SID_INTERFACE)
1244 SGX_BRIDGE_INIT_INFO_KM asInitInfoKM = {0};
1245 #endif
1247 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DEVINITPART2);
1249 /* Report the kernel-side build options to UM */
1250 psSGXDevInitPart2OUT->ui32KMBuildOptions = SGX_BUILD_OPTIONS;
1252 if(!psPerProc->bInitProcess)
1253 {
1254 psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_PROCESS_NOT_INITIALISED;
1255 return 0;
1256 }
1258 psSGXDevInitPart2OUT->eError =
1259 PVRSRVLookupHandle(psPerProc->psHandleBase,
1260 &hDevCookieInt,
1261 psSGXDevInitPart2IN->hDevCookie,
1262 PVRSRV_HANDLE_TYPE_DEV_NODE);
1263 if(psSGXDevInitPart2OUT->eError != PVRSRV_OK)
1264 {
1265 return 0;
1266 }
1268 /* Check all the meminfo handles */
1269 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1270 &hDummy,
1271 psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo,
1272 PVRSRV_HANDLE_TYPE_MEM_INFO);
1273 if (eError != PVRSRV_OK)
1274 {
1275 bLookupFailed = IMG_TRUE;
1276 }
1278 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1279 &hDummy,
1280 psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo,
1281 PVRSRV_HANDLE_TYPE_MEM_INFO);
1282 if (eError != PVRSRV_OK)
1283 {
1284 bLookupFailed = IMG_TRUE;
1285 }
1287 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1288 &hDummy,
1289 psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo,
1290 PVRSRV_HANDLE_TYPE_MEM_INFO);
1291 if (eError != PVRSRV_OK)
1292 {
1293 bLookupFailed = IMG_TRUE;
1294 }
1296 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1297 &hDummy,
1298 psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo,
1299 PVRSRV_HANDLE_TYPE_MEM_INFO);
1300 if (eError != PVRSRV_OK)
1301 {
1302 bLookupFailed = IMG_TRUE;
1303 }
1305 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1306 &hDummy,
1307 psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo,
1308 PVRSRV_HANDLE_TYPE_MEM_INFO);
1309 if (eError != PVRSRV_OK)
1310 {
1311 bLookupFailed = IMG_TRUE;
1312 }
1314 #if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920)
1315 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1316 &hDummy,
1317 psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo,
1318 PVRSRV_HANDLE_TYPE_MEM_INFO);
1319 if (eError != PVRSRV_OK)
1320 {
1321 bLookupFailed = IMG_TRUE;
1322 }
1323 #endif
1325 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1326 &hDummy,
1327 psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo,
1328 PVRSRV_HANDLE_TYPE_MEM_INFO);
1329 if (eError != PVRSRV_OK)
1330 {
1331 bLookupFailed = IMG_TRUE;
1332 }
1334 #if defined(SGX_SUPPORT_HWPROFILING)
1335 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1336 &hDummy,
1337 psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo,
1338 PVRSRV_HANDLE_TYPE_MEM_INFO);
1339 if (eError != PVRSRV_OK)
1340 {
1341 bLookupFailed = IMG_TRUE;
1342 }
1343 #endif
1345 #if defined(SUPPORT_SGX_HWPERF)
1346 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1347 &hDummy,
1348 psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo,
1349 PVRSRV_HANDLE_TYPE_MEM_INFO);
1350 if (eError != PVRSRV_OK)
1351 {
1352 PVR_DPF((PVR_DBG_ERROR, "SGXDevInitPart2BW: Failed to look up HWPerf meminfo (possibly due to SUPPORT_SGX_HWPERF option mismatch)"));
1353 bLookupFailed = IMG_TRUE;
1354 }
1355 #endif
1357 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1358 &hDummy,
1359 psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo,
1360 PVRSRV_HANDLE_TYPE_MEM_INFO);
1361 if (eError != PVRSRV_OK)
1362 {
1363 bLookupFailed = IMG_TRUE;
1364 }
1366 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1367 &hDummy,
1368 psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo,
1369 PVRSRV_HANDLE_TYPE_MEM_INFO);
1370 if (eError != PVRSRV_OK)
1371 {
1372 bLookupFailed = IMG_TRUE;
1373 }
1375 #if defined(FIX_HW_BRN_29702)
1376 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1377 &hDummy,
1378 psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo,
1379 PVRSRV_HANDLE_TYPE_MEM_INFO);
1380 if (eError != PVRSRV_OK)
1381 {
1382 bLookupFailed = IMG_TRUE;
1383 }
1384 #endif
1386 #if defined(FIX_HW_BRN_29823)
1387 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1388 &hDummy,
1389 psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo,
1390 PVRSRV_HANDLE_TYPE_MEM_INFO);
1391 if (eError != PVRSRV_OK)
1392 {
1393 bLookupFailed = IMG_TRUE;
1394 }
1395 #endif
1398 #if defined(FIX_HW_BRN_31542) || defined(FIX_HW_BRN_36513)
1399 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1400 &hDummy,
1401 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo,
1402 PVRSRV_HANDLE_TYPE_MEM_INFO);
1403 if (eError != PVRSRV_OK)
1404 {
1405 bLookupFailed = IMG_TRUE;
1406 }
1407 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1408 &hDummy,
1409 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo,
1410 PVRSRV_HANDLE_TYPE_MEM_INFO);
1411 if (eError != PVRSRV_OK)
1412 {
1413 bLookupFailed = IMG_TRUE;
1414 }
1415 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1416 &hDummy,
1417 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo,
1418 PVRSRV_HANDLE_TYPE_MEM_INFO);
1419 if (eError != PVRSRV_OK)
1420 {
1421 bLookupFailed = IMG_TRUE;
1422 }
1423 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1424 &hDummy,
1425 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo,
1426 PVRSRV_HANDLE_TYPE_MEM_INFO);
1427 if (eError != PVRSRV_OK)
1428 {
1429 bLookupFailed = IMG_TRUE;
1430 }
1431 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1432 &hDummy,
1433 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo,
1434 PVRSRV_HANDLE_TYPE_MEM_INFO);
1435 if (eError != PVRSRV_OK)
1436 {
1437 bLookupFailed = IMG_TRUE;
1438 }
1439 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1440 &hDummy,
1441 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo,
1442 PVRSRV_HANDLE_TYPE_MEM_INFO);
1443 if (eError != PVRSRV_OK)
1444 {
1445 bLookupFailed = IMG_TRUE;
1446 }
1448 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1449 &hDummy,
1450 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo,
1451 PVRSRV_HANDLE_TYPE_MEM_INFO);
1452 if (eError != PVRSRV_OK)
1453 {
1454 bLookupFailed = IMG_TRUE;
1455 }
1456 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1457 &hDummy,
1458 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo,
1459 PVRSRV_HANDLE_TYPE_MEM_INFO);
1460 if (eError != PVRSRV_OK)
1461 {
1462 bLookupFailed = IMG_TRUE;
1463 }
1464 #endif
1466 #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559)
1467 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1468 &hDummy,
1469 psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo,
1470 PVRSRV_HANDLE_TYPE_MEM_INFO);
1471 if (eError != PVRSRV_OK)
1472 {
1473 bLookupFailed = IMG_TRUE;
1474 }
1476 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1477 &hDummy,
1478 psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo,
1479 PVRSRV_HANDLE_TYPE_MEM_INFO);
1480 if (eError != PVRSRV_OK)
1481 {
1482 bLookupFailed = IMG_TRUE;
1483 }
1484 #endif
1485 #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \
1486 defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX)
1487 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1488 &hDummy,
1489 psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo,
1490 PVRSRV_HANDLE_TYPE_MEM_INFO);
1491 if (eError != PVRSRV_OK)
1492 {
1493 bLookupFailed = IMG_TRUE;
1494 }
1495 #endif
1497 #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG)
1498 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1499 &hDummy,
1500 psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo,
1501 PVRSRV_HANDLE_TYPE_MEM_INFO);
1502 if (eError != PVRSRV_OK)
1503 {
1504 bLookupFailed = IMG_TRUE;
1505 }
1506 #endif
1508 for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++)
1509 {
1510 #if defined (SUPPORT_SID_INTERFACE)
1511 IMG_SID hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i];
1512 #else
1513 IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i];
1514 #endif
1516 #if defined (SUPPORT_SID_INTERFACE)
1517 if (hHandle == 0)
1518 #else
1519 if (hHandle == IMG_NULL)
1520 #endif
1521 {
1522 continue;
1523 }
1525 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1526 &hDummy,
1527 hHandle,
1528 PVRSRV_HANDLE_TYPE_MEM_INFO);
1529 if (eError != PVRSRV_OK)
1530 {
1531 bLookupFailed = IMG_TRUE;
1532 }
1533 }
1535 if (bLookupFailed)
1536 {
1537 PVR_DPF((PVR_DBG_ERROR, "SGXDevInitPart2BW: A handle lookup failed"));
1538 psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED;
1539 return 0;
1540 }
1542 /* Lookup and release the device memory handles */
1543 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1544 #if defined (SUPPORT_SID_INTERFACE)
1545 &asInitInfoKM.hKernelCCBMemInfo,
1546 #else
1547 &psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo,
1548 #endif
1549 psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo,
1550 PVRSRV_HANDLE_TYPE_MEM_INFO);
1551 if (eError != PVRSRV_OK)
1552 {
1553 bReleaseFailed = IMG_TRUE;
1554 }
1556 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1557 #if defined (SUPPORT_SID_INTERFACE)
1558 &asInitInfoKM.hKernelCCBCtlMemInfo,
1559 #else
1560 &psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo,
1561 #endif
1562 psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo,
1563 PVRSRV_HANDLE_TYPE_MEM_INFO);
1564 if (eError != PVRSRV_OK)
1565 {
1566 bReleaseFailed = IMG_TRUE;
1567 }
1569 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1570 #if defined (SUPPORT_SID_INTERFACE)
1571 &asInitInfoKM.hKernelCCBEventKickerMemInfo,
1572 #else
1573 &psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo,
1574 #endif
1575 psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo,
1576 PVRSRV_HANDLE_TYPE_MEM_INFO);
1577 if (eError != PVRSRV_OK)
1578 {
1579 bReleaseFailed = IMG_TRUE;
1580 }
1583 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1584 #if defined (SUPPORT_SID_INTERFACE)
1585 &asInitInfoKM.hKernelSGXHostCtlMemInfo,
1586 #else
1587 &psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo,
1588 #endif
1589 psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo,
1590 PVRSRV_HANDLE_TYPE_MEM_INFO);
1591 if (eError != PVRSRV_OK)
1592 {
1593 bReleaseFailed = IMG_TRUE;
1594 }
1596 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1597 #if defined (SUPPORT_SID_INTERFACE)
1598 &asInitInfoKM.hKernelSGXTA3DCtlMemInfo,
1599 #else
1600 &psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo,
1601 #endif
1602 psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo,
1603 PVRSRV_HANDLE_TYPE_MEM_INFO);
1604 if (eError != PVRSRV_OK)
1605 {
1606 bReleaseFailed = IMG_TRUE;
1607 }
1609 #if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920)
1610 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1611 #if defined (SUPPORT_SID_INTERFACE)
1612 &asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo,
1613 #else
1614 &psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo,
1615 #endif
1616 psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo,
1617 PVRSRV_HANDLE_TYPE_MEM_INFO);
1618 if (eError != PVRSRV_OK)
1619 {
1620 bReleaseFailed = IMG_TRUE;
1621 }
1622 #endif
1624 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1625 #if defined (SUPPORT_SID_INTERFACE)
1626 &asInitInfoKM.hKernelSGXMiscMemInfo,
1627 #else
1628 &psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo,
1629 #endif
1630 psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo,
1631 PVRSRV_HANDLE_TYPE_MEM_INFO);
1632 if (eError != PVRSRV_OK)
1633 {
1634 bReleaseFailed = IMG_TRUE;
1635 }
1638 #if defined(SGX_SUPPORT_HWPROFILING)
1639 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1640 #if defined (SUPPORT_SID_INTERFACE)
1641 &asInitInfoKM.hKernelHWProfilingMemInfo,
1642 #else
1643 &psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo,
1644 #endif
1645 psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo,
1646 PVRSRV_HANDLE_TYPE_MEM_INFO);
1647 if (eError != PVRSRV_OK)
1648 {
1649 bReleaseFailed = IMG_TRUE;
1650 }
1651 #endif
1653 #if defined(SUPPORT_SGX_HWPERF)
1654 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1655 #if defined (SUPPORT_SID_INTERFACE)
1656 &asInitInfoKM.hKernelHWPerfCBMemInfo,
1657 #else
1658 &psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo,
1659 #endif
1660 psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo,
1661 PVRSRV_HANDLE_TYPE_MEM_INFO);
1662 if (eError != PVRSRV_OK)
1663 {
1664 bReleaseFailed = IMG_TRUE;
1665 }
1666 #endif
1668 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1669 #if defined (SUPPORT_SID_INTERFACE)
1670 &asInitInfoKM.hKernelTASigBufferMemInfo,
1671 #else
1672 &psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo,
1673 #endif
1674 psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo,
1675 PVRSRV_HANDLE_TYPE_MEM_INFO);
1676 if (eError != PVRSRV_OK)
1677 {
1678 bReleaseFailed = IMG_TRUE;
1679 }
1681 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1682 #if defined (SUPPORT_SID_INTERFACE)
1683 &asInitInfoKM.hKernel3DSigBufferMemInfo,
1684 #else
1685 &psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo,
1686 #endif
1687 psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo,
1688 PVRSRV_HANDLE_TYPE_MEM_INFO);
1689 if (eError != PVRSRV_OK)
1690 {
1691 bReleaseFailed = IMG_TRUE;
1692 }
1694 #if defined(FIX_HW_BRN_29702)
1695 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
1696 #if defined (SUPPORT_SID_INTERFACE)
1697 &asInitInfoKM.hKernelCFIMemInfo,
1698 #else
1699 &psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo,
1700 #endif
1701 psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo,
1702 PVRSRV_HANDLE_TYPE_MEM_INFO);
1703 if (eError != PVRSRV_OK)
1704 {
1705 bLookupFailed = IMG_TRUE;
1706 }
1707 #endif
1709 #if defined(FIX_HW_BRN_29823)
1710 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1711 #if defined (SUPPORT_SID_INTERFACE)
1712 &asInitInfoKM.hKernelDummyTermStreamMemInfo,
1713 #else
1714 &psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo,
1715 #endif
1716 psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo,
1717 PVRSRV_HANDLE_TYPE_MEM_INFO);
1718 if (eError != PVRSRV_OK)
1719 {
1720 bReleaseFailed = IMG_TRUE;
1721 }
1722 #endif
1725 #if defined(FIX_HW_BRN_31542) || defined(FIX_HW_BRN_36513)
1726 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1727 #if defined (SUPPORT_SID_INTERFACE)
1728 &asInitInfoKM.hKernelClearClipWAVDMStreamMemInfo,
1729 #else
1730 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo,
1731 #endif
1732 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo,
1733 PVRSRV_HANDLE_TYPE_MEM_INFO);
1734 if (eError != PVRSRV_OK)
1735 {
1736 bReleaseFailed = IMG_TRUE;
1737 }
1738 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1739 #if defined (SUPPORT_SID_INTERFACE)
1740 &asInitInfoKM.hKernelClearClipWAIndexStreamMemInfo,
1741 #else
1742 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo,
1743 #endif
1744 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo,
1745 PVRSRV_HANDLE_TYPE_MEM_INFO);
1746 if (eError != PVRSRV_OK)
1747 {
1748 bReleaseFailed = IMG_TRUE;
1749 }
1750 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1751 #if defined (SUPPORT_SID_INTERFACE)
1752 &asInitInfoKM.hKernelClearClipWAPDSMemInfo,
1753 #else
1754 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo,
1755 #endif
1756 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo,
1757 PVRSRV_HANDLE_TYPE_MEM_INFO);
1758 if (eError != PVRSRV_OK)
1759 {
1760 bReleaseFailed = IMG_TRUE;
1761 }
1762 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1763 #if defined (SUPPORT_SID_INTERFACE)
1764 &asInitInfoKM.hKernelClearClipWAUSEMemInfo,
1765 #else
1766 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo,
1767 #endif
1768 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo,
1769 PVRSRV_HANDLE_TYPE_MEM_INFO);
1770 if (eError != PVRSRV_OK)
1771 {
1772 bReleaseFailed = IMG_TRUE;
1773 }
1774 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1775 #if defined (SUPPORT_SID_INTERFACE)
1776 &asInitInfoKM.hKernelClearClipWAParamMemInfo,
1777 #else
1778 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo,
1779 #endif
1780 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo,
1781 PVRSRV_HANDLE_TYPE_MEM_INFO);
1782 if (eError != PVRSRV_OK)
1783 {
1784 bReleaseFailed = IMG_TRUE;
1785 }
1786 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1787 #if defined (SUPPORT_SID_INTERFACE)
1788 &asInitInfoKM.hKernelClearClipWAPMPTMemInfo,
1789 #else
1790 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo,
1791 #endif
1792 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo,
1793 PVRSRV_HANDLE_TYPE_MEM_INFO);
1794 if (eError != PVRSRV_OK)
1795 {
1796 bReleaseFailed = IMG_TRUE;
1797 }
1798 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1799 #if defined (SUPPORT_SID_INTERFACE)
1800 &asInitInfoKM.hKernelClearClipWATPCMemInfo,
1801 #else
1802 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo,
1803 #endif
1804 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo,
1805 PVRSRV_HANDLE_TYPE_MEM_INFO);
1806 if (eError != PVRSRV_OK)
1807 {
1808 bReleaseFailed = IMG_TRUE;
1809 }
1810 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1811 #if defined (SUPPORT_SID_INTERFACE)
1812 &asInitInfoKM.hKernelClearClipWAPSGRgnHdrMemInfo,
1813 #else
1814 &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo,
1815 #endif
1816 psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo,
1817 PVRSRV_HANDLE_TYPE_MEM_INFO);
1818 if (eError != PVRSRV_OK)
1819 {
1820 bReleaseFailed = IMG_TRUE;
1821 }
1822 #endif
1823 #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559)
1824 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1825 &psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo,
1826 psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo,
1827 PVRSRV_HANDLE_TYPE_MEM_INFO);
1828 if (eError != PVRSRV_OK)
1829 {
1830 bReleaseFailed = IMG_TRUE;
1831 }
1833 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1834 &psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo,
1835 psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo,
1836 PVRSRV_HANDLE_TYPE_MEM_INFO);
1837 if (eError != PVRSRV_OK)
1838 {
1839 bReleaseFailed = IMG_TRUE;
1840 }
1841 #endif
1842 #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \
1843 defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX)
1844 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1845 &psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo,
1846 psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo,
1847 PVRSRV_HANDLE_TYPE_MEM_INFO);
1848 if (eError != PVRSRV_OK)
1849 {
1850 bReleaseFailed = IMG_TRUE;
1851 }
1852 #endif
1854 #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG)
1855 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1856 #if defined (SUPPORT_SID_INTERFACE)
1857 &asInitInfoKM.hKernelEDMStatusBufferMemInfo,
1858 #else
1859 &psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo,
1860 #endif
1861 psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo,
1862 PVRSRV_HANDLE_TYPE_MEM_INFO);
1863 if (eError != PVRSRV_OK)
1864 {
1865 bReleaseFailed = IMG_TRUE;
1866 }
1867 #endif
1869 for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++)
1870 {
1871 #if defined (SUPPORT_SID_INTERFACE)
1872 IMG_SID hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i];
1873 IMG_HANDLE *phHandleKM = &asInitInfoKM.asInitMemHandles[i];
1875 if (hHandle == 0)
1876 #else
1877 IMG_HANDLE *phHandle = &psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i];
1879 if (*phHandle == IMG_NULL)
1880 #endif
1881 continue;
1883 eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase,
1884 #if defined (SUPPORT_SID_INTERFACE)
1885 phHandleKM,
1886 hHandle,
1887 #else
1888 phHandle,
1889 *phHandle,
1890 #endif
1891 PVRSRV_HANDLE_TYPE_MEM_INFO);
1892 if (eError != PVRSRV_OK)
1893 {
1894 bReleaseFailed = IMG_TRUE;
1895 }
1896 }
1898 if (bReleaseFailed)
1899 {
1900 PVR_DPF((PVR_DBG_ERROR, "SGXDevInitPart2BW: A handle release failed"));
1901 psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED;
1902 /*
1903 * Given that we checked the handles before release, a release
1904 * failure is unexpected.
1905 */
1906 PVR_DBG_BREAK;
1907 return 0;
1908 }
1910 /* Dissociate device memory from caller */
1911 #if defined (SUPPORT_SID_INTERFACE)
1912 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBMemInfo);
1913 #else
1914 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo);
1915 #endif
1916 if (eError != PVRSRV_OK)
1917 {
1918 bDissociateFailed = IMG_TRUE;
1919 }
1921 #if defined (SUPPORT_SID_INTERFACE)
1922 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBCtlMemInfo);
1923 #else
1924 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo);
1925 #endif
1926 if (eError != PVRSRV_OK)
1927 {
1928 bDissociateFailed = IMG_TRUE;
1929 }
1931 #if defined (SUPPORT_SID_INTERFACE)
1932 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBEventKickerMemInfo);
1933 #else
1934 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo);
1935 #endif
1936 if (eError != PVRSRV_OK)
1937 {
1938 bDissociateFailed = IMG_TRUE;
1939 }
1941 #if defined (SUPPORT_SID_INTERFACE)
1942 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXHostCtlMemInfo);
1943 #else
1944 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo);
1945 #endif
1946 if (eError != PVRSRV_OK)
1947 {
1948 bDissociateFailed = IMG_TRUE;
1949 }
1951 #if defined (SUPPORT_SID_INTERFACE)
1952 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXTA3DCtlMemInfo);
1953 #else
1954 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo);
1955 #endif
1956 if (eError != PVRSRV_OK)
1957 {
1958 bDissociateFailed = IMG_TRUE;
1959 }
1961 #if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920)
1962 #if defined (SUPPORT_SID_INTERFACE)
1963 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo);
1964 #else
1965 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo);
1966 #endif
1967 if (eError != PVRSRV_OK)
1968 {
1969 bDissociateFailed = IMG_TRUE;
1970 }
1971 #endif
1973 /* Dissociate SGX MiscInfo buffer from user space */
1974 #if defined (SUPPORT_SID_INTERFACE)
1975 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXMiscMemInfo);
1976 #else
1977 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo);
1978 #endif
1979 if (eError != PVRSRV_OK)
1980 {
1981 bDissociateFailed = IMG_TRUE;
1982 }
1985 #if defined(SGX_SUPPORT_HWPROFILING)
1986 #if defined (SUPPORT_SID_INTERFACE)
1987 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelHWProfilingMemInfo);
1988 if (eError != PVRSRV_OK)
1989 {
1990 bDissociateFailed = IMG_TRUE;
1991 }
1992 #else
1993 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo);
1994 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
1995 #endif
1996 #endif
1998 #if defined(SUPPORT_SGX_HWPERF)
1999 #if defined (SUPPORT_SID_INTERFACE)
2000 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelHWPerfCBMemInfo);
2001 #else
2002 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo);
2003 #endif
2004 if (eError != PVRSRV_OK)
2005 {
2006 bDissociateFailed = IMG_TRUE;
2007 }
2008 #endif
2010 #if defined (SUPPORT_SID_INTERFACE)
2011 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelTASigBufferMemInfo);
2012 #else
2013 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo);
2014 #endif
2015 if (eError != PVRSRV_OK)
2016 {
2017 bDissociateFailed = IMG_TRUE;
2018 }
2020 #if defined (SUPPORT_SID_INTERFACE)
2021 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernel3DSigBufferMemInfo);
2022 #else
2023 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo);
2024 #endif
2025 if (eError != PVRSRV_OK)
2026 {
2027 bDissociateFailed = IMG_TRUE;
2028 }
2030 #if defined(FIX_HW_BRN_29702)
2031 #if defined (SUPPORT_SID_INTERFACE)
2032 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCFIMemInfo);
2033 if (eError != PVRSRV_OK)
2034 {
2035 bDissociateFailed = IMG_TRUE;
2036 }
2037 #else
2038 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo);
2039 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2040 #endif
2041 #endif
2043 #if defined(FIX_HW_BRN_29823)
2044 #if defined (SUPPORT_SID_INTERFACE)
2045 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelDummyTermStreamMemInfo);
2046 if (eError != PVRSRV_OK)
2047 {
2048 bDissociateFailed = IMG_TRUE;
2049 }
2050 #else
2051 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo);
2052 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2053 #endif
2054 #endif
2056 #if defined(FIX_HW_BRN_31542) || defined(FIX_HW_BRN_36513)
2057 #if defined (SUPPORT_SID_INTERFACE)
2058 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAVDMStreamMemInfo);
2059 if (eError != PVRSRV_OK)
2060 {
2061 bDissociateFailed = IMG_TRUE;
2062 }
2063 #else
2064 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo);
2065 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2066 #endif
2067 #if defined (SUPPORT_SID_INTERFACE)
2068 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAIndexStreamMemInfo);
2069 if (eError != PVRSRV_OK)
2070 {
2071 bDissociateFailed = IMG_TRUE;
2072 }
2073 #else
2074 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo);
2075 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2076 #endif
2077 #if defined (SUPPORT_SID_INTERFACE)
2078 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPDSMemInfo);
2079 if (eError != PVRSRV_OK)
2080 {
2081 bDissociateFailed = IMG_TRUE;
2082 }
2083 #else
2084 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo);
2085 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2086 #endif
2087 #if defined (SUPPORT_SID_INTERFACE)
2088 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAUSEMemInfo);
2089 if (eError != PVRSRV_OK)
2090 {
2091 bDissociateFailed = IMG_TRUE;
2092 }
2093 #else
2094 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo);
2095 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2096 #endif
2097 #if defined (SUPPORT_SID_INTERFACE)
2098 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAParamMemInfo);
2099 if (eError != PVRSRV_OK)
2100 {
2101 bDissociateFailed = IMG_TRUE;
2102 }
2103 #else
2104 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo);
2105 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2106 #endif
2107 #if defined (SUPPORT_SID_INTERFACE)
2108 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPMPTMemInfo);
2109 if (eError != PVRSRV_OK)
2110 {
2111 bDissociateFailed = IMG_TRUE;
2112 }
2113 #else
2114 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo);
2115 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2116 #endif
2117 #if defined (SUPPORT_SID_INTERFACE)
2118 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWATPCMemInfo);
2119 if (eError != PVRSRV_OK)
2120 {
2121 bDissociateFailed = IMG_TRUE;
2122 }
2123 #else
2124 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo);
2125 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2126 #endif
2127 #if defined (SUPPORT_SID_INTERFACE)
2128 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPSGRgnHdrMemInfo);
2129 if (eError != PVRSRV_OK)
2130 {
2131 bDissociateFailed = IMG_TRUE;
2132 }
2133 #else
2134 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo);
2135 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2136 #endif
2137 #endif
2139 #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31559)
2140 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo);
2141 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2143 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo);
2144 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2145 #endif
2146 #if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \
2147 defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX)
2148 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo);
2149 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2150 #endif
2152 #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG)
2153 #if defined (SUPPORT_SID_INTERFACE)
2154 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelEDMStatusBufferMemInfo);
2155 if (eError != PVRSRV_OK)
2156 {
2157 bDissociateFailed = IMG_TRUE;
2158 }
2159 #else
2160 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo);
2161 bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK);
2162 #endif
2163 #endif
2165 for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++)
2166 {
2167 #if defined (SUPPORT_SID_INTERFACE)
2168 IMG_HANDLE hHandle = asInitInfoKM.asInitMemHandles[i];
2169 #else
2170 IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i];
2171 #endif
2173 if (hHandle == IMG_NULL)
2174 continue;
2176 eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, hHandle);
2177 if (eError != PVRSRV_OK)
2178 {
2179 bDissociateFailed = IMG_TRUE;
2180 }
2181 }
2183 /* If any dissociations failed, free all the device memory passed in */
2184 if(bDissociateFailed)
2185 {
2186 #if defined (SUPPORT_SID_INTERFACE)
2187 PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBMemInfo);
2188 PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBCtlMemInfo);
2189 PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXHostCtlMemInfo);
2190 PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXTA3DCtlMemInfo);
2191 #if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920)
2192 PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo);
2193 #endif
2194 PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXMiscMemInfo);
2195 #else
2196 PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo);
2197 PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo);
2198 PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo);
2199 PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo);
2200 #if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920)
2201 PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo);
2202 #endif
2203 PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo);
2204 #endif
2206 for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++)
2207 {
2208 #if defined (SUPPORT_SID_INTERFACE)
2209 IMG_HANDLE hHandle = asInitInfoKM.asInitMemHandles[i];
2211 if (hHandle == 0)
2212 #else
2213 IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i];
2215 if (hHandle == IMG_NULL)
2216 #endif
2217 continue;
2219 PVRSRVFreeDeviceMemKM(hDevCookieInt, (PVRSRV_KERNEL_MEM_INFO *)hHandle);
2221 }
2223 PVR_DPF((PVR_DBG_ERROR, "SGXDevInitPart2BW: A dissociate failed"));
2225 psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED;
2227 /* A dissociation failure is unexpected */
2228 PVR_DBG_BREAK;
2229 return 0;
2230 }
2232 #if defined (SUPPORT_SID_INTERFACE)
2233 asInitInfoKM.sScripts = psSGXDevInitPart2IN->sInitInfo.sScripts;
2234 asInitInfoKM.ui32ClientBuildOptions = psSGXDevInitPart2IN->sInitInfo.ui32ClientBuildOptions;
2235 asInitInfoKM.sSGXStructSizes = psSGXDevInitPart2IN->sInitInfo.sSGXStructSizes;
2236 asInitInfoKM.ui32CacheControl = psSGXDevInitPart2IN->sInitInfo.ui32CacheControl;
2237 asInitInfoKM.ui32EDMTaskReg0 = psSGXDevInitPart2IN->sInitInfo.ui32EDMTaskReg0;
2238 asInitInfoKM.ui32EDMTaskReg1 = psSGXDevInitPart2IN->sInitInfo.ui32EDMTaskReg1;
2239 asInitInfoKM.ui32ClkGateStatusReg = psSGXDevInitPart2IN->sInitInfo.ui32ClkGateStatusReg;
2240 asInitInfoKM.ui32ClkGateStatusMask = psSGXDevInitPart2IN->sInitInfo.ui32ClkGateStatusMask;
2242 OSMemCopy(&asInitInfoKM.asInitDevData ,
2243 &psSGXDevInitPart2IN->sInitInfo.asInitDevData,
2244 sizeof(asInitInfoKM.asInitDevData));
2245 OSMemCopy(&asInitInfoKM.aui32HostKickAddr,
2246 &psSGXDevInitPart2IN->sInitInfo.aui32HostKickAddr,
2247 sizeof(asInitInfoKM.aui32HostKickAddr));
2249 psSGXDevInitPart2OUT->eError =
2250 DevInitSGXPart2KM(psPerProc,
2251 hDevCookieInt,
2252 &asInitInfoKM);
2253 #else
2254 psSGXDevInitPart2OUT->eError =
2255 DevInitSGXPart2KM(psPerProc,
2256 hDevCookieInt,
2257 &psSGXDevInitPart2IN->sInitInfo);
2258 #endif
2260 return 0;
2261 }
2264 static IMG_INT
2265 SGXRegisterHWRenderContextBW(IMG_UINT32 ui32BridgeID,
2266 PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT *psSGXRegHWRenderContextIN,
2267 PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT *psSGXRegHWRenderContextOUT,
2268 PVRSRV_PER_PROCESS_DATA *psPerProc)
2269 {
2270 IMG_HANDLE hDevCookieInt;
2271 // PVRSRV_SGXDEV_INFO *psDevInfo;
2272 IMG_HANDLE hHWRenderContextInt;
2274 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_REGISTER_HW_RENDER_CONTEXT);
2276 NEW_HANDLE_BATCH_OR_ERROR(psSGXRegHWRenderContextOUT->eError, psPerProc, 1);
2278 psSGXRegHWRenderContextOUT->eError =
2279 PVRSRVLookupHandle(psPerProc->psHandleBase,
2280 &hDevCookieInt,
2281 psSGXRegHWRenderContextIN->hDevCookie,
2282 PVRSRV_HANDLE_TYPE_DEV_NODE);
2283 if(psSGXRegHWRenderContextOUT->eError != PVRSRV_OK)
2284 {
2285 return 0;
2286 }
2288 hHWRenderContextInt =
2289 SGXRegisterHWRenderContextKM(hDevCookieInt,
2290 psSGXRegHWRenderContextIN->pHWRenderContextCpuVAddr,
2291 psSGXRegHWRenderContextIN->ui32HWRenderContextSize,
2292 psSGXRegHWRenderContextIN->ui32OffsetToPDDevPAddr,
2293 psSGXRegHWRenderContextIN->hDevMemContext,
2294 &psSGXRegHWRenderContextOUT->sHWRenderContextDevVAddr,
2295 psPerProc);
2297 if (hHWRenderContextInt == IMG_NULL)
2298 {
2299 psSGXRegHWRenderContextOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_CONTEXT;
2300 return 0;
2301 }
2303 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
2304 &psSGXRegHWRenderContextOUT->hHWRenderContext,
2305 hHWRenderContextInt,
2306 PVRSRV_HANDLE_TYPE_SGX_HW_RENDER_CONTEXT,
2307 PVRSRV_HANDLE_ALLOC_FLAG_NONE);
2309 COMMIT_HANDLE_BATCH_OR_ERROR(psSGXRegHWRenderContextOUT->eError, psPerProc);
2311 return 0;
2312 }
2315 static IMG_INT
2316 SGXUnregisterHWRenderContextBW(IMG_UINT32 ui32BridgeID,
2317 PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_RENDER_CONTEXT *psSGXUnregHWRenderContextIN,
2318 PVRSRV_BRIDGE_RETURN *psRetOUT,
2319 PVRSRV_PER_PROCESS_DATA *psPerProc)
2320 {
2321 IMG_HANDLE hHWRenderContextInt;
2323 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_UNREGISTER_HW_RENDER_CONTEXT);
2325 psRetOUT->eError =
2326 PVRSRVLookupHandle(psPerProc->psHandleBase,
2327 &hHWRenderContextInt,
2328 psSGXUnregHWRenderContextIN->hHWRenderContext,
2329 PVRSRV_HANDLE_TYPE_SGX_HW_RENDER_CONTEXT);
2330 if(psRetOUT->eError != PVRSRV_OK)
2331 {
2332 return 0;
2333 }
2335 psRetOUT->eError = SGXUnregisterHWRenderContextKM(hHWRenderContextInt,
2336 psSGXUnregHWRenderContextIN->bForceCleanup);
2337 if(psRetOUT->eError != PVRSRV_OK)
2338 {
2339 return 0;
2340 }
2342 psRetOUT->eError =
2343 PVRSRVReleaseHandle(psPerProc->psHandleBase,
2344 psSGXUnregHWRenderContextIN->hHWRenderContext,
2345 PVRSRV_HANDLE_TYPE_SGX_HW_RENDER_CONTEXT);
2347 return 0;
2348 }
2351 static IMG_INT
2352 SGXRegisterHWTransferContextBW(IMG_UINT32 ui32BridgeID,
2353 PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_TRANSFER_CONTEXT *psSGXRegHWTransferContextIN,
2354 PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT *psSGXRegHWTransferContextOUT,
2355 PVRSRV_PER_PROCESS_DATA *psPerProc)
2356 {
2357 IMG_HANDLE hDevCookieInt;
2358 IMG_HANDLE hHWTransferContextInt;
2360 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_REGISTER_HW_TRANSFER_CONTEXT);
2362 NEW_HANDLE_BATCH_OR_ERROR(psSGXRegHWTransferContextOUT->eError, psPerProc, 1);
2364 psSGXRegHWTransferContextOUT->eError =
2365 PVRSRVLookupHandle(psPerProc->psHandleBase,
2366 &hDevCookieInt,
2367 psSGXRegHWTransferContextIN->hDevCookie,
2368 PVRSRV_HANDLE_TYPE_DEV_NODE);
2369 if(psSGXRegHWTransferContextOUT->eError != PVRSRV_OK)
2370 {
2371 return 0;
2372 }
2374 hHWTransferContextInt =
2375 SGXRegisterHWTransferContextKM(hDevCookieInt,
2376 psSGXRegHWTransferContextIN->pHWTransferContextCpuVAddr,
2377 psSGXRegHWTransferContextIN->ui32HWTransferContextSize,
2378 psSGXRegHWTransferContextIN->ui32OffsetToPDDevPAddr,
2379 psSGXRegHWTransferContextIN->hDevMemContext,
2380 &psSGXRegHWTransferContextOUT->sHWTransferContextDevVAddr,
2381 psPerProc);
2383 if (hHWTransferContextInt == IMG_NULL)
2384 {
2385 psSGXRegHWTransferContextOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_CONTEXT;
2386 return 0;
2387 }
2389 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
2390 &psSGXRegHWTransferContextOUT->hHWTransferContext,
2391 hHWTransferContextInt,
2392 PVRSRV_HANDLE_TYPE_SGX_HW_TRANSFER_CONTEXT,
2393 PVRSRV_HANDLE_ALLOC_FLAG_NONE);
2395 COMMIT_HANDLE_BATCH_OR_ERROR(psSGXRegHWTransferContextOUT->eError, psPerProc);
2397 return 0;
2398 }
2401 static IMG_INT
2402 SGXUnregisterHWTransferContextBW(IMG_UINT32 ui32BridgeID,
2403 PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_TRANSFER_CONTEXT *psSGXUnregHWTransferContextIN,
2404 PVRSRV_BRIDGE_RETURN *psRetOUT,
2405 PVRSRV_PER_PROCESS_DATA *psPerProc)
2406 {
2407 #if defined (SUPPORT_SID_INTERFACE)
2408 IMG_HANDLE hHWTransferContextInt = 0;
2409 #else
2410 IMG_HANDLE hHWTransferContextInt;
2411 #endif
2413 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_UNREGISTER_HW_TRANSFER_CONTEXT);
2415 psRetOUT->eError =
2416 PVRSRVLookupHandle(psPerProc->psHandleBase,
2417 &hHWTransferContextInt,
2418 psSGXUnregHWTransferContextIN->hHWTransferContext,
2419 PVRSRV_HANDLE_TYPE_SGX_HW_TRANSFER_CONTEXT);
2420 if(psRetOUT->eError != PVRSRV_OK)
2421 {
2422 return 0;
2423 }
2425 psRetOUT->eError = SGXUnregisterHWTransferContextKM(hHWTransferContextInt,
2426 psSGXUnregHWTransferContextIN->bForceCleanup);
2427 if(psRetOUT->eError != PVRSRV_OK)
2428 {
2429 return 0;
2430 }
2432 psRetOUT->eError =
2433 PVRSRVReleaseHandle(psPerProc->psHandleBase,
2434 psSGXUnregHWTransferContextIN->hHWTransferContext,
2435 PVRSRV_HANDLE_TYPE_SGX_HW_TRANSFER_CONTEXT);
2437 return 0;
2438 }
2441 #if defined(SGX_FEATURE_2D_HARDWARE)
2442 static IMG_INT
2443 SGXRegisterHW2DContextBW(IMG_UINT32 ui32BridgeID,
2444 PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_2D_CONTEXT *psSGXRegHW2DContextIN,
2445 PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT *psSGXRegHW2DContextOUT,
2446 PVRSRV_PER_PROCESS_DATA *psPerProc)
2447 {
2448 IMG_HANDLE hDevCookieInt;
2449 IMG_HANDLE hHW2DContextInt;
2451 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_REGISTER_HW_2D_CONTEXT);
2453 NEW_HANDLE_BATCH_OR_ERROR(psSGXRegHW2DContextOUT->eError, psPerProc, 1);
2455 psSGXRegHW2DContextOUT->eError =
2456 PVRSRVLookupHandle(psPerProc->psHandleBase,
2457 &hDevCookieInt,
2458 psSGXRegHW2DContextIN->hDevCookie,
2459 PVRSRV_HANDLE_TYPE_DEV_NODE);
2460 if(psSGXRegHW2DContextOUT->eError != PVRSRV_OK)
2461 {
2462 return 0;
2463 }
2465 hHW2DContextInt =
2466 SGXRegisterHW2DContextKM(hDevCookieInt,
2467 psSGXRegHW2DContextIN->pHW2DContextCpuVAddr,
2468 psSGXRegHW2DContextIN->ui32HW2DContextSize,
2469 psSGXRegHW2DContextIN->ui32OffsetToPDDevPAddr,
2470 psSGXRegHW2DContextIN->hDevMemContext,
2471 &psSGXRegHW2DContextOUT->sHW2DContextDevVAddr,
2472 psPerProc);
2474 if (hHW2DContextInt == IMG_NULL)
2475 {
2476 psSGXRegHW2DContextOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_CONTEXT;
2477 return 0;
2478 }
2480 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
2481 &psSGXRegHW2DContextOUT->hHW2DContext,
2482 hHW2DContextInt,
2483 PVRSRV_HANDLE_TYPE_SGX_HW_2D_CONTEXT,
2484 PVRSRV_HANDLE_ALLOC_FLAG_NONE);
2486 COMMIT_HANDLE_BATCH_OR_ERROR(psSGXRegHW2DContextOUT->eError, psPerProc);
2488 return 0;
2489 }
2492 static IMG_INT
2493 SGXUnregisterHW2DContextBW(IMG_UINT32 ui32BridgeID,
2494 PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT *psSGXUnregHW2DContextIN,
2495 PVRSRV_BRIDGE_RETURN *psRetOUT,
2496 PVRSRV_PER_PROCESS_DATA *psPerProc)
2497 {
2498 IMG_HANDLE hHW2DContextInt;
2500 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_UNREGISTER_HW_2D_CONTEXT);
2502 psRetOUT->eError =
2503 PVRSRVLookupHandle(psPerProc->psHandleBase,
2504 &hHW2DContextInt,
2505 psSGXUnregHW2DContextIN->hHW2DContext,
2506 PVRSRV_HANDLE_TYPE_SGX_HW_2D_CONTEXT);
2507 if(psRetOUT->eError != PVRSRV_OK)
2508 {
2509 return 0;
2510 }
2512 psRetOUT->eError = SGXUnregisterHW2DContextKM(hHW2DContextInt,
2513 psSGXUnregHW2DContextIN->bForceCleanup);
2514 if(psRetOUT->eError != PVRSRV_OK)
2515 {
2516 return 0;
2517 }
2519 psRetOUT->eError =
2520 PVRSRVReleaseHandle(psPerProc->psHandleBase,
2521 psSGXUnregHW2DContextIN->hHW2DContext,
2522 PVRSRV_HANDLE_TYPE_SGX_HW_2D_CONTEXT);
2524 return 0;
2525 }
2526 #endif /* #if defined(SGX_FEATURE_2D_HARDWARE) */
2528 static IMG_INT
2529 SGXFlushHWRenderTargetBW(IMG_UINT32 ui32BridgeID,
2530 PVRSRV_BRIDGE_IN_SGX_FLUSH_HW_RENDER_TARGET *psSGXFlushHWRenderTargetIN,
2531 PVRSRV_BRIDGE_RETURN *psRetOUT,
2532 PVRSRV_PER_PROCESS_DATA *psPerProc)
2533 {
2534 IMG_HANDLE hDevCookieInt;
2535 // PVRSRV_SGXDEV_INFO *psDevInfo;
2537 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_FLUSH_HW_RENDER_TARGET);
2539 psRetOUT->eError =
2540 PVRSRVLookupHandle(psPerProc->psHandleBase,
2541 &hDevCookieInt,
2542 psSGXFlushHWRenderTargetIN->hDevCookie,
2543 PVRSRV_HANDLE_TYPE_DEV_NODE);
2544 if(psRetOUT->eError != PVRSRV_OK)
2545 {
2546 return 0;
2547 }
2549 // psDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookieInt)->pvDevice;
2551 psRetOUT->eError = SGXFlushHWRenderTargetKM(hDevCookieInt, psSGXFlushHWRenderTargetIN->sHWRTDataSetDevVAddr, IMG_FALSE);
2553 return 0;
2554 }
2557 static IMG_INT
2558 SGX2DQueryBlitsCompleteBW(IMG_UINT32 ui32BridgeID,
2559 PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE *ps2DQueryBltsCompleteIN,
2560 PVRSRV_BRIDGE_RETURN *psRetOUT,
2561 PVRSRV_PER_PROCESS_DATA *psPerProc)
2562 {
2563 IMG_HANDLE hDevCookieInt;
2564 IMG_VOID *pvSyncInfo;
2565 PVRSRV_SGXDEV_INFO *psDevInfo;
2567 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_2DQUERYBLTSCOMPLETE);
2569 psRetOUT->eError =
2570 PVRSRVLookupHandle(psPerProc->psHandleBase,
2571 &hDevCookieInt,
2572 ps2DQueryBltsCompleteIN->hDevCookie,
2573 PVRSRV_HANDLE_TYPE_DEV_NODE);
2574 if(psRetOUT->eError != PVRSRV_OK)
2575 {
2576 return 0;
2577 }
2579 psRetOUT->eError =
2580 PVRSRVLookupHandle(psPerProc->psHandleBase,
2581 &pvSyncInfo,
2582 ps2DQueryBltsCompleteIN->hKernSyncInfo,
2583 PVRSRV_HANDLE_TYPE_SYNC_INFO);
2584 if(psRetOUT->eError != PVRSRV_OK)
2585 {
2586 return 0;
2587 }
2589 psDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookieInt)->pvDevice;
2591 psRetOUT->eError =
2592 SGX2DQueryBlitsCompleteKM(psDevInfo,
2593 (PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo,
2594 ps2DQueryBltsCompleteIN->bWaitForComplete);
2596 return 0;
2597 }
2600 static IMG_INT
2601 SGXFindSharedPBDescBW(IMG_UINT32 ui32BridgeID,
2602 PVRSRV_BRIDGE_IN_SGXFINDSHAREDPBDESC *psSGXFindSharedPBDescIN,
2603 PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC *psSGXFindSharedPBDescOUT,
2604 PVRSRV_PER_PROCESS_DATA *psPerProc)
2605 {
2606 IMG_HANDLE hDevCookieInt;
2607 PVRSRV_KERNEL_MEM_INFO *psSharedPBDescKernelMemInfo;
2608 PVRSRV_KERNEL_MEM_INFO *psHWPBDescKernelMemInfo;
2609 PVRSRV_KERNEL_MEM_INFO *psBlockKernelMemInfo;
2610 PVRSRV_KERNEL_MEM_INFO *psHWBlockKernelMemInfo;
2611 PVRSRV_KERNEL_MEM_INFO **ppsSharedPBDescSubKernelMemInfos = IMG_NULL;
2612 IMG_UINT32 ui32SharedPBDescSubKernelMemInfosCount = 0;
2613 IMG_UINT32 i;
2614 IMG_HANDLE hSharedPBDesc = IMG_NULL;
2616 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC);
2618 NEW_HANDLE_BATCH_OR_ERROR(psSGXFindSharedPBDescOUT->eError, psPerProc, PVRSRV_BRIDGE_SGX_SHAREDPBDESC_MAX_SUBMEMINFOS + 4);
2620 psSGXFindSharedPBDescOUT->hSharedPBDesc = IMG_NULL;
2622 psSGXFindSharedPBDescOUT->eError =
2623 PVRSRVLookupHandle(psPerProc->psHandleBase,
2624 &hDevCookieInt,
2625 psSGXFindSharedPBDescIN->hDevCookie,
2626 PVRSRV_HANDLE_TYPE_DEV_NODE);
2627 if(psSGXFindSharedPBDescOUT->eError != PVRSRV_OK)
2628 goto PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC_EXIT;
2630 psSGXFindSharedPBDescOUT->eError =
2631 SGXFindSharedPBDescKM(psPerProc, hDevCookieInt,
2632 psSGXFindSharedPBDescIN->bLockOnFailure,
2633 psSGXFindSharedPBDescIN->ui32TotalPBSize,
2634 &hSharedPBDesc,
2635 &psSharedPBDescKernelMemInfo,
2636 &psHWPBDescKernelMemInfo,
2637 &psBlockKernelMemInfo,
2638 &psHWBlockKernelMemInfo,
2639 &ppsSharedPBDescSubKernelMemInfos,
2640 &ui32SharedPBDescSubKernelMemInfosCount);
2641 if(psSGXFindSharedPBDescOUT->eError != PVRSRV_OK)
2642 goto PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC_EXIT;
2644 PVR_ASSERT(ui32SharedPBDescSubKernelMemInfosCount
2645 <= PVRSRV_BRIDGE_SGX_SHAREDPBDESC_MAX_SUBMEMINFOS);
2647 psSGXFindSharedPBDescOUT->ui32SharedPBDescSubKernelMemInfoHandlesCount =
2648 ui32SharedPBDescSubKernelMemInfosCount;
2650 if(hSharedPBDesc == IMG_NULL)
2651 {
2652 psSGXFindSharedPBDescOUT->hSharedPBDescKernelMemInfoHandle = 0;
2653 /* It's not an error if we don't find a buffer,
2654 * we just return NULL */
2655 goto PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC_EXIT;
2656 }
2658 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
2659 &psSGXFindSharedPBDescOUT->hSharedPBDesc,
2660 hSharedPBDesc,
2661 PVRSRV_HANDLE_TYPE_SHARED_PB_DESC,
2662 PVRSRV_HANDLE_ALLOC_FLAG_NONE);
2664 /*
2665 * We allocate handles of type PVRSRV_HANDLE_TYPE_MEM_INFO_REF here,
2666 * as the process doesn't own the underlying memory, and so should
2667 * only be allowed a restricted set of operations on it, such as
2668 * mapping it into its address space.
2669 */
2670 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
2671 &psSGXFindSharedPBDescOUT->hSharedPBDescKernelMemInfoHandle,
2672 psSharedPBDescKernelMemInfo,
2673 PVRSRV_HANDLE_TYPE_MEM_INFO_REF,
2674 PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
2675 psSGXFindSharedPBDescOUT->hSharedPBDesc);
2677 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
2678 &psSGXFindSharedPBDescOUT->hHWPBDescKernelMemInfoHandle,
2679 psHWPBDescKernelMemInfo,
2680 PVRSRV_HANDLE_TYPE_MEM_INFO_REF,
2681 PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
2682 psSGXFindSharedPBDescOUT->hSharedPBDesc);
2684 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
2685 &psSGXFindSharedPBDescOUT->hBlockKernelMemInfoHandle,
2686 psBlockKernelMemInfo,
2687 PVRSRV_HANDLE_TYPE_MEM_INFO_REF,
2688 PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
2689 psSGXFindSharedPBDescOUT->hSharedPBDesc);
2691 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
2692 &psSGXFindSharedPBDescOUT->hHWBlockKernelMemInfoHandle,
2693 psHWBlockKernelMemInfo,
2694 PVRSRV_HANDLE_TYPE_MEM_INFO_REF,
2695 PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
2696 psSGXFindSharedPBDescOUT->hSharedPBDesc);
2699 for(i=0; i<ui32SharedPBDescSubKernelMemInfosCount; i++)
2700 {
2701 PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC *psSGXFindSharedPBDescOut =
2702 psSGXFindSharedPBDescOUT;
2704 PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
2705 &psSGXFindSharedPBDescOut->ahSharedPBDescSubKernelMemInfoHandles[i],
2706 ppsSharedPBDescSubKernelMemInfos[i],
2707 PVRSRV_HANDLE_TYPE_MEM_INFO_REF,
2708 PVRSRV_HANDLE_ALLOC_FLAG_MULTI,
2709 psSGXFindSharedPBDescOUT->hSharedPBDescKernelMemInfoHandle);
2710 }
2712 PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC_EXIT:
2713 if (ppsSharedPBDescSubKernelMemInfos != IMG_NULL)
2714 {
2715 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
2716 sizeof(PVRSRV_KERNEL_MEM_INFO *) * ui32SharedPBDescSubKernelMemInfosCount,
2717 ppsSharedPBDescSubKernelMemInfos,
2718 IMG_NULL);
2719 }
2721 if(psSGXFindSharedPBDescOUT->eError != PVRSRV_OK)
2722 {
2723 if(hSharedPBDesc != IMG_NULL)
2724 {
2725 SGXUnrefSharedPBDescKM(hSharedPBDesc);
2726 }
2727 }
2728 else
2729 {
2730 COMMIT_HANDLE_BATCH_OR_ERROR(psSGXFindSharedPBDescOUT->eError, psPerProc);
2731 }
2733 return 0;
2734 }
2737 static IMG_INT
2738 SGXUnrefSharedPBDescBW(IMG_UINT32 ui32BridgeID,
2739 PVRSRV_BRIDGE_IN_SGXUNREFSHAREDPBDESC *psSGXUnrefSharedPBDescIN,
2740 PVRSRV_BRIDGE_OUT_SGXUNREFSHAREDPBDESC *psSGXUnrefSharedPBDescOUT,
2741 PVRSRV_PER_PROCESS_DATA *psPerProc)
2742 {
2743 IMG_HANDLE hSharedPBDesc;
2745 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_UNREFSHAREDPBDESC);
2747 psSGXUnrefSharedPBDescOUT->eError =
2748 PVRSRVLookupHandle(psPerProc->psHandleBase,
2749 &hSharedPBDesc,
2750 psSGXUnrefSharedPBDescIN->hSharedPBDesc,
2751 PVRSRV_HANDLE_TYPE_SHARED_PB_DESC);
2752 if(psSGXUnrefSharedPBDescOUT->eError != PVRSRV_OK)
2753 {
2754 return 0;
2755 }
2757 psSGXUnrefSharedPBDescOUT->eError =
2758 SGXUnrefSharedPBDescKM(hSharedPBDesc);
2760 if(psSGXUnrefSharedPBDescOUT->eError != PVRSRV_OK)
2761 {
2762 return 0;
2763 }
2765 psSGXUnrefSharedPBDescOUT->eError =
2766 PVRSRVReleaseHandle(psPerProc->psHandleBase,
2767 psSGXUnrefSharedPBDescIN->hSharedPBDesc,
2768 PVRSRV_HANDLE_TYPE_SHARED_PB_DESC);
2770 return 0;
2771 }
2774 static IMG_INT
2775 SGXAddSharedPBDescBW(IMG_UINT32 ui32BridgeID,
2776 PVRSRV_BRIDGE_IN_SGXADDSHAREDPBDESC *psSGXAddSharedPBDescIN,
2777 PVRSRV_BRIDGE_OUT_SGXADDSHAREDPBDESC *psSGXAddSharedPBDescOUT,
2778 PVRSRV_PER_PROCESS_DATA *psPerProc)
2779 {
2780 IMG_HANDLE hDevCookieInt;
2781 PVRSRV_KERNEL_MEM_INFO *psSharedPBDescKernelMemInfo;
2782 PVRSRV_KERNEL_MEM_INFO *psHWPBDescKernelMemInfo;
2783 PVRSRV_KERNEL_MEM_INFO *psBlockKernelMemInfo;
2784 PVRSRV_KERNEL_MEM_INFO *psHWBlockKernelMemInfo;
2785 IMG_UINT32 ui32KernelMemInfoHandlesCount =
2786 psSGXAddSharedPBDescIN->ui32KernelMemInfoHandlesCount;
2787 IMG_INT ret = 0;
2788 #if defined (SUPPORT_SID_INTERFACE)
2789 IMG_SID *phKernelMemInfoHandles = 0;
2790 #else
2791 IMG_HANDLE *phKernelMemInfoHandles = IMG_NULL;
2792 #endif
2793 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfos = IMG_NULL;
2794 IMG_UINT32 i;
2795 PVRSRV_ERROR eError;
2796 IMG_HANDLE hSharedPBDesc = IMG_NULL;
2798 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC);
2800 NEW_HANDLE_BATCH_OR_ERROR(psSGXAddSharedPBDescOUT->eError, psPerProc, 1);
2802 psSGXAddSharedPBDescOUT->hSharedPBDesc = IMG_NULL;
2804 PVR_ASSERT(ui32KernelMemInfoHandlesCount
2805 <= PVRSRV_BRIDGE_SGX_SHAREDPBDESC_MAX_SUBMEMINFOS);
2807 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
2808 &hDevCookieInt,
2809 psSGXAddSharedPBDescIN->hDevCookie,
2810 PVRSRV_HANDLE_TYPE_DEV_NODE);
2811 if(eError != PVRSRV_OK)
2812 {
2813 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2814 }
2816 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
2817 (IMG_VOID **)&psSharedPBDescKernelMemInfo,
2818 psSGXAddSharedPBDescIN->hSharedPBDescKernelMemInfo,
2819 PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO);
2820 if(eError != PVRSRV_OK)
2821 {
2822 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2823 }
2825 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
2826 (IMG_VOID **)&psHWPBDescKernelMemInfo,
2827 psSGXAddSharedPBDescIN->hHWPBDescKernelMemInfo,
2828 PVRSRV_HANDLE_TYPE_MEM_INFO);
2829 if(eError != PVRSRV_OK)
2830 {
2831 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2832 }
2834 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
2835 (IMG_VOID **)&psBlockKernelMemInfo,
2836 psSGXAddSharedPBDescIN->hBlockKernelMemInfo,
2837 PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO);
2838 if(eError != PVRSRV_OK)
2839 {
2840 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2841 }
2843 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
2844 (IMG_VOID **)&psHWBlockKernelMemInfo,
2845 psSGXAddSharedPBDescIN->hHWBlockKernelMemInfo,
2846 PVRSRV_HANDLE_TYPE_MEM_INFO);
2847 if(eError != PVRSRV_OK)
2848 {
2849 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2850 }
2853 if(!OSAccessOK(PVR_VERIFY_READ,
2854 psSGXAddSharedPBDescIN->phKernelMemInfoHandles,
2855 ui32KernelMemInfoHandlesCount * sizeof(IMG_HANDLE)))
2856 {
2857 PVR_DPF((PVR_DBG_ERROR, "%s: PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC:"
2858 " Invalid phKernelMemInfos pointer", __FUNCTION__));
2859 ret = -EFAULT;
2860 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2861 }
2863 eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
2864 ui32KernelMemInfoHandlesCount * sizeof(IMG_HANDLE),
2865 (IMG_VOID **)&phKernelMemInfoHandles,
2866 0,
2867 "Array of Handles");
2868 if (eError != PVRSRV_OK)
2869 {
2870 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2871 }
2873 if(CopyFromUserWrapper(psPerProc,
2874 ui32BridgeID,
2875 phKernelMemInfoHandles,
2876 psSGXAddSharedPBDescIN->phKernelMemInfoHandles,
2877 ui32KernelMemInfoHandlesCount * sizeof(IMG_HANDLE))
2878 != PVRSRV_OK)
2879 {
2880 ret = -EFAULT;
2881 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2882 }
2884 eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
2885 ui32KernelMemInfoHandlesCount * sizeof(PVRSRV_KERNEL_MEM_INFO *),
2886 (IMG_VOID **)&ppsKernelMemInfos,
2887 0,
2888 "Array of pointers to Kernel Memory Info");
2889 if (eError != PVRSRV_OK)
2890 {
2891 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2892 }
2894 for(i=0; i<ui32KernelMemInfoHandlesCount; i++)
2895 {
2896 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
2897 (IMG_VOID **)&ppsKernelMemInfos[i],
2898 phKernelMemInfoHandles[i],
2899 PVRSRV_HANDLE_TYPE_MEM_INFO);
2900 if(eError != PVRSRV_OK)
2901 {
2902 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2903 }
2904 }
2906 /*
2907 * Release all the handles we've just looked up, as none
2908 * of the associated resources will be valid for access via
2909 * those handles once we return from SGXAddSharedPBDesc.
2910 */
2911 /* PRQA S 3198 2 */ /* override redundant warning as PVR_ASSERT is ignored by QAC */
2912 eError = PVRSRVReleaseHandle(psPerProc->psHandleBase,
2913 psSGXAddSharedPBDescIN->hSharedPBDescKernelMemInfo,
2914 PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO);
2915 PVR_ASSERT(eError == PVRSRV_OK);
2917 /* PRQA S 3198 2 */ /* override redundant warning as PVR_ASSERT is ignored by QAC */
2918 eError = PVRSRVReleaseHandle(psPerProc->psHandleBase,
2919 psSGXAddSharedPBDescIN->hHWPBDescKernelMemInfo,
2920 PVRSRV_HANDLE_TYPE_MEM_INFO);
2921 PVR_ASSERT(eError == PVRSRV_OK);
2923 /* PRQA S 3198 2 */ /* override redundant warning as PVR_ASSERT is ignored by QAC */
2924 eError = PVRSRVReleaseHandle(psPerProc->psHandleBase,
2925 psSGXAddSharedPBDescIN->hBlockKernelMemInfo,
2926 PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO);
2927 PVR_ASSERT(eError == PVRSRV_OK);
2929 /* PRQA S 3198 2 */ /* override redundant warning as PVR_ASSERT is ignored by QAC */
2930 eError = PVRSRVReleaseHandle(psPerProc->psHandleBase,
2931 psSGXAddSharedPBDescIN->hHWBlockKernelMemInfo,
2932 PVRSRV_HANDLE_TYPE_MEM_INFO);
2933 PVR_ASSERT(eError == PVRSRV_OK);
2935 for(i=0; i<ui32KernelMemInfoHandlesCount; i++)
2936 {
2937 /* PRQA S 3198 2 */ /* override redundant warning as PVR_ASSERT is ignored by QAC */
2938 eError = PVRSRVReleaseHandle(psPerProc->psHandleBase,
2939 phKernelMemInfoHandles[i],
2940 PVRSRV_HANDLE_TYPE_MEM_INFO);
2941 PVR_ASSERT(eError == PVRSRV_OK);
2942 }
2944 eError = SGXAddSharedPBDescKM(psPerProc, hDevCookieInt,
2945 psSharedPBDescKernelMemInfo,
2946 psHWPBDescKernelMemInfo,
2947 psBlockKernelMemInfo,
2948 psHWBlockKernelMemInfo,
2949 psSGXAddSharedPBDescIN->ui32TotalPBSize,
2950 &hSharedPBDesc,
2951 ppsKernelMemInfos,
2952 ui32KernelMemInfoHandlesCount,
2953 psSGXAddSharedPBDescIN->sHWPBDescDevVAddr);
2956 if (eError != PVRSRV_OK)
2957 {
2958 goto PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT;
2959 }
2961 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
2962 &psSGXAddSharedPBDescOUT->hSharedPBDesc,
2963 hSharedPBDesc,
2964 PVRSRV_HANDLE_TYPE_SHARED_PB_DESC,
2965 PVRSRV_HANDLE_ALLOC_FLAG_NONE);
2967 PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC_RETURN_RESULT:
2969 if(phKernelMemInfoHandles)
2970 {
2971 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
2972 psSGXAddSharedPBDescIN->ui32KernelMemInfoHandlesCount * sizeof(IMG_HANDLE),
2973 (IMG_VOID *)phKernelMemInfoHandles,
2974 0);
2975 }
2976 if(ppsKernelMemInfos)
2977 {
2978 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
2979 psSGXAddSharedPBDescIN->ui32KernelMemInfoHandlesCount * sizeof(PVRSRV_KERNEL_MEM_INFO *),
2980 (IMG_VOID *)ppsKernelMemInfos,
2981 0);
2982 }
2984 if(ret == 0 && eError == PVRSRV_OK)
2985 {
2986 COMMIT_HANDLE_BATCH_OR_ERROR(psSGXAddSharedPBDescOUT->eError, psPerProc);
2987 }
2989 psSGXAddSharedPBDescOUT->eError = eError;
2991 return ret;
2992 }
2994 static IMG_INT
2995 SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID,
2996 PVRSRV_BRIDGE_IN_SGXINFO_FOR_SRVINIT *psSGXInfoForSrvinitIN,
2997 PVRSRV_BRIDGE_OUT_SGXINFO_FOR_SRVINIT *psSGXInfoForSrvinitOUT,
2998 PVRSRV_PER_PROCESS_DATA *psPerProc)
2999 {
3000 IMG_HANDLE hDevCookieInt;
3001 IMG_UINT32 i;
3002 #if defined (SUPPORT_SID_INTERFACE)
3003 PVRSRV_HEAP_INFO_KM asHeapInfo[PVRSRV_MAX_CLIENT_HEAPS];
3004 #endif
3005 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGXINFO_FOR_SRVINIT);
3007 NEW_HANDLE_BATCH_OR_ERROR(psSGXInfoForSrvinitOUT->eError, psPerProc, PVRSRV_MAX_CLIENT_HEAPS);
3009 if(!psPerProc->bInitProcess)
3010 {
3011 psSGXInfoForSrvinitOUT->eError = PVRSRV_ERROR_PROCESS_NOT_INITIALISED;
3012 return 0;
3013 }
3015 psSGXInfoForSrvinitOUT->eError =
3016 PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt,
3017 psSGXInfoForSrvinitIN->hDevCookie,
3018 PVRSRV_HANDLE_TYPE_DEV_NODE);
3020 if(psSGXInfoForSrvinitOUT->eError != PVRSRV_OK)
3021 {
3022 return 0;
3023 }
3025 psSGXInfoForSrvinitOUT->eError =
3026 SGXGetInfoForSrvinitKM(hDevCookieInt,
3027 #if defined (SUPPORT_SID_INTERFACE)
3028 &asHeapInfo[0],
3029 &psSGXInfoForSrvinitOUT->sInitInfo.sPDDevPAddr);
3030 #else
3031 &psSGXInfoForSrvinitOUT->sInitInfo);
3032 #endif
3034 if(psSGXInfoForSrvinitOUT->eError != PVRSRV_OK)
3035 {
3036 return 0;
3037 }
3039 for(i = 0; i < PVRSRV_MAX_CLIENT_HEAPS; i++)
3040 {
3041 PVRSRV_HEAP_INFO *psHeapInfo;
3043 psHeapInfo = &psSGXInfoForSrvinitOUT->sInitInfo.asHeapInfo[i];
3045 #if defined (SUPPORT_SID_INTERFACE)
3046 if ((asHeapInfo[i].ui32HeapID != (IMG_UINT32)SGX_UNDEFINED_HEAP_ID) &&
3047 (asHeapInfo[i].hDevMemHeap != IMG_NULL))
3048 {
3049 /* Allocate heap handle */
3050 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
3051 &psHeapInfo->hDevMemHeap,
3052 asHeapInfo[i].hDevMemHeap,
3053 PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP,
3054 PVRSRV_HANDLE_ALLOC_FLAG_SHARED);
3055 }
3056 else
3057 {
3058 psHeapInfo->hDevMemHeap = 0;
3059 }
3061 psHeapInfo->ui32HeapID = asHeapInfo[i].ui32HeapID;
3062 psHeapInfo->sDevVAddrBase = asHeapInfo[i].sDevVAddrBase;
3063 psHeapInfo->ui32HeapByteSize = asHeapInfo[i].ui32HeapByteSize;
3064 psHeapInfo->ui32Attribs = asHeapInfo[i].ui32Attribs;
3065 psHeapInfo->ui32XTileStride = asHeapInfo[i].ui32XTileStride;
3066 #else
3067 if (psHeapInfo->ui32HeapID != (IMG_UINT32)SGX_UNDEFINED_HEAP_ID)
3068 {
3069 IMG_HANDLE hDevMemHeapExt;
3071 if (psHeapInfo->hDevMemHeap != IMG_NULL)
3072 {
3073 /* Allocate heap handle */
3074 PVRSRVAllocHandleNR(psPerProc->psHandleBase,
3075 &hDevMemHeapExt,
3076 psHeapInfo->hDevMemHeap,
3077 PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP,
3078 PVRSRV_HANDLE_ALLOC_FLAG_SHARED);
3079 psHeapInfo->hDevMemHeap = hDevMemHeapExt;
3080 }
3081 }
3082 #endif
3083 }
3085 COMMIT_HANDLE_BATCH_OR_ERROR(psSGXInfoForSrvinitOUT->eError, psPerProc);
3087 return 0;
3088 }
3090 #if defined(PDUMP)
3091 // PRQA S 5120++
3092 /*****************************************************************************
3093 FUNCTION : DumpBufferArray
3094 PURPOSE : PDUMP information in stored buffer array
3095 PARAMETERS :
3096 RETURNS :
3097 *****************************************************************************/
3098 static IMG_VOID
3099 DumpBufferArray(PVRSRV_PER_PROCESS_DATA *psPerProc,
3100 #if defined (SUPPORT_SID_INTERFACE)
3101 PSGX_KICKTA_DUMP_BUFFER_KM psBufferArray,
3102 #else
3103 PSGX_KICKTA_DUMP_BUFFER psBufferArray,
3104 #endif
3105 IMG_UINT32 ui32BufferArrayLength,
3106 IMG_BOOL bDumpPolls)
3107 {
3108 IMG_UINT32 i;
3110 for (i=0; i<ui32BufferArrayLength; i++)
3111 {
3112 #if defined (SUPPORT_SID_INTERFACE)
3113 PSGX_KICKTA_DUMP_BUFFER_KM psBuffer;
3114 #else
3115 PSGX_KICKTA_DUMP_BUFFER psBuffer;
3116 #endif
3117 PVRSRV_KERNEL_MEM_INFO *psCtrlMemInfoKM;
3118 IMG_CHAR * pszName;
3119 IMG_HANDLE hUniqueTag;
3120 IMG_UINT32 ui32Offset;
3122 psBuffer = &psBufferArray[i];
3123 pszName = psBuffer->pszName;
3124 if (!pszName)
3125 {
3126 pszName = "Nameless buffer";
3127 }
3129 hUniqueTag = MAKEUNIQUETAG((PVRSRV_KERNEL_MEM_INFO *)psBuffer->hKernelMemInfo);
3131 #if defined(SUPPORT_SGX_NEW_STATUS_VALS)
3132 psCtrlMemInfoKM = ((PVRSRV_KERNEL_MEM_INFO *)psBuffer->hCtrlKernelMemInfo);
3133 ui32Offset = psBuffer->sCtrlDevVAddr.uiAddr - psCtrlMemInfoKM->sDevVAddr.uiAddr;
3134 #else
3135 psCtrlMemInfoKM = ((PVRSRV_KERNEL_MEM_INFO *)psBuffer->hKernelMemInfo)->psKernelSyncInfo->psSyncDataMemInfoKM;
3136 ui32Offset = offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete);
3137 #endif
3139 if (psBuffer->ui32Start <= psBuffer->ui32End)
3140 {
3141 if (bDumpPolls)
3142 {
3143 PDUMPCOMMENTWITHFLAGS(0, "Wait for %s space\r\n", pszName);
3144 PDUMPCBP(psCtrlMemInfoKM,
3145 ui32Offset,
3146 psBuffer->ui32Start,
3147 psBuffer->ui32SpaceUsed,
3148 psBuffer->ui32BufferSize,
3149 0,
3150 MAKEUNIQUETAG(psCtrlMemInfoKM));
3151 }
3153 PDUMPCOMMENTWITHFLAGS(0, "%s\r\n", pszName);
3154 PDUMPMEMUM(psPerProc,
3155 IMG_NULL,
3156 psBuffer->pvLinAddr,
3157 (PVRSRV_KERNEL_MEM_INFO*)psBuffer->hKernelMemInfo,
3158 psBuffer->ui32Start,
3159 psBuffer->ui32End - psBuffer->ui32Start,
3160 0,
3161 hUniqueTag);
3162 }
3163 else
3164 {
3165 /*
3166 Range of data wraps the end of the buffer so it needs to be dumped in two sections
3167 */
3169 if (bDumpPolls)
3170 {
3171 PDUMPCOMMENTWITHFLAGS(0, "Wait for %s space\r\n", pszName);
3172 PDUMPCBP(psCtrlMemInfoKM,
3173 ui32Offset,
3174 psBuffer->ui32Start,
3175 psBuffer->ui32BackEndLength,
3176 psBuffer->ui32BufferSize,
3177 0,
3178 MAKEUNIQUETAG(psCtrlMemInfoKM));
3179 }
3180 PDUMPCOMMENTWITHFLAGS(0, "%s (part 1)\r\n", pszName);
3181 PDUMPMEMUM(psPerProc,
3182 IMG_NULL,
3183 psBuffer->pvLinAddr,
3184 (PVRSRV_KERNEL_MEM_INFO*)psBuffer->hKernelMemInfo,
3185 psBuffer->ui32Start,
3186 psBuffer->ui32BackEndLength,
3187 0,
3188 hUniqueTag);
3190 if (bDumpPolls)
3191 {
3192 PDUMPMEMPOL(psCtrlMemInfoKM,
3193 ui32Offset,
3194 0,
3195 0xFFFFFFFF,
3196 PDUMP_POLL_OPERATOR_NOTEQUAL,
3197 0,
3198 MAKEUNIQUETAG(psCtrlMemInfoKM));
3200 PDUMPCOMMENTWITHFLAGS(0, "Wait for %s space\r\n", pszName);
3201 PDUMPCBP(psCtrlMemInfoKM,
3202 ui32Offset,
3203 0,
3204 psBuffer->ui32End,
3205 psBuffer->ui32BufferSize,
3206 0,
3207 MAKEUNIQUETAG(psCtrlMemInfoKM));
3208 }
3209 PDUMPCOMMENTWITHFLAGS(0, "%s (part 2)\r\n", pszName);
3210 PDUMPMEMUM(psPerProc,
3211 IMG_NULL,
3212 psBuffer->pvLinAddr,
3213 (PVRSRV_KERNEL_MEM_INFO*)psBuffer->hKernelMemInfo,
3214 0,
3215 psBuffer->ui32End,
3216 0,
3217 hUniqueTag);
3218 }
3219 }
3220 }
3221 static IMG_INT
3222 SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID,
3223 PVRSRV_BRIDGE_IN_PDUMP_BUFFER_ARRAY *psPDumpBufferArrayIN,
3224 IMG_VOID *psBridgeOut,
3225 PVRSRV_PER_PROCESS_DATA *psPerProc)
3226 {
3227 IMG_UINT32 i;
3228 #if defined (SUPPORT_SID_INTERFACE)
3229 SGX_KICKTA_DUMP_BUFFER *psUMPtr;
3230 SGX_KICKTA_DUMP_BUFFER_KM *psKickTADumpBufferKM, *psKMPtr;
3231 #else
3232 #if defined(__QNXNTO__)
3233 const IMG_UINT32 NAME_BUFFER_SIZE = 30;
3234 IMG_PCHAR pszNameBuffer, pszName;
3235 IMG_UINT32 ui32NameBufferArraySize, ui32NameLength;
3236 #endif
3237 SGX_KICKTA_DUMP_BUFFER *psKickTADumpBuffer;
3238 #endif
3239 IMG_UINT32 ui32BufferArrayLength =
3240 psPDumpBufferArrayIN->ui32BufferArrayLength;
3241 IMG_UINT32 ui32BufferArraySize =
3242 ui32BufferArrayLength * sizeof(SGX_KICKTA_DUMP_BUFFER);
3243 PVRSRV_ERROR eError = PVRSRV_ERROR_TOO_FEW_BUFFERS;
3245 PVR_UNREFERENCED_PARAMETER(psBridgeOut);
3247 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY);
3249 #if defined (SUPPORT_SID_INTERFACE)
3250 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
3251 ui32BufferArraySize,
3252 (IMG_PVOID *)&psKickTADumpBufferKM, 0,
3253 "Array of Kick Tile Accelerator Dump Buffer") != PVRSRV_OK)
3254 #else
3255 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
3256 ui32BufferArraySize,
3257 (IMG_PVOID *)&psKickTADumpBuffer, 0,
3258 "Array of Kick Tile Accelerator Dump Buffer") != PVRSRV_OK)
3259 #endif
3260 {
3261 return -ENOMEM;
3262 }
3264 #if !defined (SUPPORT_SID_INTERFACE)
3265 if(CopyFromUserWrapper(psPerProc,
3266 ui32BridgeID,
3267 psKickTADumpBuffer,
3268 psPDumpBufferArrayIN->psBufferArray,
3269 ui32BufferArraySize) != PVRSRV_OK)
3270 {
3271 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBuffer, 0);
3272 /*not nulling pointer, out of scope*/
3273 return -EFAULT;
3274 }
3276 #if defined (__QNXNTO__)
3277 ui32NameBufferArraySize = ui32BufferArrayLength * NAME_BUFFER_SIZE;
3278 if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, ui32NameBufferArraySize,
3279 (IMG_PVOID *)&pszNameBuffer, 0,
3280 "Kick Tile Accelerator Dump Buffer names") != PVRSRV_OK)
3281 {
3282 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBuffer, 0);
3283 return -ENOMEM;
3284 }
3286 pszName = pszNameBuffer;
3288 for (i=0; i<ui32BufferArrayLength; i++)
3289 {
3290 if (psKickTADumpBuffer[i].pszName)
3291 {
3292 ui32NameLength = psKickTADumpBuffer[i].ui32NameLength;
3293 if (ui32NameLength >= NAME_BUFFER_SIZE)
3294 {
3295 ui32NameLength = NAME_BUFFER_SIZE - 1;
3296 }
3298 if (ui32NameLength &&
3299 (CopyFromUserWrapper(psPerProc, ui32BridgeID, pszName,
3300 psKickTADumpBuffer[i].pszName, ui32NameLength + 1) == PVRSRV_OK))
3301 {
3302 pszName[NAME_BUFFER_SIZE - 1] = 0;
3303 psKickTADumpBuffer[i].pszName = pszName;
3304 pszName += NAME_BUFFER_SIZE;
3305 }
3306 else
3307 {
3308 PVR_DPF((PVR_DBG_WARNING, "Failed to read PDUMP buffer name"));
3309 psKickTADumpBuffer[i].pszName = 0;
3310 }
3311 }
3312 }
3313 #endif
3314 #endif
3316 for(i = 0; i < ui32BufferArrayLength; i++)
3317 {
3318 #if defined (SUPPORT_SID_INTERFACE)
3319 IMG_VOID *pvMemInfo = IMG_NULL;
3320 psUMPtr = &psPDumpBufferArrayIN->psBufferArray[i];
3321 psKMPtr = &psKickTADumpBufferKM[i];
3322 #else
3323 IMG_VOID *pvMemInfo;
3324 #endif
3326 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
3327 &pvMemInfo,
3328 #if defined (SUPPORT_SID_INTERFACE)
3329 psUMPtr->hKernelMemInfo,
3330 #else
3331 psKickTADumpBuffer[i].hKernelMemInfo,
3332 #endif
3333 PVRSRV_HANDLE_TYPE_MEM_INFO);
3335 if(eError != PVRSRV_OK)
3336 {
3337 PVR_DPF((PVR_DBG_ERROR, "PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY: "
3338 "PVRSRVLookupHandle failed (%d)", eError));
3339 break;
3340 }
3341 #if defined (SUPPORT_SID_INTERFACE)
3342 psKMPtr->hKernelMemInfo = pvMemInfo;
3343 #else
3344 psKickTADumpBuffer[i].hKernelMemInfo = pvMemInfo;
3345 #endif
3347 #if defined(SUPPORT_SGX_NEW_STATUS_VALS)
3348 eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
3349 &pvMemInfo,
3350 #if defined (SUPPORT_SID_INTERFACE)
3351 psUMPtr->hCtrlKernelMemInfo,
3352 #else
3353 psKickTADumpBuffer[i].hCtrlKernelMemInfo,
3354 #endif
3355 PVRSRV_HANDLE_TYPE_MEM_INFO);
3357 if(eError != PVRSRV_OK)
3358 {
3359 PVR_DPF((PVR_DBG_ERROR, "PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY: "
3360 "PVRSRVLookupHandle failed (%d)", eError));
3361 break;
3362 }
3363 #if defined (SUPPORT_SID_INTERFACE)
3364 psKMPtr->hCtrlKernelMemInfo = pvMemInfo;
3365 psKMPtr->sCtrlDevVAddr = psUMPtr->sCtrlDevVAddr;
3366 #else
3367 psKickTADumpBuffer[i].hCtrlKernelMemInfo = pvMemInfo;
3368 #endif
3369 #endif
3371 #if defined (SUPPORT_SID_INTERFACE)
3372 psKMPtr->ui32SpaceUsed = psUMPtr->ui32SpaceUsed;
3373 psKMPtr->ui32Start = psUMPtr->ui32Start;
3374 psKMPtr->ui32End = psUMPtr->ui32End;
3375 psKMPtr->ui32BufferSize = psUMPtr->ui32BufferSize;
3376 psKMPtr->ui32BackEndLength = psUMPtr->ui32BackEndLength;
3377 psKMPtr->uiAllocIndex = psUMPtr->uiAllocIndex;
3378 psKMPtr->pvLinAddr = psUMPtr->pvLinAddr;
3379 psKMPtr->pszName = psUMPtr->pszName;
3380 #endif
3381 }
3383 if(eError == PVRSRV_OK)
3384 {
3385 DumpBufferArray(psPerProc,
3386 #if defined (SUPPORT_SID_INTERFACE)
3387 psKickTADumpBufferKM,
3388 #else
3389 psKickTADumpBuffer,
3390 #endif
3391 ui32BufferArrayLength,
3392 psPDumpBufferArrayIN->bDumpPolls);
3393 }
3395 #if defined (SUPPORT_SID_INTERFACE)
3396 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBufferKM, 0);
3397 #else
3398 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBuffer, 0);
3399 #if defined (__QNXNTO__)
3400 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32NameBufferArraySize, pszNameBuffer, 0);
3401 #endif
3402 #endif
3403 /*not nulling pointer, out of scope*/
3405 return 0;
3406 }
3408 static IMG_INT
3409 SGXPDump3DSignatureRegistersBW(IMG_UINT32 ui32BridgeID,
3410 PVRSRV_BRIDGE_IN_PDUMP_3D_SIGNATURE_REGISTERS *psPDump3DSignatureRegistersIN,
3411 PVRSRV_BRIDGE_RETURN *psRetOUT,
3412 PVRSRV_PER_PROCESS_DATA *psPerProc)
3413 {
3414 IMG_UINT32 ui32RegisterArraySize = psPDump3DSignatureRegistersIN->ui32NumRegisters * sizeof(IMG_UINT32);
3415 IMG_UINT32 *pui32Registers = IMG_NULL;
3416 PVRSRV_SGXDEV_INFO *psDevInfo;
3417 #if defined(SGX_FEATURE_MP) && defined(FIX_HW_BRN_27270)
3418 IMG_UINT32 ui32RegVal = 0;
3419 #endif
3420 PVRSRV_DEVICE_NODE *psDeviceNode;
3421 IMG_HANDLE hDevMemContextInt = 0;
3422 IMG_UINT32 ui32MMUContextID;
3423 IMG_INT ret = -EFAULT;
3425 PVR_UNREFERENCED_PARAMETER(psRetOUT);
3427 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_3D_SIGNATURE_REGISTERS);
3429 if (ui32RegisterArraySize == 0)
3430 {
3431 goto ExitNoError;
3432 }
3434 psRetOUT->eError =
3435 PVRSRVLookupHandle(psPerProc->psHandleBase,
3436 (IMG_VOID**)&psDeviceNode,
3437 psPDump3DSignatureRegistersIN->hDevCookie,
3438 PVRSRV_HANDLE_TYPE_DEV_NODE);
3439 if(psRetOUT->eError != PVRSRV_OK)
3440 {
3441 PVR_DPF((PVR_DBG_ERROR, "PDumpTASignatureRegistersBW: hDevCookie lookup failed"));
3442 goto Exit;
3443 }
3445 psDevInfo = (PVRSRV_SGXDEV_INFO*)psDeviceNode->pvDevice;
3447 #if defined(SGX_FEATURE_MP) && defined(FIX_HW_BRN_27270)
3448 /* Enable all cores available */
3449 ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE);
3450 OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE, (SGX_FEATURE_MP_CORE_COUNT - 1) << EUR_CR_MASTER_CORE_ENABLE_SHIFT);
3451 #if defined(PDUMP)
3452 PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_CORE, (SGX_FEATURE_MP_CORE_COUNT - 1) << EUR_CR_MASTER_CORE_ENABLE_SHIFT,
3453 psPDump3DSignatureRegistersIN->bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0);
3454 #endif
3455 #endif
3457 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
3458 ui32RegisterArraySize,
3459 (IMG_PVOID *)&pui32Registers, 0,
3460 "Array of Registers") != PVRSRV_OK)
3461 {
3462 PVR_DPF((PVR_DBG_ERROR, "PDump3DSignatureRegistersBW: OSAllocMem failed"));
3463 goto Exit;
3464 }
3466 if(CopyFromUserWrapper(psPerProc,
3467 ui32BridgeID,
3468 pui32Registers,
3469 psPDump3DSignatureRegistersIN->pui32Registers,
3470 ui32RegisterArraySize) != PVRSRV_OK)
3471 {
3472 PVR_DPF((PVR_DBG_ERROR, "PDump3DSignatureRegistersBW: CopyFromUserWrapper failed"));
3473 goto Exit;
3474 }
3476 PDump3DSignatureRegisters(&psDeviceNode->sDevId,
3477 psPDump3DSignatureRegistersIN->ui32DumpFrameNum,
3478 psPDump3DSignatureRegistersIN->bLastFrame,
3479 pui32Registers,
3480 psPDump3DSignatureRegistersIN->ui32NumRegisters);
3482 psRetOUT->eError =
3483 PVRSRVLookupHandle( psPerProc->psHandleBase,
3484 &hDevMemContextInt,
3485 psPDump3DSignatureRegistersIN->hDevMemContext,
3486 PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
3487 if(psRetOUT->eError != PVRSRV_OK)
3488 {
3489 return 0;
3490 }
3492 /* look up the MMU context ID */
3493 PVR_ASSERT(psDeviceNode->pfnMMUGetContextID != IMG_NULL);
3494 ui32MMUContextID = psDeviceNode->pfnMMUGetContextID((IMG_HANDLE)psDeviceNode->sDevMemoryInfo.pBMKernelContext);
3496 PDumpSignatureBuffer(&psDeviceNode->sDevId,
3497 "out.tasig", "TA", 0,
3498 psDevInfo->psKernelTASigBufferMemInfo->sDevVAddr,
3499 (IMG_UINT32)psDevInfo->psKernelTASigBufferMemInfo->uAllocSize,
3500 ui32MMUContextID,
3501 0 /*ui32PDumpFlags*/);
3502 PDumpSignatureBuffer(&psDeviceNode->sDevId,
3503 "out.3dsig", "3D", 0,
3504 psDevInfo->psKernel3DSigBufferMemInfo->sDevVAddr,
3505 (IMG_UINT32)psDevInfo->psKernel3DSigBufferMemInfo->uAllocSize,
3506 ui32MMUContextID,
3507 0 /*ui32PDumpFlags*/);
3509 ExitNoError:
3510 psRetOUT->eError = PVRSRV_OK;
3511 ret = 0;
3512 Exit:
3513 if (pui32Registers != IMG_NULL)
3514 {
3515 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32RegisterArraySize, pui32Registers, 0);
3516 }
3518 #if defined(SGX_FEATURE_MP) && defined(FIX_HW_BRN_27270)
3519 if (psDevInfo != IMG_NULL)
3520 {
3521 OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE, ui32RegVal);
3522 #if defined(PDUMP)
3523 PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_CORE, ui32RegVal,
3524 psPDump3DSignatureRegistersIN->bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0);
3525 #endif
3526 }
3527 #endif
3529 return ret;
3530 }
3532 static IMG_INT
3533 SGXPDumpCounterRegistersBW(IMG_UINT32 ui32BridgeID,
3534 PVRSRV_BRIDGE_IN_PDUMP_COUNTER_REGISTERS *psPDumpCounterRegistersIN,
3535 IMG_VOID *psBridgeOut,
3536 PVRSRV_PER_PROCESS_DATA *psPerProc)
3537 {
3538 IMG_UINT32 ui32RegisterArraySize = psPDumpCounterRegistersIN->ui32NumRegisters * sizeof(IMG_UINT32);
3539 IMG_UINT32 *pui32Registers = IMG_NULL;
3540 PVRSRV_DEVICE_NODE *psDeviceNode ;
3541 IMG_INT ret = -EFAULT;
3543 PVR_UNREFERENCED_PARAMETER(psBridgeOut);
3545 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_COUNTER_REGISTERS);
3547 if (ui32RegisterArraySize == 0)
3548 {
3549 goto ExitNoError;
3550 }
3552 if(PVRSRVLookupHandle(psPerProc->psHandleBase,
3553 (IMG_VOID**)&psDeviceNode,
3554 psPDumpCounterRegistersIN->hDevCookie,
3555 PVRSRV_HANDLE_TYPE_DEV_NODE) != PVRSRV_OK)
3556 {
3557 PVR_DPF((PVR_DBG_ERROR, "SGXPDumpCounterRegistersBW: hDevCookie lookup failed"));
3558 ret = -ENOMEM;
3559 goto Exit;
3560 }
3562 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
3563 ui32RegisterArraySize,
3564 (IMG_PVOID *)&pui32Registers, 0,
3565 "Array of Registers") != PVRSRV_OK)
3566 {
3567 PVR_DPF((PVR_DBG_ERROR, "PDumpCounterRegistersBW: OSAllocMem failed"));
3568 ret = -ENOMEM;
3569 goto Exit;
3570 }
3572 if(CopyFromUserWrapper(psPerProc,
3573 ui32BridgeID,
3574 pui32Registers,
3575 psPDumpCounterRegistersIN->pui32Registers,
3576 ui32RegisterArraySize) != PVRSRV_OK)
3577 {
3578 PVR_DPF((PVR_DBG_ERROR, "PDumpCounterRegistersBW: CopyFromUserWrapper failed"));
3579 goto Exit;
3580 }
3582 PDumpCounterRegisters(&psDeviceNode->sDevId,
3583 psPDumpCounterRegistersIN->ui32DumpFrameNum,
3584 psPDumpCounterRegistersIN->bLastFrame,
3585 pui32Registers,
3586 psPDumpCounterRegistersIN->ui32NumRegisters);
3588 ExitNoError:
3589 ret = 0;
3590 Exit:
3591 if (pui32Registers != IMG_NULL)
3592 {
3593 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32RegisterArraySize, pui32Registers, 0);
3594 }
3596 return ret;
3597 }
3599 static IMG_INT
3600 SGXPDumpTASignatureRegistersBW(IMG_UINT32 ui32BridgeID,
3601 PVRSRV_BRIDGE_IN_PDUMP_TA_SIGNATURE_REGISTERS *psPDumpTASignatureRegistersIN,
3602 PVRSRV_BRIDGE_RETURN *psRetOUT,
3603 PVRSRV_PER_PROCESS_DATA *psPerProc)
3604 {
3605 IMG_UINT32 ui32RegisterArraySize = psPDumpTASignatureRegistersIN->ui32NumRegisters * sizeof(IMG_UINT32);
3606 IMG_UINT32 *pui32Registers = IMG_NULL;
3607 #if defined(SGX_FEATURE_MP) && defined(FIX_HW_BRN_27270)
3608 PVRSRV_SGXDEV_INFO *psDevInfo = IMG_NULL;
3609 IMG_UINT32 ui32RegVal = 0;
3610 #endif
3611 PVRSRV_DEVICE_NODE *psDeviceNode;
3612 IMG_INT ret = -EFAULT;
3614 PVR_UNREFERENCED_PARAMETER(psRetOUT);
3616 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_TA_SIGNATURE_REGISTERS);
3618 if (ui32RegisterArraySize == 0)
3619 {
3620 goto ExitNoError;
3621 }
3623 psRetOUT->eError =
3624 PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID**)&psDeviceNode,
3625 psPDumpTASignatureRegistersIN->hDevCookie,
3626 PVRSRV_HANDLE_TYPE_DEV_NODE);
3627 if(psRetOUT->eError != PVRSRV_OK)
3628 {
3629 PVR_DPF((PVR_DBG_ERROR, "PDumpTASignatureRegistersBW: hDevCookie lookup failed"));
3630 goto Exit;
3631 }
3633 #if defined(SGX_FEATURE_MP) && defined(FIX_HW_BRN_27270)
3635 psDevInfo = (PVRSRV_SGXDEV_INFO*)psDeviceNode->pvDevice;
3637 /* Enable all cores available */
3638 ui32RegVal = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE);
3639 OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE, (SGX_FEATURE_MP_CORE_COUNT - 1) << EUR_CR_MASTER_CORE_ENABLE_SHIFT);
3640 #if defined(PDUMP)
3641 PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_CORE, (SGX_FEATURE_MP_CORE_COUNT - 1) << EUR_CR_MASTER_CORE_ENABLE_SHIFT,
3642 psPDumpTASignatureRegistersIN->bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0);
3643 #endif
3644 #endif
3646 if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
3647 ui32RegisterArraySize,
3648 (IMG_PVOID *)&pui32Registers, 0,
3649 "Array of Registers") != PVRSRV_OK)
3650 {
3651 PVR_DPF((PVR_DBG_ERROR, "PDumpTASignatureRegistersBW: OSAllocMem failed"));
3652 ret = -ENOMEM;
3653 goto Exit;
3654 }
3656 if(CopyFromUserWrapper(psPerProc,
3657 ui32BridgeID,
3658 pui32Registers,
3659 psPDumpTASignatureRegistersIN->pui32Registers,
3660 ui32RegisterArraySize) != PVRSRV_OK)
3661 {
3662 PVR_DPF((PVR_DBG_ERROR, "PDumpTASignatureRegistersBW: CopyFromUserWrapper failed"));
3663 goto Exit;
3664 }
3666 PDumpTASignatureRegisters(&psDeviceNode->sDevId,
3667 psPDumpTASignatureRegistersIN->ui32DumpFrameNum,
3668 psPDumpTASignatureRegistersIN->ui32TAKickCount,
3669 psPDumpTASignatureRegistersIN->bLastFrame,
3670 pui32Registers,
3671 psPDumpTASignatureRegistersIN->ui32NumRegisters);
3673 ExitNoError:
3674 psRetOUT->eError = PVRSRV_OK;
3675 ret = 0;
3676 Exit:
3677 if (pui32Registers != IMG_NULL)
3678 {
3679 OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32RegisterArraySize, pui32Registers, 0);
3680 }
3682 #if defined(SGX_FEATURE_MP) && defined(FIX_HW_BRN_27270)
3683 if (psDevInfo != IMG_NULL)
3684 {
3685 OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE, ui32RegVal);
3686 #if defined(PDUMP)
3687 PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_CORE, ui32RegVal,
3688 psPDumpTASignatureRegistersIN->bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0);
3689 #endif
3690 }
3691 #endif
3693 return ret;
3694 }
3695 //PRQA S 5120--
3698 static IMG_INT
3699 SGXPDumpHWPerfCBBW(IMG_UINT32 ui32BridgeID,
3700 PVRSRV_BRIDGE_IN_PDUMP_HWPERFCB *psPDumpHWPerfCBIN,
3701 PVRSRV_BRIDGE_RETURN *psRetOUT,
3702 PVRSRV_PER_PROCESS_DATA *psPerProc)
3703 {
3704 #if defined(SUPPORT_SGX_HWPERF)
3705 #if defined(__linux__)
3706 PVRSRV_SGXDEV_INFO *psDevInfo;
3707 PVRSRV_DEVICE_NODE *psDeviceNode;
3708 IMG_HANDLE hDevMemContextInt = 0;
3709 IMG_UINT32 ui32MMUContextID = 0;
3711 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_HWPERFCB);
3713 psRetOUT->eError =
3714 PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID**)&psDeviceNode,
3715 psPDumpHWPerfCBIN->hDevCookie,
3716 PVRSRV_HANDLE_TYPE_DEV_NODE);
3717 if(psRetOUT->eError != PVRSRV_OK)
3718 {
3719 return 0;
3720 }
3722 psDevInfo = psDeviceNode->pvDevice;
3724 psRetOUT->eError =
3725 PVRSRVLookupHandle( psPerProc->psHandleBase,
3726 &hDevMemContextInt,
3727 psPDumpHWPerfCBIN->hDevMemContext,
3728 PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
3729 if(psRetOUT->eError != PVRSRV_OK)
3730 {
3731 return 0;
3732 }
3734 /* look up the MMU context ID */
3735 PVR_ASSERT(psDeviceNode->pfnMMUGetContextID != IMG_NULL);
3736 ui32MMUContextID = psDeviceNode->pfnMMUGetContextID(hDevMemContextInt);
3738 PDumpHWPerfCBKM(&psDeviceNode->sDevId,
3739 &psPDumpHWPerfCBIN->szFileName[0],
3740 psPDumpHWPerfCBIN->ui32FileOffset,
3741 psDevInfo->psKernelHWPerfCBMemInfo->sDevVAddr,
3742 psDevInfo->psKernelHWPerfCBMemInfo->uAllocSize,
3743 ui32MMUContextID,
3744 psPDumpHWPerfCBIN->ui32PDumpFlags);
3746 return 0;
3747 #else
3748 PVR_UNREFERENCED_PARAMETER(ui32BridgeID);
3749 PVR_UNREFERENCED_PARAMETER(psPDumpHWPerfCBIN);
3750 PVR_UNREFERENCED_PARAMETER(psRetOUT);
3751 PVR_UNREFERENCED_PARAMETER(psPerProc);
3752 return 0;
3753 #endif
3754 #else
3755 PVR_UNREFERENCED_PARAMETER(ui32BridgeID);
3756 PVR_UNREFERENCED_PARAMETER(psPDumpHWPerfCBIN);
3757 PVR_UNREFERENCED_PARAMETER(psRetOUT);
3758 PVR_UNREFERENCED_PARAMETER(psPerProc);
3759 return -EFAULT;
3760 #endif /* defined(SUPPORT_SGX_HWPERF) */
3761 }
3764 static IMG_INT
3765 SGXPDumpSaveMemBW(IMG_UINT32 ui32BridgeID,
3766 PVRSRV_BRIDGE_IN_PDUMP_SAVEMEM *psPDumpSaveMem,
3767 PVRSRV_BRIDGE_RETURN *psRetOUT,
3768 PVRSRV_PER_PROCESS_DATA *psPerProc)
3769 {
3770 PVRSRV_DEVICE_NODE *psDeviceNode;
3771 IMG_HANDLE hDevMemContextInt = 0;
3772 IMG_UINT32 ui32MMUContextID;
3774 PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_SAVEMEM);
3776 psRetOUT->eError =
3777 PVRSRVLookupHandle(psPerProc->psHandleBase,
3778 (IMG_VOID**)&psDeviceNode,
3779 psPDumpSaveMem->hDevCookie,
3780 PVRSRV_HANDLE_TYPE_DEV_NODE);
3781 if(psRetOUT->eError != PVRSRV_OK)
3782 {
3783 return 0;
3784 }
3786 psRetOUT->eError =
3787 PVRSRVLookupHandle( psPerProc->psHandleBase,
3788 &hDevMemContextInt,
3789 psPDumpSaveMem->hDevMemContext,
3790 PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
3791 if(psRetOUT->eError != PVRSRV_OK)
3792 {
3793 return 0;
3794 }
3796 /* look up the MMU context ID */
3797 PVR_ASSERT(psDeviceNode->pfnMMUGetContextID != IMG_NULL);
3798 ui32MMUContextID = psDeviceNode->pfnMMUGetContextID(hDevMemContextInt);
3800 PDumpSaveMemKM(&psDeviceNode->sDevId,
3801 &psPDumpSaveMem->szFileName[0],
3802 psPDumpSaveMem->ui32FileOffset,
3803 psPDumpSaveMem->sDevVAddr,
3804 psPDumpSaveMem->ui32Size,
3805 ui32MMUContextID,
3806 psPDumpSaveMem->ui32PDumpFlags);
3807 return 0;
3808 }
3810 #endif /* PDUMP */
3813 /* PRQA S 0313,3635 END_SET_SGX */ /* function macro required this format */
3814 IMG_VOID SetSGXDispatchTableEntry(IMG_VOID)
3815 {
3817 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETCLIENTINFO, SGXGetClientInfoBW);
3818 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_RELEASECLIENTINFO, SGXReleaseClientInfoBW);
3819 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETINTERNALDEVINFO, SGXGetInternalDevInfoBW);
3820 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_DOKICK, SGXDoKickBW);
3821 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETPHYSPAGEADDR, DummyBW);
3822 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_READREGISTRYDWORD, DummyBW);
3824 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_2DQUERYBLTSCOMPLETE, SGX2DQueryBlitsCompleteBW);
3826 #if defined(TRANSFER_QUEUE)
3827 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SUBMITTRANSFER, SGXSubmitTransferBW);
3828 #endif
3829 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETMISCINFO, SGXGetMiscInfoBW);
3830 SetDispatchTableEntry(PVRSRV_BRIDGE_SGXINFO_FOR_SRVINIT , SGXGetInfoForSrvinitBW);
3831 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_DEVINITPART2, SGXDevInitPart2BW);
3833 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC, SGXFindSharedPBDescBW);
3834 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_UNREFSHAREDPBDESC, SGXUnrefSharedPBDescBW);
3835 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC, SGXAddSharedPBDescBW);
3836 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_REGISTER_HW_RENDER_CONTEXT, SGXRegisterHWRenderContextBW);
3837 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_FLUSH_HW_RENDER_TARGET, SGXFlushHWRenderTargetBW);
3838 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_UNREGISTER_HW_RENDER_CONTEXT, SGXUnregisterHWRenderContextBW);
3839 #if defined(SGX_FEATURE_2D_HARDWARE)
3840 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SUBMIT2D, SGXSubmit2DBW);
3841 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_REGISTER_HW_2D_CONTEXT, SGXRegisterHW2DContextBW);
3842 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_UNREGISTER_HW_2D_CONTEXT, SGXUnregisterHW2DContextBW);
3843 #endif
3844 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_REGISTER_HW_TRANSFER_CONTEXT, SGXRegisterHWTransferContextBW);
3845 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_UNREGISTER_HW_TRANSFER_CONTEXT, SGXUnregisterHWTransferContextBW);
3847 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SCHEDULE_PROCESS_QUEUES, SGXScheduleProcessQueuesBW);
3849 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_READ_HWPERF_CB, SGXReadHWPerfCBBW);
3850 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SET_RENDER_CONTEXT_PRIORITY, SGXSetRenderContextPriorityBW);
3851 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SET_TRANSFER_CONTEXT_PRIORITY, SGXSetTransferContextPriorityBW);
3853 #if defined(PDUMP)
3854 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY, SGXPDumpBufferArrayBW);
3855 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_3D_SIGNATURE_REGISTERS, SGXPDump3DSignatureRegistersBW);
3856 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_COUNTER_REGISTERS, SGXPDumpCounterRegistersBW);
3857 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_TA_SIGNATURE_REGISTERS, SGXPDumpTASignatureRegistersBW);
3858 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_HWPERFCB, SGXPDumpHWPerfCBBW);
3859 SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_SAVEMEM, SGXPDumpSaveMemBW);
3860 #endif
3861 }
3862 /* PRQA L:END_SET_SGX */ /* end of setup overrides */
3864 #endif /* SUPPORT_SGX */