static PVRSRV_ERROR FreeDeviceMemCallBack(IMG_PVOID		pvParam,
										  IMG_UINT32	ui32Param)
{
	PVRSRV_ERROR eError = PVRSRV_OK;
	PVRSRV_KERNEL_MEM_INFO *psMemInfo = pvParam;

	PVR_UNREFERENCED_PARAMETER(ui32Param);

	
	psMemInfo->ui32RefCount--;

	
	if(psMemInfo->ui32Flags & PVRSRV_MEM_EXPORTED)
	{
		IMG_HANDLE hMemInfo = IMG_NULL;

		
		if (psMemInfo->ui32RefCount != 0)
		{
			PVR_DPF((PVR_DBG_ERROR, "FreeDeviceMemCallBack: mappings are open in other processes"));		
			return PVRSRV_ERROR_GENERIC;
		}
		
		
		eError = PVRSRVFindHandle(KERNEL_HANDLE_BASE,
								 &hMemInfo,
								 psMemInfo,
								 PVRSRV_HANDLE_TYPE_MEM_INFO);
		if(eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR, "FreeDeviceMemCallBack: can't find exported meminfo in the global handle list"));
			return eError;
		}
		
		
		eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE,
									hMemInfo,
									PVRSRV_HANDLE_TYPE_MEM_INFO);
		if(eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR, "FreeDeviceMemCallBack: PVRSRVReleaseHandle failed for exported meminfo"));
			return eError;
		}
	}

	PVR_ASSERT(psMemInfo->ui32RefCount == 0);

	if (psMemInfo->psKernelSyncInfo)
	{
		eError = PVRSRVFreeSyncInfoKM(psMemInfo->psKernelSyncInfo);
	}

	if (eError == PVRSRV_OK)
	{
		eError = FreeDeviceMem(psMemInfo);
	}

	return eError;
}
Beispiel #2
0
static enum PVRSRV_ERROR FreePerProcessData(
				struct PVRSRV_PER_PROCESS_DATA *psPerProc)
{
	enum PVRSRV_ERROR eError;
	u32 uiPerProc;

	PVR_ASSERT(psPerProc != NULL);

	uiPerProc = HASH_Remove(psHashTab, (u32)psPerProc->ui32PID);
	if (uiPerProc == 0) {
		PVR_DPF(PVR_DBG_ERROR, "FreePerProcessData: "
		       "Couldn't find process in per-process data hash table");

		PVR_ASSERT(psPerProc->ui32PID == 0);
	} else {
		PVR_ASSERT((struct PVRSRV_PER_PROCESS_DATA *)
				uiPerProc == psPerProc);
		PVR_ASSERT(((struct PVRSRV_PER_PROCESS_DATA *)uiPerProc)->
				ui32PID == psPerProc->ui32PID);
	}

	if (psPerProc->psHandleBase != NULL) {
		eError = PVRSRVFreeHandleBase(psPerProc->psHandleBase);
		if (eError != PVRSRV_OK) {
			PVR_DPF(PVR_DBG_ERROR, "FreePerProcessData: "
				"Couldn't free handle base for process (%d)",
				 eError);
			return eError;
		}
	}

	if (psPerProc->hPerProcData != NULL) {
		eError =
		    PVRSRVReleaseHandle(KERNEL_HANDLE_BASE,
					psPerProc->hPerProcData,
					PVRSRV_HANDLE_TYPE_PERPROC_DATA);

		if (eError != PVRSRV_OK) {
			PVR_DPF(PVR_DBG_ERROR, "FreePerProcessData: "
				"Couldn't release per-process data handle (%d)",
				 eError);
			return eError;
		}
	}

	OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(*psPerProc),
			psPerProc, psPerProc->hBlockAlloc);

	return PVRSRV_OK;
}
static IMG_INT
PVRSRVBridgeServerSyncFree(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_SERVERSYNCFREE *psServerSyncFreeIN,
					 PVRSRV_BRIDGE_OUT_SERVERSYNCFREE *psServerSyncFreeOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hSyncHandleInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_SERVERSYNCFREE);





				{
					/* Look up the address from the handle */
					psServerSyncFreeOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hSyncHandleInt2,
											psServerSyncFreeIN->hSyncHandle,
											PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
					if(psServerSyncFreeOUT->eError != PVRSRV_OK)
					{
						goto ServerSyncFree_exit;
					}

				}

	psServerSyncFreeOUT->eError = ServerSyncFreeResManProxy(hSyncHandleInt2);
	/* Exit early if bridged call fails */
	if(psServerSyncFreeOUT->eError != PVRSRV_OK)
	{
		goto ServerSyncFree_exit;
	}

	psServerSyncFreeOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psServerSyncFreeIN->hSyncHandle,
					PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);


ServerSyncFree_exit:

	return 0;
}
static IMG_INT
PVRSRVBridgeFreeSyncPrimitiveBlock(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_FREESYNCPRIMITIVEBLOCK *psFreeSyncPrimitiveBlockIN,
					 PVRSRV_BRIDGE_OUT_FREESYNCPRIMITIVEBLOCK *psFreeSyncPrimitiveBlockOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hSyncHandleInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_FREESYNCPRIMITIVEBLOCK);





				{
					/* Look up the address from the handle */
					psFreeSyncPrimitiveBlockOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hSyncHandleInt2,
											psFreeSyncPrimitiveBlockIN->hSyncHandle,
											PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
					if(psFreeSyncPrimitiveBlockOUT->eError != PVRSRV_OK)
					{
						goto FreeSyncPrimitiveBlock_exit;
					}

				}

	psFreeSyncPrimitiveBlockOUT->eError = FreeSyncPrimitiveBlockResManProxy(hSyncHandleInt2);
	/* Exit early if bridged call fails */
	if(psFreeSyncPrimitiveBlockOUT->eError != PVRSRV_OK)
	{
		goto FreeSyncPrimitiveBlock_exit;
	}

	psFreeSyncPrimitiveBlockOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psFreeSyncPrimitiveBlockIN->hSyncHandle,
					PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);


FreeSyncPrimitiveBlock_exit:

	return 0;
}
static IMG_INT
PVRSRVBridgeSyncPrimOpDestroy(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_SYNCPRIMOPDESTROY *psSyncPrimOpDestroyIN,
					 PVRSRV_BRIDGE_OUT_SYNCPRIMOPDESTROY *psSyncPrimOpDestroyOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hServerCookieInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_SYNCPRIMOPDESTROY);





				{
					/* Look up the address from the handle */
					psSyncPrimOpDestroyOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hServerCookieInt2,
											psSyncPrimOpDestroyIN->hServerCookie,
											PVRSRV_HANDLE_TYPE_SERVER_OP_COOKIE);
					if(psSyncPrimOpDestroyOUT->eError != PVRSRV_OK)
					{
						goto SyncPrimOpDestroy_exit;
					}

				}

	psSyncPrimOpDestroyOUT->eError = SyncPrimOpDestroyResManProxy(hServerCookieInt2);
	/* Exit early if bridged call fails */
	if(psSyncPrimOpDestroyOUT->eError != PVRSRV_OK)
	{
		goto SyncPrimOpDestroy_exit;
	}

	psSyncPrimOpDestroyOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psSyncPrimOpDestroyIN->hServerCookie,
					PVRSRV_HANDLE_TYPE_SERVER_OP_COOKIE);


SyncPrimOpDestroy_exit:

	return 0;
}
static IMG_INT
PVRSRVBridgeTLCloseStream(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_TLCLOSESTREAM *psTLCloseStreamIN,
					 PVRSRV_BRIDGE_OUT_TLCLOSESTREAM *psTLCloseStreamOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hSDInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PVRTL_TLCLOSESTREAM);





				{
					/* Look up the address from the handle */
					psTLCloseStreamOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hSDInt2,
											psTLCloseStreamIN->hSD,
											PVRSRV_HANDLE_TYPE_PVR_TL_SD);
					if(psTLCloseStreamOUT->eError != PVRSRV_OK)
					{
						goto TLCloseStream_exit;
					}

				}

	psTLCloseStreamOUT->eError = TLCloseStreamResManProxy(hSDInt2);
	/* Exit early if bridged call fails */
	if(psTLCloseStreamOUT->eError != PVRSRV_OK)
	{
		goto TLCloseStream_exit;
	}

	psTLCloseStreamOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psTLCloseStreamIN->hSD,
					PVRSRV_HANDLE_TYPE_PVR_TL_SD);


TLCloseStream_exit:

	return 0;
}
static IMG_INT
PVRSRVBridgeRGXDestroyComputeContext(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_RGXDESTROYCOMPUTECONTEXT *psRGXDestroyComputeContextIN,
					 PVRSRV_BRIDGE_OUT_RGXDESTROYCOMPUTECONTEXT *psRGXDestroyComputeContextOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hComputeContextInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_RGXCMP_RGXDESTROYCOMPUTECONTEXT);





				{
					/* Look up the address from the handle */
					psRGXDestroyComputeContextOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hComputeContextInt2,
											psRGXDestroyComputeContextIN->hComputeContext,
											PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
					if(psRGXDestroyComputeContextOUT->eError != PVRSRV_OK)
					{
						goto RGXDestroyComputeContext_exit;
					}

				}

	psRGXDestroyComputeContextOUT->eError = RGXDestroyComputeContextResManProxy(hComputeContextInt2);
	/* Exit early if bridged call fails */
	if(psRGXDestroyComputeContextOUT->eError != PVRSRV_OK)
	{
		goto RGXDestroyComputeContext_exit;
	}

	psRGXDestroyComputeContextOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psRGXDestroyComputeContextIN->hComputeContext,
					PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);


RGXDestroyComputeContext_exit:

	return 0;
}
static IMG_INT
PVRSRVBridgeEventObjectClose(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_EVENTOBJECTCLOSE *psEventObjectCloseIN,
					 PVRSRV_BRIDGE_OUT_EVENTOBJECTCLOSE *psEventObjectCloseOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hOSEventKMInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SRVCORE_EVENTOBJECTCLOSE);





				{
					/* Look up the address from the handle */
					psEventObjectCloseOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hOSEventKMInt2,
											psEventObjectCloseIN->hOSEventKM,
											PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT);
					if(psEventObjectCloseOUT->eError != PVRSRV_OK)
					{
						goto EventObjectClose_exit;
					}

				}

	psEventObjectCloseOUT->eError = EventObjectCloseResManProxy(hOSEventKMInt2);
	/* Exit early if bridged call fails */
	if(psEventObjectCloseOUT->eError != PVRSRV_OK)
	{
		goto EventObjectClose_exit;
	}

	psEventObjectCloseOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psEventObjectCloseIN->hOSEventKM,
					PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT);


EventObjectClose_exit:

	return 0;
}
static IMG_INT
PVRSRVBridgeReleaseGlobalEventObject(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_RELEASEGLOBALEVENTOBJECT *psReleaseGlobalEventObjectIN,
					 PVRSRV_BRIDGE_OUT_RELEASEGLOBALEVENTOBJECT *psReleaseGlobalEventObjectOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hGlobalEventObjectInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SRVCORE_RELEASEGLOBALEVENTOBJECT);





				{
					/* Look up the address from the handle */
					psReleaseGlobalEventObjectOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hGlobalEventObjectInt2,
											psReleaseGlobalEventObjectIN->hGlobalEventObject,
											PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT);
					if(psReleaseGlobalEventObjectOUT->eError != PVRSRV_OK)
					{
						goto ReleaseGlobalEventObject_exit;
					}

				}

	psReleaseGlobalEventObjectOUT->eError = ReleaseGlobalEventObjectResManProxy(hGlobalEventObjectInt2);
	/* Exit early if bridged call fails */
	if(psReleaseGlobalEventObjectOUT->eError != PVRSRV_OK)
	{
		goto ReleaseGlobalEventObject_exit;
	}

	psReleaseGlobalEventObjectOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psReleaseGlobalEventObjectIN->hGlobalEventObject,
					PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT);


ReleaseGlobalEventObject_exit:

	return 0;
}
static IMG_INT
PVRSRVBridgePMRSecureUnexportPMR(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_PMRSECUREUNEXPORTPMR *psPMRSecureUnexportPMRIN,
					 PVRSRV_BRIDGE_OUT_PMRSECUREUNEXPORTPMR *psPMRSecureUnexportPMROUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hPMRInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SMM_PMRSECUREUNEXPORTPMR);





				{
					/* Look up the address from the handle */
					psPMRSecureUnexportPMROUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hPMRInt2,
											psPMRSecureUnexportPMRIN->hPMR,
											PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
					if(psPMRSecureUnexportPMROUT->eError != PVRSRV_OK)
					{
						goto PMRSecureUnexportPMR_exit;
					}

				}

	psPMRSecureUnexportPMROUT->eError = PMRSecureUnexportPMRResManProxy(hPMRInt2);
	/* Exit early if bridged call fails */
	if(psPMRSecureUnexportPMROUT->eError != PVRSRV_OK)
	{
		goto PMRSecureUnexportPMR_exit;
	}

	psPMRSecureUnexportPMROUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psPMRSecureUnexportPMRIN->hPMR,
					PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);


PMRSecureUnexportPMR_exit:

	return 0;
}
Beispiel #11
0
static IMG_INT
PVRSRVBridgeRIDeleteMEMDESCEntry(IMG_UINT32 ui32BridgeID,
					 PVRSRV_BRIDGE_IN_RIDELETEMEMDESCENTRY *psRIDeleteMEMDESCEntryIN,
					 PVRSRV_BRIDGE_OUT_RIDELETEMEMDESCENTRY *psRIDeleteMEMDESCEntryOUT,
					 CONNECTION_DATA *psConnection)
{
	IMG_HANDLE hRIHandleInt2 = IMG_NULL;

	PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_RI_RIDELETEMEMDESCENTRY);





				{
					/* Look up the address from the handle */
					psRIDeleteMEMDESCEntryOUT->eError =
						PVRSRVLookupHandle(psConnection->psHandleBase,
											(IMG_HANDLE *) &hRIHandleInt2,
											psRIDeleteMEMDESCEntryIN->hRIHandle,
											PVRSRV_HANDLE_TYPE_RI_HANDLE);
					if(psRIDeleteMEMDESCEntryOUT->eError != PVRSRV_OK)
					{
						goto RIDeleteMEMDESCEntry_exit;
					}

				}

	psRIDeleteMEMDESCEntryOUT->eError = RIDeleteMEMDESCEntryResManProxy(hRIHandleInt2);
	/* Exit early if bridged call fails */
	if(psRIDeleteMEMDESCEntryOUT->eError != PVRSRV_OK)
	{
		goto RIDeleteMEMDESCEntry_exit;
	}

	psRIDeleteMEMDESCEntryOUT->eError =
		PVRSRVReleaseHandle(psConnection->psHandleBase,
					(IMG_HANDLE) psRIDeleteMEMDESCEntryIN->hRIHandle,
					PVRSRV_HANDLE_TYPE_RI_HANDLE);


RIDeleteMEMDESCEntry_exit:

	return 0;
}
Beispiel #12
0
static PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo,
										  IMG_UINT32	ui32Param,
										  IMG_BOOL	bFromAllocator)
{
	PVRSRV_ERROR eError = PVRSRV_OK;

	PVR_UNREFERENCED_PARAMETER(ui32Param);

	
	psMemInfo->ui32RefCount--;

	if (psMemInfo->ui32RefCount == 0)
	{
		if(psMemInfo->ui32Flags & PVRSRV_MEM_EXPORTED)
		{
			IMG_HANDLE hMemInfo = IMG_NULL;


			eError = PVRSRVFindHandle(KERNEL_HANDLE_BASE,
					&hMemInfo,
					psMemInfo,
					PVRSRV_HANDLE_TYPE_MEM_INFO);
			if(eError != PVRSRV_OK)
			{
				PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: can't find exported meminfo in the global handle list"));
				return eError;
			}


			eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE,
					hMemInfo,
					PVRSRV_HANDLE_TYPE_MEM_INFO);
			if(eError != PVRSRV_OK)
			{
				PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: PVRSRVReleaseHandle failed for exported meminfo"));
				return eError;
			}
		}

		switch(psMemInfo->memType)
		{
			
			case PVRSRV_MEMTYPE_WRAPPED:
				freeWrapped(psMemInfo);
			case PVRSRV_MEMTYPE_DEVICE:
				if (psMemInfo->psKernelSyncInfo)
				{
					psMemInfo->psKernelSyncInfo->ui32RefCount--;

					if (psMemInfo->psKernelSyncInfo->ui32RefCount == 0)
					{
						eError = PVRSRVFreeSyncInfoKM(psMemInfo->psKernelSyncInfo);
					}
				}

			case PVRSRV_MEMTYPE_DEVICECLASS:
				break;
			default:
				PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: Unknown memType"));
				eError = PVRSRV_ERROR_INVALID_MEMINFO;
		}
	}

	
	
	eError = FreeDeviceMem2(psMemInfo, bFromAllocator);

	return eError;
}
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;
}
Beispiel #14
0
/*!
******************************************************************************

 @Function	FreePerProcData

 @Description	Free a per-process data area

 @Input		psPerProc - pointer to per-process data area

 @Return	Error code, or PVRSRV_OK

******************************************************************************/
static PVRSRV_ERROR FreePerProcessData(PVRSRV_PER_PROCESS_DATA *psPerProc)
{
	PVRSRV_ERROR eError;
	IMG_UINTPTR_T uiPerProc;

	PVR_ASSERT(psPerProc != IMG_NULL);

	if (psPerProc == IMG_NULL)
	{
		PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: invalid parameter"));
		return PVRSRV_ERROR_INVALID_PARAMS;
	}

	uiPerProc = HASH_Remove(psHashTab, (IMG_UINTPTR_T)psPerProc->ui32PID);
	if (uiPerProc == 0)
	{
		PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't find process in per-process data hash table"));
		/*
		 * We must have failed early in the per-process data area
		 * creation, before the process ID was set.
		 */
		PVR_ASSERT(psPerProc->ui32PID == 0);
	}
	else
	{
		PVR_ASSERT((PVRSRV_PER_PROCESS_DATA *)uiPerProc == psPerProc);
		PVR_ASSERT(((PVRSRV_PER_PROCESS_DATA *)uiPerProc)->ui32PID == psPerProc->ui32PID);
	}

	/* Free handle base for this process */
	if (psPerProc->psHandleBase != IMG_NULL)
	{
		eError = PVRSRVFreeHandleBase(psPerProc->psHandleBase);
		if (eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't free handle base for process (%d)", eError));
			return eError;
		}
	}

	/* Release handle for per-process data area */
	if (psPerProc->hPerProcData != IMG_NULL)
	{
		eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE, psPerProc->hPerProcData, PVRSRV_HANDLE_TYPE_PERPROC_DATA);

		if (eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't release per-process data handle (%d)", eError));
			return eError;
		}
	}

	/* Call environment specific per process deinit function */
	eError = OSPerProcessPrivateDataDeInit(psPerProc->hOsPrivateData);
	if (eError != PVRSRV_OK)
	{
		 PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: OSPerProcessPrivateDataDeInit failed (%d)", eError));
		return eError;
	}

	eError = OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
		sizeof(*psPerProc),
		psPerProc,
		psPerProc->hBlockAlloc);
	/*not nulling pointer, copy on stack*/
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't free per-process data (%d)", eError));
		return eError;
	}

	return PVRSRV_OK;
}
static PVRSRV_ERROR FreePerProcessData(PVRSRV_PER_PROCESS_DATA *psPerProc)
{
	PVRSRV_ERROR eError;
	IMG_UINTPTR_T uiPerProc;

	PVR_ASSERT(psPerProc != IMG_NULL);

	if (psPerProc == IMG_NULL)
	{
		PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: invalid parameter"));
		return PVRSRV_ERROR_INVALID_PARAMS;
	}

	uiPerProc = HASH_Remove(psHashTab, (IMG_UINTPTR_T)psPerProc->ui32PID);
	if (uiPerProc == 0)
	{
		PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't find process in per-process data hash table"));
		
		PVR_ASSERT(psPerProc->ui32PID == 0);
	}
	else
	{
		PVR_ASSERT((PVRSRV_PER_PROCESS_DATA *)uiPerProc == psPerProc);
		PVR_ASSERT(((PVRSRV_PER_PROCESS_DATA *)uiPerProc)->ui32PID == psPerProc->ui32PID);
	}

	
	if (psPerProc->psHandleBase != IMG_NULL)
	{
		eError = PVRSRVFreeHandleBase(psPerProc->psHandleBase);
		if (eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't free handle base for process (%d)", eError));
			return eError;
		}
	}

	
	if (psPerProc->hPerProcData != IMG_NULL)
	{
		eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE, psPerProc->hPerProcData, PVRSRV_HANDLE_TYPE_PERPROC_DATA);

		if (eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't release per-process data handle (%d)", eError));
			return eError;
		}
	}

	
	eError = OSPerProcessPrivateDataDeInit(psPerProc->hOsPrivateData);
	if (eError != PVRSRV_OK)
	{
		 PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: OSPerProcessPrivateDataDeInit failed (%d)", eError));
		return eError;
	}

	eError = OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
		sizeof(*psPerProc),
		psPerProc,
		psPerProc->hBlockAlloc);
	
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "FreePerProcessData: Couldn't free per-process data (%d)", eError));
		return eError;
	}

	return PVRSRV_OK;
}
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;
}