PVRSRV_ERROR CopyToUserWrapper(CONNECTION_DATA *psConnection, IMG_UINT32 ui32BridgeID, IMG_VOID *pvDest, IMG_VOID *pvSrc, IMG_UINT32 ui32Size) { g_BridgeDispatchTable[ui32BridgeID].ui32CopyToUserTotalBytes+=ui32Size; g_BridgeGlobalStats.ui32TotalCopyToUserBytes+=ui32Size; return OSCopyToUser(psConnection, pvDest, pvSrc, ui32Size); }
static IMG_INT PVRSRVBridgeEnumerateDevices(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_ENUMERATEDEVICES *psEnumerateDevicesIN, PVRSRV_BRIDGE_OUT_ENUMERATEDEVICES *psEnumerateDevicesOUT, CONNECTION_DATA *psConnection) { PVRSRV_DEVICE_IDENTIFIER *psDeviceIdentifierInt = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SRVCORE_ENUMERATEDEVICES); PVR_UNREFERENCED_PARAMETER(psConnection); PVR_UNREFERENCED_PARAMETER(psEnumerateDevicesIN); psEnumerateDevicesOUT->psDeviceIdentifier = psEnumerateDevicesIN->psDeviceIdentifier; { psDeviceIdentifierInt = OSAllocMem(PVRSRV_MAX_DEVICES * sizeof(PVRSRV_DEVICE_IDENTIFIER)); if (!psDeviceIdentifierInt) { psEnumerateDevicesOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto EnumerateDevices_exit; } } psEnumerateDevicesOUT->eError = PVRSRVEnumerateDevicesKM( &psEnumerateDevicesOUT->ui32NumDevices, psDeviceIdentifierInt); if ( !OSAccessOK(PVR_VERIFY_WRITE, (IMG_VOID*) psEnumerateDevicesOUT->psDeviceIdentifier, (PVRSRV_MAX_DEVICES * sizeof(PVRSRV_DEVICE_IDENTIFIER))) || (OSCopyToUser(NULL, psEnumerateDevicesOUT->psDeviceIdentifier, psDeviceIdentifierInt, (PVRSRV_MAX_DEVICES * sizeof(PVRSRV_DEVICE_IDENTIFIER))) != PVRSRV_OK) ) { psEnumerateDevicesOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto EnumerateDevices_exit; } EnumerateDevices_exit: if (psDeviceIdentifierInt) OSFreeMem(psDeviceIdentifierInt); return 0; }
static IMG_INT PVRSRVBridgeServerSyncGetStatus(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_SERVERSYNCGETSTATUS *psServerSyncGetStatusIN, PVRSRV_BRIDGE_OUT_SERVERSYNCGETSTATUS *psServerSyncGetStatusOUT, CONNECTION_DATA *psConnection) { SERVER_SYNC_PRIMITIVE * *psSyncHandleInt = IMG_NULL; IMG_HANDLE *hSyncHandleInt2 = IMG_NULL; IMG_UINT32 *pui32UIDInt = IMG_NULL; IMG_UINT32 *pui32FWAddrInt = IMG_NULL; IMG_UINT32 *pui32CurrentOpInt = IMG_NULL; IMG_UINT32 *pui32NextOpInt = IMG_NULL; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_SERVERSYNCGETSTATUS); psServerSyncGetStatusOUT->pui32UID = psServerSyncGetStatusIN->pui32UID; psServerSyncGetStatusOUT->pui32FWAddr = psServerSyncGetStatusIN->pui32FWAddr; psServerSyncGetStatusOUT->pui32CurrentOp = psServerSyncGetStatusIN->pui32CurrentOp; psServerSyncGetStatusOUT->pui32NextOp = psServerSyncGetStatusIN->pui32NextOp; if (psServerSyncGetStatusIN->ui32SyncCount != 0) { psSyncHandleInt = OSAllocMem(psServerSyncGetStatusIN->ui32SyncCount * sizeof(SERVER_SYNC_PRIMITIVE *)); if (!psSyncHandleInt) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ServerSyncGetStatus_exit; } hSyncHandleInt2 = OSAllocMem(psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_HANDLE)); if (!hSyncHandleInt2) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ServerSyncGetStatus_exit; } } /* Copy the data over */ if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psServerSyncGetStatusIN->phSyncHandle, psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_HANDLE)) || (OSCopyFromUser(NULL, hSyncHandleInt2, psServerSyncGetStatusIN->phSyncHandle, psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK) ) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto ServerSyncGetStatus_exit; } if (psServerSyncGetStatusIN->ui32SyncCount != 0) { pui32UIDInt = OSAllocMem(psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32)); if (!pui32UIDInt) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ServerSyncGetStatus_exit; } } if (psServerSyncGetStatusIN->ui32SyncCount != 0) { pui32FWAddrInt = OSAllocMem(psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32)); if (!pui32FWAddrInt) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ServerSyncGetStatus_exit; } } if (psServerSyncGetStatusIN->ui32SyncCount != 0) { pui32CurrentOpInt = OSAllocMem(psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32)); if (!pui32CurrentOpInt) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ServerSyncGetStatus_exit; } } if (psServerSyncGetStatusIN->ui32SyncCount != 0) { pui32NextOpInt = OSAllocMem(psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32)); if (!pui32NextOpInt) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ServerSyncGetStatus_exit; } } { IMG_UINT32 i; for (i=0;i<psServerSyncGetStatusIN->ui32SyncCount;i++) { { /* Look up the address from the handle */ psServerSyncGetStatusOUT->eError = PVRSRVLookupHandle(psConnection->psHandleBase, (IMG_HANDLE *) &hSyncHandleInt2[i], psServerSyncGetStatusIN->phSyncHandle[i], PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE); if(psServerSyncGetStatusOUT->eError != PVRSRV_OK) { goto ServerSyncGetStatus_exit; } /* Look up the data from the resman address */ psServerSyncGetStatusOUT->eError = ResManFindPrivateDataByPtr(hSyncHandleInt2[i], (IMG_VOID **) &psSyncHandleInt[i]); if(psServerSyncGetStatusOUT->eError != PVRSRV_OK) { goto ServerSyncGetStatus_exit; } } } } psServerSyncGetStatusOUT->eError = PVRSRVServerSyncGetStatusKM( psServerSyncGetStatusIN->ui32SyncCount, psSyncHandleInt, pui32UIDInt, pui32FWAddrInt, pui32CurrentOpInt, pui32NextOpInt); if ( !OSAccessOK(PVR_VERIFY_WRITE, (IMG_VOID*) psServerSyncGetStatusOUT->pui32UID, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) || (OSCopyToUser(NULL, psServerSyncGetStatusOUT->pui32UID, pui32UIDInt, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) != PVRSRV_OK) ) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto ServerSyncGetStatus_exit; } if ( !OSAccessOK(PVR_VERIFY_WRITE, (IMG_VOID*) psServerSyncGetStatusOUT->pui32FWAddr, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) || (OSCopyToUser(NULL, psServerSyncGetStatusOUT->pui32FWAddr, pui32FWAddrInt, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) != PVRSRV_OK) ) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto ServerSyncGetStatus_exit; } if ( !OSAccessOK(PVR_VERIFY_WRITE, (IMG_VOID*) psServerSyncGetStatusOUT->pui32CurrentOp, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) || (OSCopyToUser(NULL, psServerSyncGetStatusOUT->pui32CurrentOp, pui32CurrentOpInt, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) != PVRSRV_OK) ) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto ServerSyncGetStatus_exit; } if ( !OSAccessOK(PVR_VERIFY_WRITE, (IMG_VOID*) psServerSyncGetStatusOUT->pui32NextOp, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) || (OSCopyToUser(NULL, psServerSyncGetStatusOUT->pui32NextOp, pui32NextOpInt, (psServerSyncGetStatusIN->ui32SyncCount * sizeof(IMG_UINT32))) != PVRSRV_OK) ) { psServerSyncGetStatusOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; goto ServerSyncGetStatus_exit; } ServerSyncGetStatus_exit: if (psSyncHandleInt) OSFreeMem(psSyncHandleInt); if (hSyncHandleInt2) OSFreeMem(hSyncHandleInt2); if (pui32UIDInt) OSFreeMem(pui32UIDInt); if (pui32FWAddrInt) OSFreeMem(pui32FWAddrInt); if (pui32CurrentOpInt) OSFreeMem(pui32CurrentOpInt); if (pui32NextOpInt) OSFreeMem(pui32NextOpInt); return 0; }