static IMG_INT PVRSRVBridgePMRSecureImportPMR(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_PMRSECUREIMPORTPMR *psPMRSecureImportPMRIN, PVRSRV_BRIDGE_OUT_PMRSECUREIMPORTPMR *psPMRSecureImportPMROUT, CONNECTION_DATA *psConnection) { PMR * psPMRInt; IMG_HANDLE hPMRInt2; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SMM_PMRSECUREIMPORTPMR); NEW_HANDLE_BATCH_OR_ERROR(psPMRSecureImportPMROUT->eError, psConnection, 1); 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; } PVRSRVAllocHandleNR(psConnection->psHandleBase, &psPMRSecureImportPMROUT->hPMR, (IMG_HANDLE) hPMRInt2, PVRSRV_HANDLE_TYPE_PHYSMEM_PMR, PVRSRV_HANDLE_ALLOC_FLAG_NONE ); COMMIT_HANDLE_BATCH_OR_ERROR(psPMRSecureImportPMROUT->eError, psConnection); PMRSecureImportPMR_exit: return 0; }
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; }