/*! ****************************************************************************** @Function PVRSRVHandleDeInit @Description De-initialise handle management @Return Error code or PVRSRV_OK ******************************************************************************/ PVRSRV_ERROR PVRSRVHandleDeInit(IMG_VOID) { PVRSRV_ERROR eError = PVRSRV_OK; if (gpsHandleFuncs != IMG_NULL) { if (gpsKernelHandleBase != IMG_NULL) { eError = PVRSRVFreeHandleBase(gpsKernelHandleBase); if (eError == PVRSRV_OK) { gpsKernelHandleBase = IMG_NULL; } else { PVR_DPF((PVR_DBG_ERROR, "PVRSRVHandleDeInit: FreeHandleBase failed (%s)", PVRSRVGetErrorStringKM(eError))); } } if (eError == PVRSRV_OK) { gpsHandleFuncs = IMG_NULL; } } else { /* If we don't have a handle function table we shouldn't have a handle base either */ PVR_ASSERT(gpsKernelHandleBase == IMG_NULL); } return eError; }
/*! ****************************************************************************** @Function FreeConnectionData @Description Free a connection data area @Input psConnection - pointer to connection data area @Return Error code, or PVRSRV_OK ******************************************************************************/ static PVRSRV_ERROR FreeConnectionData(CONNECTION_DATA *psConnection) { PVRSRV_ERROR eError; PVR_ASSERT(psConnection != IMG_NULL); if (psConnection == IMG_NULL) { PVR_DPF((PVR_DBG_ERROR, "FreeConnectionData: invalid parameter")); return PVRSRV_ERROR_INVALID_PARAMS; } /* Free handle base for this connection */ if (psConnection->psHandleBase != IMG_NULL) { eError = PVRSRVFreeHandleBase(psConnection->psHandleBase); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "FreeConnectionData: Couldn't free handle base for connection (%d)", eError)); return eError; } } /* Call environment specific per process deinit function */ eError = OSConnectionPrivateDataDeInit(psConnection->hOsPrivateData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "FreeConnectionData: OSConnectionPrivateDataDeInit failed (%d)", eError)); return eError; } OSFreeMem(psConnection); return PVRSRV_OK; }
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; }
/*! ****************************************************************************** @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; }