static IMG_INT PVRSRVBridgeAcquireDeviceData(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_ACQUIREDEVICEDATA *psAcquireDeviceDataIN, PVRSRV_BRIDGE_OUT_ACQUIREDEVICEDATA *psAcquireDeviceDataOUT, CONNECTION_DATA *psConnection) { IMG_HANDLE hDevCookieInt = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SRVCORE_ACQUIREDEVICEDATA); psAcquireDeviceDataOUT->eError = PVRSRVAcquireDeviceDataKM( psAcquireDeviceDataIN->ui32DevIndex, psAcquireDeviceDataIN->eDeviceType, &hDevCookieInt); /* Exit early if bridged call fails */ if(psAcquireDeviceDataOUT->eError != PVRSRV_OK) { goto AcquireDeviceData_exit; } psAcquireDeviceDataOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psAcquireDeviceDataOUT->hDevCookie, (IMG_HANDLE) hDevCookieInt, PVRSRV_HANDLE_TYPE_DEV_NODE, PVRSRV_HANDLE_ALLOC_FLAG_SHARED ); if (psAcquireDeviceDataOUT->eError != PVRSRV_OK) { goto AcquireDeviceData_exit; } AcquireDeviceData_exit: if (psAcquireDeviceDataOUT->eError != PVRSRV_OK) { } return 0; }
static IMG_INT PVRSRVBridgeSyncPrimOpCreate(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_SYNCPRIMOPCREATE *psSyncPrimOpCreateIN, PVRSRV_BRIDGE_OUT_SYNCPRIMOPCREATE *psSyncPrimOpCreateOUT, CONNECTION_DATA *psConnection) { SYNC_PRIMITIVE_BLOCK * *psBlockListInt = IMG_NULL; IMG_HANDLE *hBlockListInt2 = IMG_NULL; IMG_UINT32 *ui32SyncBlockIndexInt = IMG_NULL; IMG_UINT32 *ui32IndexInt = IMG_NULL; SERVER_SYNC_PRIMITIVE * *psServerSyncInt = IMG_NULL; IMG_HANDLE *hServerSyncInt2 = IMG_NULL; SERVER_OP_COOKIE * psServerCookieInt = IMG_NULL; IMG_HANDLE hServerCookieInt2 = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_SYNCPRIMOPCREATE); if (psSyncPrimOpCreateIN->ui32SyncBlockCount != 0) { psBlockListInt = OSAllocMem(psSyncPrimOpCreateIN->ui32SyncBlockCount * sizeof(SYNC_PRIMITIVE_BLOCK *)); if (!psBlockListInt) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto SyncPrimOpCreate_exit; } hBlockListInt2 = OSAllocMem(psSyncPrimOpCreateIN->ui32SyncBlockCount * sizeof(IMG_HANDLE)); if (!hBlockListInt2) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto SyncPrimOpCreate_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psSyncPrimOpCreateIN->phBlockList, psSyncPrimOpCreateIN->ui32SyncBlockCount * sizeof(IMG_HANDLE)) || (OSCopyFromUser(NULL, hBlockListInt2, psSyncPrimOpCreateIN->phBlockList, psSyncPrimOpCreateIN->ui32SyncBlockCount * sizeof(IMG_HANDLE)) != PVRSRV_OK) ) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto SyncPrimOpCreate_exit; } if (psSyncPrimOpCreateIN->ui32ClientSyncCount != 0) { ui32SyncBlockIndexInt = OSAllocMem(psSyncPrimOpCreateIN->ui32ClientSyncCount * sizeof(IMG_UINT32)); if (!ui32SyncBlockIndexInt) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto SyncPrimOpCreate_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psSyncPrimOpCreateIN->pui32SyncBlockIndex, psSyncPrimOpCreateIN->ui32ClientSyncCount * sizeof(IMG_UINT32)) || (OSCopyFromUser(NULL, ui32SyncBlockIndexInt, psSyncPrimOpCreateIN->pui32SyncBlockIndex, psSyncPrimOpCreateIN->ui32ClientSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK) ) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto SyncPrimOpCreate_exit; } if (psSyncPrimOpCreateIN->ui32ClientSyncCount != 0) { ui32IndexInt = OSAllocMem(psSyncPrimOpCreateIN->ui32ClientSyncCount * sizeof(IMG_UINT32)); if (!ui32IndexInt) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto SyncPrimOpCreate_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psSyncPrimOpCreateIN->pui32Index, psSyncPrimOpCreateIN->ui32ClientSyncCount * sizeof(IMG_UINT32)) || (OSCopyFromUser(NULL, ui32IndexInt, psSyncPrimOpCreateIN->pui32Index, psSyncPrimOpCreateIN->ui32ClientSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK) ) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto SyncPrimOpCreate_exit; } if (psSyncPrimOpCreateIN->ui32ServerSyncCount != 0) { psServerSyncInt = OSAllocMem(psSyncPrimOpCreateIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *)); if (!psServerSyncInt) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto SyncPrimOpCreate_exit; } hServerSyncInt2 = OSAllocMem(psSyncPrimOpCreateIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)); if (!hServerSyncInt2) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto SyncPrimOpCreate_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psSyncPrimOpCreateIN->phServerSync, psSyncPrimOpCreateIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) || (OSCopyFromUser(NULL, hServerSyncInt2, psSyncPrimOpCreateIN->phServerSync, psSyncPrimOpCreateIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK) ) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto SyncPrimOpCreate_exit; } { IMG_UINT32 i; for (i=0;i<psSyncPrimOpCreateIN->ui32SyncBlockCount;i++) { { /* Look up the address from the handle */ psSyncPrimOpCreateOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hBlockListInt2[i], psSyncPrimOpCreateIN->phBlockList[i], PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK); if(psSyncPrimOpCreateOUT->eError != PVRSRV_OK) { goto SyncPrimOpCreate_exit; } /* Look up the data from the resman address */ psSyncPrimOpCreateOUT->eError = ResManFindPrivateDataByPtr(hBlockListInt2[i], (IMG_VOID **) &psBlockListInt[i]); if(psSyncPrimOpCreateOUT->eError != PVRSRV_OK) { goto SyncPrimOpCreate_exit; } } } } { IMG_UINT32 i; for (i=0;i<psSyncPrimOpCreateIN->ui32ServerSyncCount;i++) { { /* Look up the address from the handle */ psSyncPrimOpCreateOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hServerSyncInt2[i], psSyncPrimOpCreateIN->phServerSync[i], PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE); if(psSyncPrimOpCreateOUT->eError != PVRSRV_OK) { goto SyncPrimOpCreate_exit; } /* Look up the data from the resman address */ psSyncPrimOpCreateOUT->eError = ResManFindPrivateDataByPtr(hServerSyncInt2[i], (IMG_VOID **) &psServerSyncInt[i]); if(psSyncPrimOpCreateOUT->eError != PVRSRV_OK) { goto SyncPrimOpCreate_exit; } } } } psSyncPrimOpCreateOUT->eError = PVRSRVSyncPrimOpCreateKM( psSyncPrimOpCreateIN->ui32SyncBlockCount, psBlockListInt, psSyncPrimOpCreateIN->ui32ClientSyncCount, ui32SyncBlockIndexInt, ui32IndexInt, psSyncPrimOpCreateIN->ui32ServerSyncCount, psServerSyncInt, &psServerCookieInt); /* Exit early if bridged call fails */ if(psSyncPrimOpCreateOUT->eError != PVRSRV_OK) { goto SyncPrimOpCreate_exit; } /* Create a resman item and overwrite the handle with it */ hServerCookieInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_SERVER_OP_COOKIE, psServerCookieInt, /* FIXME: how can we avoid this cast? */ (RESMAN_FREE_FN)&PVRSRVSyncPrimOpDestroyKM); if (hServerCookieInt2 == IMG_NULL) { psSyncPrimOpCreateOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto SyncPrimOpCreate_exit; } psSyncPrimOpCreateOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psSyncPrimOpCreateOUT->hServerCookie, (IMG_HANDLE) hServerCookieInt2, PVRSRV_HANDLE_TYPE_SERVER_OP_COOKIE, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); if (psSyncPrimOpCreateOUT->eError != PVRSRV_OK) { goto SyncPrimOpCreate_exit; } SyncPrimOpCreate_exit: if (psSyncPrimOpCreateOUT->eError != PVRSRV_OK) { /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hServerCookieInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hServerCookieInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (psServerCookieInt) { PVRSRVSyncPrimOpDestroyKM(psServerCookieInt); } } if (psBlockListInt) OSFreeMem(psBlockListInt); if (hBlockListInt2) OSFreeMem(hBlockListInt2); if (ui32SyncBlockIndexInt) OSFreeMem(ui32SyncBlockIndexInt); if (ui32IndexInt) OSFreeMem(ui32IndexInt); if (psServerSyncInt) OSFreeMem(psServerSyncInt); if (hServerSyncInt2) OSFreeMem(hServerSyncInt2); return 0; }
static IMG_INT PVRSRVBridgeServerSyncAlloc(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_SERVERSYNCALLOC *psServerSyncAllocIN, PVRSRV_BRIDGE_OUT_SERVERSYNCALLOC *psServerSyncAllocOUT, CONNECTION_DATA *psConnection) { IMG_HANDLE hDevNodeInt = IMG_NULL; SERVER_SYNC_PRIMITIVE * psSyncHandleInt = IMG_NULL; IMG_HANDLE hSyncHandleInt2 = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_SERVERSYNCALLOC); { /* Look up the address from the handle */ psServerSyncAllocOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hDevNodeInt, psServerSyncAllocIN->hDevNode, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psServerSyncAllocOUT->eError != PVRSRV_OK) { goto ServerSyncAlloc_exit; } } psServerSyncAllocOUT->eError = PVRSRVServerSyncAllocKM( hDevNodeInt, &psSyncHandleInt, &psServerSyncAllocOUT->ui32SyncPrimVAddr); /* Exit early if bridged call fails */ if(psServerSyncAllocOUT->eError != PVRSRV_OK) { goto ServerSyncAlloc_exit; } /* Create a resman item and overwrite the handle with it */ hSyncHandleInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_SERVER_SYNC_PRIMITIVE, psSyncHandleInt, /* FIXME: how can we avoid this cast? */ (RESMAN_FREE_FN)&PVRSRVServerSyncFreeKM); if (hSyncHandleInt2 == IMG_NULL) { psServerSyncAllocOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto ServerSyncAlloc_exit; } psServerSyncAllocOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psServerSyncAllocOUT->hSyncHandle, (IMG_HANDLE) hSyncHandleInt2, PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); if (psServerSyncAllocOUT->eError != PVRSRV_OK) { goto ServerSyncAlloc_exit; } ServerSyncAlloc_exit: if (psServerSyncAllocOUT->eError != PVRSRV_OK) { /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hSyncHandleInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hSyncHandleInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (psSyncHandleInt) { PVRSRVServerSyncFreeKM(psSyncHandleInt); } } return 0; }
static IMG_INT PVRSRVBridgeAllocSyncPrimitiveBlock(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_ALLOCSYNCPRIMITIVEBLOCK *psAllocSyncPrimitiveBlockIN, PVRSRV_BRIDGE_OUT_ALLOCSYNCPRIMITIVEBLOCK *psAllocSyncPrimitiveBlockOUT, CONNECTION_DATA *psConnection) { IMG_HANDLE hDevNodeInt = IMG_NULL; SYNC_PRIMITIVE_BLOCK * psSyncHandleInt = IMG_NULL; IMG_HANDLE hSyncHandleInt2 = IMG_NULL; DEVMEM_EXPORTCOOKIE * psExportCookieInt = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_ALLOCSYNCPRIMITIVEBLOCK); psAllocSyncPrimitiveBlockOUT->hSyncHandle = IMG_NULL; { /* Look up the address from the handle */ psAllocSyncPrimitiveBlockOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hDevNodeInt, psAllocSyncPrimitiveBlockIN->hDevNode, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psAllocSyncPrimitiveBlockOUT->eError != PVRSRV_OK) { goto AllocSyncPrimitiveBlock_exit; } } psAllocSyncPrimitiveBlockOUT->eError = PVRSRVAllocSyncPrimitiveBlockKM(psConnection, hDevNodeInt, &psSyncHandleInt, &psAllocSyncPrimitiveBlockOUT->ui32SyncPrimVAddr, &psAllocSyncPrimitiveBlockOUT->ui32SyncPrimBlockSize, &psExportCookieInt); /* Exit early if bridged call fails */ if(psAllocSyncPrimitiveBlockOUT->eError != PVRSRV_OK) { goto AllocSyncPrimitiveBlock_exit; } /* Create a resman item and overwrite the handle with it */ hSyncHandleInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_SYNC_PRIMITIVE_BLOCK, psSyncHandleInt, /* FIXME: how can we avoid this cast? */ (RESMAN_FREE_FN)&PVRSRVFreeSyncPrimitiveBlockKM); if (hSyncHandleInt2 == IMG_NULL) { psAllocSyncPrimitiveBlockOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto AllocSyncPrimitiveBlock_exit; } psAllocSyncPrimitiveBlockOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psAllocSyncPrimitiveBlockOUT->hSyncHandle, (IMG_HANDLE) hSyncHandleInt2, PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); if (psAllocSyncPrimitiveBlockOUT->eError != PVRSRV_OK) { goto AllocSyncPrimitiveBlock_exit; } psAllocSyncPrimitiveBlockOUT->eError = PVRSRVAllocSubHandle(psConnection->psHandleBase, &psAllocSyncPrimitiveBlockOUT->hExportCookie, (IMG_HANDLE) psExportCookieInt, PVRSRV_HANDLE_TYPE_SERVER_EXPORTCOOKIE, PVRSRV_HANDLE_ALLOC_FLAG_NONE ,psAllocSyncPrimitiveBlockOUT->hSyncHandle); if (psAllocSyncPrimitiveBlockOUT->eError != PVRSRV_OK) { goto AllocSyncPrimitiveBlock_exit; } AllocSyncPrimitiveBlock_exit: if (psAllocSyncPrimitiveBlockOUT->eError != PVRSRV_OK) { if (psAllocSyncPrimitiveBlockOUT->hSyncHandle) { PVRSRVReleaseHandle(psConnection->psHandleBase, (IMG_HANDLE) psAllocSyncPrimitiveBlockOUT->hSyncHandle, PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK); } /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hSyncHandleInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hSyncHandleInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (psSyncHandleInt) { PVRSRVFreeSyncPrimitiveBlockKM(psSyncHandleInt); } } return 0; }
/*! ****************************************************************************** @Function PVRSRVPerProcessDataConnect @Description Allocate per-process data area, or increment refcount if one already exists for this PID. @Input ui32PID - process ID ppsPerProc - Pointer to per-process data area @Return PVRSRV_ERROR ******************************************************************************/ PVRSRV_ERROR PVRSRVPerProcessDataConnect(IMG_UINT32 ui32PID, IMG_UINT32 ui32Flags) { PVRSRV_PER_PROCESS_DATA *psPerProc; IMG_HANDLE hBlockAlloc; PVRSRV_ERROR eError = PVRSRV_OK; if (psHashTab == IMG_NULL) { return PVRSRV_ERROR_INIT_FAILURE; } /* Look for existing per-process data area */ psPerProc = (PVRSRV_PER_PROCESS_DATA *)HASH_Retrieve(psHashTab, (IMG_UINTPTR_T)ui32PID); if (psPerProc == IMG_NULL) { /* Allocate per-process data area */ eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(*psPerProc), (IMG_PVOID *)&psPerProc, &hBlockAlloc, "Per Process Data"); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't allocate per-process data (%d)", eError)); return eError; } OSMemSet(psPerProc, 0, sizeof(*psPerProc)); psPerProc->hBlockAlloc = hBlockAlloc; if (!HASH_Insert(psHashTab, (IMG_UINTPTR_T)ui32PID, (IMG_UINTPTR_T)psPerProc)) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't insert per-process data into hash table")); eError = PVRSRV_ERROR_INSERT_HASH_TABLE_DATA_FAILED; goto failure; } psPerProc->ui32PID = ui32PID; psPerProc->ui32RefCount = 0; #if defined(SUPPORT_PDUMP_MULTI_PROCESS) if (ui32Flags == SRV_FLAGS_PDUMP_ACTIVE) { psPerProc->bPDumpActive = IMG_TRUE; } #else PVR_UNREFERENCED_PARAMETER(ui32Flags); #endif /* Call environment specific per process init function */ eError = OSPerProcessPrivateDataInit(&psPerProc->hOsPrivateData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: OSPerProcessPrivateDataInit failed (%d)", eError)); goto failure; } /* Allocate a handle for the per-process data area */ eError = PVRSRVAllocHandle(KERNEL_HANDLE_BASE, &psPerProc->hPerProcData, psPerProc, PVRSRV_HANDLE_TYPE_PERPROC_DATA, PVRSRV_HANDLE_ALLOC_FLAG_NONE); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't allocate handle for per-process data (%d)", eError)); goto failure; } /* Allocate handle base for this process */ eError = PVRSRVAllocHandleBase(&psPerProc->psHandleBase); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't allocate handle base for process (%d)", eError)); goto failure; } /* Set per-process handle options */ eError = OSPerProcessSetHandleOptions(psPerProc->psHandleBase); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't set handle options (%d)", eError)); goto failure; } /* Create a resource manager context for the process */ eError = PVRSRVResManConnect(psPerProc, &psPerProc->hResManContext); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't register with the resource manager")); goto failure; } #if defined (TTRACE) PVRSRVTimeTraceBufferCreate(ui32PID); #endif } psPerProc->ui32RefCount++; PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVPerProcessDataConnect: Process 0x%x has ref-count %d", ui32PID, psPerProc->ui32RefCount)); return eError; failure: (IMG_VOID)FreePerProcessData(psPerProc); return eError; }
static IMG_INT PVRSRVBridgeTLOpenStream(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_TLOPENSTREAM *psTLOpenStreamIN, PVRSRV_BRIDGE_OUT_TLOPENSTREAM *psTLOpenStreamOUT, CONNECTION_DATA *psConnection) { IMG_CHAR *uiNameInt = IMG_NULL; TL_STREAM_DESC * psSDInt = IMG_NULL; IMG_HANDLE hSDInt2 = IMG_NULL; DEVMEM_EXPORTCOOKIE * psClientBUFExportCookieInt = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PVRTL_TLOPENSTREAM); psTLOpenStreamOUT->hSD = IMG_NULL; { uiNameInt = OSAllocMem(PRVSRVTL_MAX_STREAM_NAME_SIZE * sizeof(IMG_CHAR)); if (!uiNameInt) { psTLOpenStreamOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto TLOpenStream_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psTLOpenStreamIN->puiName, PRVSRVTL_MAX_STREAM_NAME_SIZE * sizeof(IMG_CHAR)) || (OSCopyFromUser(NULL, uiNameInt, psTLOpenStreamIN->puiName, PRVSRVTL_MAX_STREAM_NAME_SIZE * sizeof(IMG_CHAR)) != PVRSRV_OK) ) { psTLOpenStreamOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto TLOpenStream_exit; } psTLOpenStreamOUT->eError = TLServerOpenStreamKM( uiNameInt, psTLOpenStreamIN->ui32Mode, &psSDInt, &psClientBUFExportCookieInt); /* Exit early if bridged call fails */ if(psTLOpenStreamOUT->eError != PVRSRV_OK) { goto TLOpenStream_exit; } /* Create a resman item and overwrite the handle with it */ hSDInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_TL_STREAM_DESC, psSDInt, /* FIXME: how can we avoid this cast? */ (RESMAN_FREE_FN)&TLServerCloseStreamKM); if (hSDInt2 == IMG_NULL) { psTLOpenStreamOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto TLOpenStream_exit; } psTLOpenStreamOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psTLOpenStreamOUT->hSD, (IMG_HANDLE) hSDInt2, PVRSRV_HANDLE_TYPE_PVR_TL_SD, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); if (psTLOpenStreamOUT->eError != PVRSRV_OK) { goto TLOpenStream_exit; } psTLOpenStreamOUT->eError = PVRSRVAllocSubHandle(psConnection->psHandleBase, &psTLOpenStreamOUT->hClientBUFExportCookie, (IMG_HANDLE) psClientBUFExportCookieInt, PVRSRV_HANDLE_TYPE_SERVER_EXPORTCOOKIE, PVRSRV_HANDLE_ALLOC_FLAG_NONE ,psTLOpenStreamOUT->hSD); if (psTLOpenStreamOUT->eError != PVRSRV_OK) { goto TLOpenStream_exit; } TLOpenStream_exit: if (psTLOpenStreamOUT->eError != PVRSRV_OK) { if (psTLOpenStreamOUT->hSD) { PVRSRVReleaseHandle(psConnection->psHandleBase, (IMG_HANDLE) psTLOpenStreamOUT->hSD, PVRSRV_HANDLE_TYPE_PVR_TL_SD); } /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hSDInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hSDInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (psSDInt) { TLServerCloseStreamKM(psSDInt); } } if (uiNameInt) OSFreeMem(uiNameInt); return 0; }
static IMG_INT PVRSRVBridgeRGXCreateComputeContext(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_RGXCREATECOMPUTECONTEXT *psRGXCreateComputeContextIN, PVRSRV_BRIDGE_OUT_RGXCREATECOMPUTECONTEXT *psRGXCreateComputeContextOUT, CONNECTION_DATA *psConnection) { IMG_HANDLE hDevNodeInt = IMG_NULL; IMG_BYTE *psFrameworkCmdInt = IMG_NULL; IMG_HANDLE hPrivDataInt = IMG_NULL; RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = IMG_NULL; IMG_HANDLE hComputeContextInt2 = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_RGXCMP_RGXCREATECOMPUTECONTEXT); if (psRGXCreateComputeContextIN->ui32FrameworkCmdize != 0) { psFrameworkCmdInt = OSAllocMem(psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)); if (!psFrameworkCmdInt) { psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto RGXCreateComputeContext_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXCreateComputeContextIN->psFrameworkCmd, psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) || (OSCopyFromUser(NULL, psFrameworkCmdInt, psRGXCreateComputeContextIN->psFrameworkCmd, psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) != PVRSRV_OK) ) { psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto RGXCreateComputeContext_exit; } { /* Look up the address from the handle */ psRGXCreateComputeContextOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hDevNodeInt, psRGXCreateComputeContextIN->hDevNode, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRGXCreateComputeContextOUT->eError != PVRSRV_OK) { goto RGXCreateComputeContext_exit; } } { /* Look up the address from the handle */ psRGXCreateComputeContextOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hPrivDataInt, psRGXCreateComputeContextIN->hPrivData, PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA); if(psRGXCreateComputeContextOUT->eError != PVRSRV_OK) { goto RGXCreateComputeContext_exit; } } psRGXCreateComputeContextOUT->eError = PVRSRVRGXCreateComputeContextKM(psConnection, hDevNodeInt, psRGXCreateComputeContextIN->ui32Priority, psRGXCreateComputeContextIN->sMCUFenceAddr, psRGXCreateComputeContextIN->ui32FrameworkCmdize, psFrameworkCmdInt, hPrivDataInt, &psComputeContextInt); /* Exit early if bridged call fails */ if(psRGXCreateComputeContextOUT->eError != PVRSRV_OK) { goto RGXCreateComputeContext_exit; } /* Create a resman item and overwrite the handle with it */ hComputeContextInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_RGX_SERVER_COMPUTE_CONTEXT, psComputeContextInt, (RESMAN_FREE_FN)&PVRSRVRGXDestroyComputeContextKM); if (hComputeContextInt2 == IMG_NULL) { psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto RGXCreateComputeContext_exit; } psRGXCreateComputeContextOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psRGXCreateComputeContextOUT->hComputeContext, (IMG_HANDLE) hComputeContextInt2, PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); if (psRGXCreateComputeContextOUT->eError != PVRSRV_OK) { goto RGXCreateComputeContext_exit; } RGXCreateComputeContext_exit: if (psRGXCreateComputeContextOUT->eError != PVRSRV_OK) { /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hComputeContextInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hComputeContextInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (psComputeContextInt) { PVRSRVRGXDestroyComputeContextKM(psComputeContextInt); } } if (psFrameworkCmdInt) OSFreeMem(psFrameworkCmdInt); return 0; }
static IMG_INT PVRSRVBridgeEventObjectOpen(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_EVENTOBJECTOPEN *psEventObjectOpenIN, PVRSRV_BRIDGE_OUT_EVENTOBJECTOPEN *psEventObjectOpenOUT, CONNECTION_DATA *psConnection) { IMG_HANDLE hEventObjectInt = IMG_NULL; IMG_HANDLE hEventObjectInt2 = IMG_NULL; IMG_HANDLE hOSEventInt = IMG_NULL; IMG_HANDLE hOSEventInt2 = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SRVCORE_EVENTOBJECTOPEN); { /* Look up the address from the handle */ psEventObjectOpenOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hEventObjectInt2, psEventObjectOpenIN->hEventObject, PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT); if(psEventObjectOpenOUT->eError != PVRSRV_OK) { goto EventObjectOpen_exit; } /* Look up the data from the resman address */ psEventObjectOpenOUT->eError = ResManFindPrivateDataByPtr(hEventObjectInt2, (IMG_VOID **) &hEventObjectInt); if(psEventObjectOpenOUT->eError != PVRSRV_OK) { goto EventObjectOpen_exit; } } psEventObjectOpenOUT->eError = OSEventObjectOpen( hEventObjectInt, &hOSEventInt); /* Exit early if bridged call fails */ if(psEventObjectOpenOUT->eError != PVRSRV_OK) { goto EventObjectOpen_exit; } /* Create a resman item and overwrite the handle with it */ hOSEventInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_EVENT_OBJECT, hOSEventInt, /* FIXME: how can we avoid this cast? */ (RESMAN_FREE_FN)&OSEventObjectClose); if (hOSEventInt2 == IMG_NULL) { psEventObjectOpenOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto EventObjectOpen_exit; } psEventObjectOpenOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psEventObjectOpenOUT->hOSEvent, (IMG_HANDLE) hOSEventInt2, PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT, PVRSRV_HANDLE_ALLOC_FLAG_MULTI ); if (psEventObjectOpenOUT->eError != PVRSRV_OK) { goto EventObjectOpen_exit; } EventObjectOpen_exit: if (psEventObjectOpenOUT->eError != PVRSRV_OK) { /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hOSEventInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hOSEventInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (hOSEventInt) { OSEventObjectClose(hOSEventInt); } } return 0; }
static IMG_INT PVRSRVBridgeAcquireGlobalEventObject(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_ACQUIREGLOBALEVENTOBJECT *psAcquireGlobalEventObjectIN, PVRSRV_BRIDGE_OUT_ACQUIREGLOBALEVENTOBJECT *psAcquireGlobalEventObjectOUT, CONNECTION_DATA *psConnection) { IMG_HANDLE hGlobalEventObjectInt = IMG_NULL; IMG_HANDLE hGlobalEventObjectInt2 = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SRVCORE_ACQUIREGLOBALEVENTOBJECT); PVR_UNREFERENCED_PARAMETER(psAcquireGlobalEventObjectIN); psAcquireGlobalEventObjectOUT->eError = AcquireGlobalEventObjectServer( &hGlobalEventObjectInt); /* Exit early if bridged call fails */ if(psAcquireGlobalEventObjectOUT->eError != PVRSRV_OK) { goto AcquireGlobalEventObject_exit; } /* Create a resman item and overwrite the handle with it */ hGlobalEventObjectInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_SHARED_EVENT_OBJECT, hGlobalEventObjectInt, /* FIXME: how can we avoid this cast? */ (RESMAN_FREE_FN)&ReleaseGlobalEventObjectServer); if (hGlobalEventObjectInt2 == IMG_NULL) { psAcquireGlobalEventObjectOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto AcquireGlobalEventObject_exit; } psAcquireGlobalEventObjectOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psAcquireGlobalEventObjectOUT->hGlobalEventObject, (IMG_HANDLE) hGlobalEventObjectInt2, PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT, PVRSRV_HANDLE_ALLOC_FLAG_SHARED ); if (psAcquireGlobalEventObjectOUT->eError != PVRSRV_OK) { goto AcquireGlobalEventObject_exit; } AcquireGlobalEventObject_exit: if (psAcquireGlobalEventObjectOUT->eError != PVRSRV_OK) { /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hGlobalEventObjectInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hGlobalEventObjectInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (hGlobalEventObjectInt) { ReleaseGlobalEventObjectServer(hGlobalEventObjectInt); } } return 0; }
enum PVRSRV_ERROR PVRSRVPerProcessDataConnect(u32 ui32PID) { struct PVRSRV_PER_PROCESS_DATA *psPerProc; void *hBlockAlloc; enum PVRSRV_ERROR eError = PVRSRV_OK; PVR_ASSERT(psHashTab != NULL); psPerProc = (struct PVRSRV_PER_PROCESS_DATA *)HASH_Retrieve(psHashTab, (u32)ui32PID); if (psPerProc == NULL) { eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(*psPerProc), (void **)&psPerProc, &hBlockAlloc); if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "Couldn't allocate per-process data (%d)", eError); return eError; } OSMemSet(psPerProc, 0, sizeof(*psPerProc)); psPerProc->hBlockAlloc = hBlockAlloc; if (!HASH_Insert(psHashTab, (u32) ui32PID, (u32)psPerProc)) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "Couldn't insert per-process data into hash table"); eError = PVRSRV_ERROR_GENERIC; goto failure; } psPerProc->ui32PID = ui32PID; psPerProc->ui32RefCount = 0; eError = OSPerProcessPrivateDataInit(&psPerProc->hOsPrivateData); if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "OSPerProcessPrivateDataInit failed (%d)", eError); goto failure; } eError = PVRSRVAllocHandle(KERNEL_HANDLE_BASE, &psPerProc->hPerProcData, psPerProc, PVRSRV_HANDLE_TYPE_PERPROC_DATA, PVRSRV_HANDLE_ALLOC_FLAG_NONE); if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "Couldn't allocate handle for per-process data (%d)", eError); goto failure; } eError = PVRSRVAllocHandleBase(&psPerProc->psHandleBase); if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "Couldn't allocate handle base for process (%d)", eError); goto failure; } eError = OSPerProcessSetHandleOptions(psPerProc->psHandleBase); if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "Couldn't set handle options (%d)", eError); goto failure; } eError = PVRSRVResManConnect(psPerProc, &psPerProc->hResManContext); if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "Couldn't register with the resource manager"); goto failure; } } psPerProc->ui32RefCount++; PVR_DPF(PVR_DBG_MESSAGE, "PVRSRVPerProcessDataConnect: Process 0x%x has ref-count %d", ui32PID, psPerProc->ui32RefCount); return eError; failure: (void)FreePerProcessData(psPerProc); return eError; }
PVRSRV_ERROR PVRSRVPerProcessDataConnect(IMG_UINT32 ui32PID, IMG_UINT32 ui32Flags) { PVRSRV_PER_PROCESS_DATA *psPerProc; IMG_HANDLE hBlockAlloc; PVRSRV_ERROR eError = PVRSRV_OK; PVR_ASSERT(psHashTab != IMG_NULL); psPerProc = (PVRSRV_PER_PROCESS_DATA *)HASH_Retrieve(psHashTab, (IMG_UINTPTR_T)ui32PID); if (psPerProc == IMG_NULL) { eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(*psPerProc), (IMG_PVOID *)&psPerProc, &hBlockAlloc, "Per Process Data"); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't allocate per-process data (%d)", eError)); return eError; } OSMemSet(psPerProc, 0, sizeof(*psPerProc)); psPerProc->hBlockAlloc = hBlockAlloc; /* * FIXME: using a hash to retrieve psPerProc makes not much * sense. We always want to have this struct on the IOCTL path * for the current task, so it'd be just a matter of storing * it in the file private object. Until this is resolved and * we get rid of this pid specific lookup make sure the above * assumption holds. */ WARN_ON(OSGetCurrentProcessIDKM() != ui32PID); get_task_comm(psPerProc->name, current); if (!HASH_Insert(psHashTab, (IMG_UINTPTR_T)ui32PID, (IMG_UINTPTR_T)psPerProc)) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't insert per-process data into hash table")); eError = PVRSRV_ERROR_INSERT_HASH_TABLE_DATA_FAILED; goto failure; } psPerProc->ui32PID = ui32PID; psPerProc->ui32RefCount = 0; #if defined(PERPROC_LIST) List_PVRSRV_PER_PROCESS_DATA_Insert(&psPerProcList, psPerProc); /*PVR_LOG(("MarkTupsperproc %d\n", ui32PID));*/ #endif #if defined(SUPPORT_PDUMP_MULTI_PROCESS) if (ui32Flags == SRV_FLAGS_PDUMP_ACTIVE) { psPerProc->bPDumpActive = IMG_TRUE; } #else PVR_UNREFERENCED_PARAMETER(ui32Flags); #endif eError = OSPerProcessPrivateDataInit(&psPerProc->hOsPrivateData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: OSPerProcessPrivateDataInit failed (%d)", eError)); goto failure; } eError = PVRSRVAllocHandle(KERNEL_HANDLE_BASE, &psPerProc->hPerProcData, psPerProc, PVRSRV_HANDLE_TYPE_PERPROC_DATA, PVRSRV_HANDLE_ALLOC_FLAG_NONE); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't allocate handle for per-process data (%d)", eError)); goto failure; } eError = PVRSRVAllocHandleBase(&psPerProc->psHandleBase); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't allocate handle base for process (%d)", eError)); goto failure; } eError = OSPerProcessSetHandleOptions(psPerProc->psHandleBase); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't set handle options (%d)", eError)); goto failure; } eError = PVRSRVResManConnect(psPerProc, &psPerProc->hResManContext); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't register with the resource manager")); goto failure; } } psPerProc->ui32RefCount++; PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVPerProcessDataConnect: Process 0x%x has ref-count %d", ui32PID, psPerProc->ui32RefCount)); return eError; failure: (IMG_VOID)FreePerProcessData(psPerProc); return eError; }
static IMG_INT PVRSRVBridgePMRSecureImportPMR(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_PMRSECUREIMPORTPMR *psPMRSecureImportPMRIN, PVRSRV_BRIDGE_OUT_PMRSECUREIMPORTPMR *psPMRSecureImportPMROUT, CONNECTION_DATA *psConnection) { PMR * psPMRInt = IMG_NULL; IMG_HANDLE hPMRInt2 = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SMM_PMRSECUREIMPORTPMR); psPMRSecureImportPMROUT->eError = PMRSecureImportPMR( psPMRSecureImportPMRIN->Export, &psPMRInt, &psPMRSecureImportPMROUT->uiSize, &psPMRSecureImportPMROUT->sAlign); /* Exit early if bridged call fails */ if(psPMRSecureImportPMROUT->eError != PVRSRV_OK) { goto PMRSecureImportPMR_exit; } /* Create a resman item and overwrite the handle with it */ hPMRInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_PMR, psPMRInt, /* FIXME: how can we avoid this cast? */ (RESMAN_FREE_FN)&PMRUnrefPMR); if (hPMRInt2 == IMG_NULL) { psPMRSecureImportPMROUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto PMRSecureImportPMR_exit; } psPMRSecureImportPMROUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psPMRSecureImportPMROUT->hPMR, (IMG_HANDLE) hPMRInt2, PVRSRV_HANDLE_TYPE_PHYSMEM_PMR, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); if (psPMRSecureImportPMROUT->eError != PVRSRV_OK) { goto PMRSecureImportPMR_exit; } PMRSecureImportPMR_exit: if (psPMRSecureImportPMROUT->eError != PVRSRV_OK) { /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hPMRInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hPMRInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (psPMRInt) { PMRUnrefPMR(psPMRInt); } } return 0; }
static IMG_INT PVRSRVBridgeRIWriteMEMDESCEntry(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_RIWRITEMEMDESCENTRY *psRIWriteMEMDESCEntryIN, PVRSRV_BRIDGE_OUT_RIWRITEMEMDESCENTRY *psRIWriteMEMDESCEntryOUT, CONNECTION_DATA *psConnection) { PMR * psPMRHandleInt = IMG_NULL; IMG_HANDLE hPMRHandleInt2 = IMG_NULL; IMG_CHAR *uiTextBInt = IMG_NULL; RI_HANDLE psRIHandleInt = IMG_NULL; IMG_HANDLE hRIHandleInt2 = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_RI_RIWRITEMEMDESCENTRY); { uiTextBInt = OSAllocMem(RI_MAX_TEXT_LEN * sizeof(IMG_CHAR)); if (!uiTextBInt) { psRIWriteMEMDESCEntryOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto RIWriteMEMDESCEntry_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRIWriteMEMDESCEntryIN->puiTextB, RI_MAX_TEXT_LEN * sizeof(IMG_CHAR)) || (OSCopyFromUser(NULL, uiTextBInt, psRIWriteMEMDESCEntryIN->puiTextB, RI_MAX_TEXT_LEN * sizeof(IMG_CHAR)) != PVRSRV_OK) ) { psRIWriteMEMDESCEntryOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto RIWriteMEMDESCEntry_exit; } { /* Look up the address from the handle */ psRIWriteMEMDESCEntryOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hPMRHandleInt2, psRIWriteMEMDESCEntryIN->hPMRHandle, PVRSRV_HANDLE_TYPE_PHYSMEM_PMR); if(psRIWriteMEMDESCEntryOUT->eError != PVRSRV_OK) { goto RIWriteMEMDESCEntry_exit; } /* Look up the data from the resman address */ psRIWriteMEMDESCEntryOUT->eError = ResManFindPrivateDataByPtr(hPMRHandleInt2, (IMG_VOID **) &psPMRHandleInt); if(psRIWriteMEMDESCEntryOUT->eError != PVRSRV_OK) { goto RIWriteMEMDESCEntry_exit; } } psRIWriteMEMDESCEntryOUT->eError = RIWriteMEMDESCEntryKM( psPMRHandleInt, uiTextBInt, psRIWriteMEMDESCEntryIN->uiOffset, psRIWriteMEMDESCEntryIN->uiSize, psRIWriteMEMDESCEntryIN->bIsImport, psRIWriteMEMDESCEntryIN->bIsExportable, &psRIHandleInt); /* Exit early if bridged call fails */ if(psRIWriteMEMDESCEntryOUT->eError != PVRSRV_OK) { goto RIWriteMEMDESCEntry_exit; } /* Create a resman item and overwrite the handle with it */ hRIHandleInt2 = ResManRegisterRes(psConnection->hResManContext, RESMAN_TYPE_RI_HANDLE, psRIHandleInt, (RESMAN_FREE_FN)&RIDeleteMEMDESCEntryKM); if (hRIHandleInt2 == IMG_NULL) { psRIWriteMEMDESCEntryOUT->eError = PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE; goto RIWriteMEMDESCEntry_exit; } psRIWriteMEMDESCEntryOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase, &psRIWriteMEMDESCEntryOUT->hRIHandle, (IMG_HANDLE) hRIHandleInt2, PVRSRV_HANDLE_TYPE_RI_HANDLE, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); if (psRIWriteMEMDESCEntryOUT->eError != PVRSRV_OK) { goto RIWriteMEMDESCEntry_exit; } RIWriteMEMDESCEntry_exit: if (psRIWriteMEMDESCEntryOUT->eError != PVRSRV_OK) { /* If we have a valid resman item we should undo the bridge function by freeing the resman item */ if (hRIHandleInt2) { PVRSRV_ERROR eError = ResManFreeResByPtr(hRIHandleInt2); /* Freeing a resource should never fail... */ PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY)); } else if (psRIHandleInt) { RIDeleteMEMDESCEntryKM(psRIHandleInt); } } if (uiTextBInt) OSFreeMem(uiTextBInt); return 0; }