示例#1
0
/* PVRSRVConnectionConnect*/
PVRSRV_ERROR PVRSRVConnectionConnect(IMG_PVOID *ppvPrivData, IMG_PVOID pvOSData)
{
	PVRSRV_DATA *psPVRSRVData = PVRSRVGetPVRSRVData();
	CONNECTION_DATA *psConnection;
	PVRSRV_ERROR eError = PVRSRV_OK;

	/* Allocate per-process data area */
	psConnection = OSAllocMem(sizeof(*psConnection));
	if (psConnection == IMG_NULL)
	{
		PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionConnect: Couldn't allocate per-process data (%d)", eError));
		return PVRSRV_ERROR_OUT_OF_MEMORY;
	}
	OSMemSet(psConnection, 0, sizeof(*psConnection));

	/* Call environment specific per process init function */
	eError = OSConnectionPrivateDataInit(&psConnection->hOsPrivateData, pvOSData);
	if (eError != PVRSRV_OK)
	{
		 PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionConnect: OSConnectionPrivateDataInit failed (%d)", eError));
		goto failure;
	}

	/* Allocate handle base for this process */
	eError = PVRSRVAllocHandleBase(&psConnection->psHandleBase);
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionConnect: Couldn't allocate handle base for process (%d)", eError));
		goto failure;
	}

	/* Create a resource manager context for the process */
	eError = PVRSRVResManConnect(psPVRSRVData->hResManDeferContext, &psConnection->hResManContext);
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionConnect: Couldn't register with the resource manager"));
		goto failure;
	}

	*ppvPrivData = psConnection;

	return eError;

failure:
	(IMG_VOID)FreeConnectionData(psConnection);
	return eError;
}
示例#2
0
/* PVRSRVConnectionDisconnect */
IMG_VOID PVRSRVConnectionDisconnect(IMG_PVOID pvDataPtr)
{
	PVRSRV_ERROR eError;
	CONNECTION_DATA *psConnection = pvDataPtr;

	/* Close the Resource Manager connection */
	PVRSRVResManDisconnect(psConnection->hResManContext);
	
	/* Free the connection data */
	eError = FreeConnectionData(psConnection);
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionDisconnect: Error freeing per-process data"));
	}

	/* FIXME: Is this still required? */
	eError = PVRSRVPurgeHandles(KERNEL_HANDLE_BASE);
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionDisconnect: Purge of global handle pool failed (%d)", eError));
	}
}
/* PVRSRVConnectionDisconnect */
IMG_VOID PVRSRVConnectionDisconnect(IMG_PVOID pvDataPtr)
{
	PVRSRV_ERROR eError;
	CONNECTION_DATA *psConnection = pvDataPtr;

	/* Close the Resource Manager connection */
	PVRSRVResManDisconnect(psConnection->hResManContext);

	/*
		Unregister with the sync core. Logically this is after resman to
		ensure that any sync block that haven't been freed by the app will
		be freed by resman 1st.
		However, due to the fact the resman can defer the free the Sync core
		needs to handle the case where the connection data is destroyed while
		Sync blocks are still in it.
	*/
	SyncUnregisterConnection(psConnection->psSyncConnectionData);

	/*
		Unregister with the PDump core, see the note above about logical order
		and refcounting as it also applies to the PDump connection data
	*/
	PDumpUnregisterConnection(psConnection->psPDumpConnectionData);

	/* Free the connection data */
	eError = FreeConnectionData(psConnection);
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionDisconnect: Error freeing per-process data"));
	}

	eError = PVRSRVPurgeHandles(KERNEL_HANDLE_BASE);
	if (eError != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "PVRSRVConnectionDisconnect: Purge of global handle pool failed (%d)", eError));
	}
}