Esempio n. 1
0
/*!
******************************************************************************

 @Function	PVRSRVFreeHandleBase

 @Description	Free a handle base structure

 @Input 	psBase - pointer to handle base structure

 @Return	Error code or PVRSRV_OK

******************************************************************************/
PVRSRV_ERROR PVRSRVFreeHandleBase(PVRSRV_HANDLE_BASE *psBase)
{
	PVRSRV_ERROR eError;

	PVR_ASSERT(gpsHandleFuncs);

	/* Make sure all handles have been freed before destroying the handle base */
	eError = gpsHandleFuncs->pfnIterateOverHandles(psBase->psImplBase,
						       &FreeHandleDataWrapper,
						       (IMG_VOID *)psBase);
	if (eError != PVRSRV_OK)
	{
		goto err;
	}

	if (psBase->psHashTab != IMG_NULL)
	{
		HASH_Delete(psBase->psHashTab);
	}

	eError = gpsHandleFuncs->pfnDestroyHandleBase(psBase->psImplBase);
	if (eError != PVRSRV_OK)
	{
		goto err;
	}

	OSFreeMem(psBase);

	eError = PVRSRV_OK;
err:
	return eError;
}
Esempio n. 2
0
/*!
******************************************************************************

 @Function	PVRSRVTimeTraceDeinit

 @Description

  De-initialise the timed trace subsystem.

 @Return Error

******************************************************************************/
IMG_VOID PVRSRVTimeTraceDeinit(IMG_VOID)
{
	PVRSRVTimeTraceBufferDestroy(KERNEL_ID);
	/* Free any buffers the where created at alloc item time */
	HASH_Iterate(g_psBufferTable, _PVRSRVTimeTraceBufferDestroy);
	HASH_Delete(g_psBufferTable);
	OSFuncHighResTimerDestroy(g_psTimer);
}
Esempio n. 3
0
IMG_VOID
RA_Delete (RA_ARENA *pArena)
{
	IMG_UINT32 uIndex;

	PVR_ASSERT(pArena != IMG_NULL);

	if (pArena == IMG_NULL)
	{
		PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: invalid parameter - pArena"));
		return;
	}

	PVR_DPF ((PVR_DBG_MESSAGE,
			  "RA_Delete: name='%s'", pArena->name));

	for (uIndex=0; uIndex<FREE_TABLE_LIMIT; uIndex++)
		pArena->aHeadFree[uIndex] = IMG_NULL;

	while (pArena->pHeadSegment != IMG_NULL)
	{
		BT *pBT = pArena->pHeadSegment;

		if (pBT->type != btt_free)
		{
			PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: allocations still exist in the arena that is being destroyed"));
			PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing alocations before destroying devmemcontext"));
			PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x%x size=0x%x", pBT->base, pBT->uSize));
		}

		_SegmentListRemove (pArena, pBT);
		OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pBT, IMG_NULL);
		
#ifdef RA_STATS
		pArena->sStatistics.uSpanCount--;
#endif
	}
#if defined(CONFIG_PROC_FS) && defined(DEBUG)
	{
		IMG_VOID (*pfnRemoveProcEntrySeq)(struct proc_dir_entry*);

		pfnRemoveProcEntrySeq = pArena->bInitProcEntry ? RemoveProcEntrySeq : RemovePerProcessProcEntrySeq;

		if (pArena->pProcInfo != 0)
		{
			pfnRemoveProcEntrySeq( pArena->pProcInfo );
		}

		if (pArena->pProcSegs != 0)
		{
			pfnRemoveProcEntrySeq( pArena->pProcSegs );
		}
	}
#endif
	HASH_Delete (pArena->pSegmentHash);
	OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RA_ARENA), pArena, IMG_NULL);
	
}
Esempio n. 4
0
enum PVRSRV_ERROR PVRSRVPerProcessDataDeInit(void)
{
	if (psHashTab != NULL) {
		HASH_Delete(psHashTab);
		psHashTab = NULL;
	}

	return PVRSRV_OK;
}
static enum PVRSRV_ERROR BM_DestroyContextCallBack(void *pvParam, u32 ui32Param)
{
	struct BM_CONTEXT *pBMContext = pvParam;
	struct BM_CONTEXT **ppBMContext;
	struct BM_HEAP *psBMHeap, *psTmpBMHeap;
	struct PVRSRV_DEVICE_NODE *psDeviceNode;

	PVR_UNREFERENCED_PARAMETER(ui32Param);

	psDeviceNode = pBMContext->psDeviceNode;

	psBMHeap = pBMContext->psBMHeap;
	while (psBMHeap) {
		if (psBMHeap->ui32Attribs &
		    (PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG |
		      PVRSRV_BACKINGSTORE_LOCALMEM_CONTIG)) {
			if (psBMHeap->pImportArena)
				RA_Delete(psBMHeap->pImportArena);
		} else {
			PVR_DPF(PVR_DBG_ERROR, "BM_DestroyContext: "
					   "backing store type unsupported");
			return PVRSRV_ERROR_GENERIC;
		}

		psDeviceNode->pfnMMUDelete(psBMHeap->pMMUHeap);

		psTmpBMHeap = psBMHeap;

		psBMHeap = psBMHeap->psNext;

		OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BM_HEAP),
			  psTmpBMHeap, NULL);
	}

	if (pBMContext->psMMUContext)
		psDeviceNode->pfnMMUFinalise(pBMContext->psMMUContext);

	if (pBMContext->pBufferHash)
		HASH_Delete(pBMContext->pBufferHash);

	if (pBMContext == psDeviceNode->sDevMemoryInfo.pBMKernelContext) {
		psDeviceNode->sDevMemoryInfo.pBMKernelContext = NULL;
	} else {
		for (ppBMContext = &psDeviceNode->sDevMemoryInfo.pBMContext;
		     *ppBMContext; ppBMContext = &((*ppBMContext)->psNext))
			if (*ppBMContext == pBMContext) {
				*ppBMContext = pBMContext->psNext;
				break;
			}
	}

	OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BM_CONTEXT),
		  pBMContext, NULL);

	return PVRSRV_OK;
}
Esempio n. 6
0
/*!
******************************************************************************

 @Function	PVRSRVPerProcessDataDeInit

 @Description	De-initialise per-process data management

 @Return	Error code, or PVRSRV_OK

******************************************************************************/
PVRSRV_ERROR PVRSRVPerProcessDataDeInit(IMG_VOID)
{
	/* Destroy per-process data area hash table */
	if (psHashTab != IMG_NULL)
	{
		/* Free the hash table */
		HASH_Delete(psHashTab);
		psHashTab = IMG_NULL;
	}

	return PVRSRV_OK;
}
Esempio n. 7
0
PVRSRV_ERROR PVRSRVPerProcessDataDeInit(IMG_VOID)
{
	
	if (psHashTab != IMG_NULL)
	{
		
		HASH_Delete(psHashTab);
		psHashTab = IMG_NULL;
	}

	return PVRSRV_OK;
}
Esempio n. 8
0
static PVRSRV_ERROR BM_DestroyContextCallBack(IMG_PVOID		pvParam,
											  IMG_UINT32	ui32Param)
{
	BM_CONTEXT *pBMContext = pvParam;
	PVRSRV_DEVICE_NODE *psDeviceNode;
	PVRSRV_ERROR eError;
	PVR_UNREFERENCED_PARAMETER(ui32Param);

	

	psDeviceNode = pBMContext->psDeviceNode;

	

	eError = List_BM_HEAP_PVRSRV_ERROR_Any_va(pBMContext->psBMHeap,
										&BM_DestroyContextCallBack_AnyVaCb,
										psDeviceNode);
	if (eError != PVRSRV_OK)
	{
		return eError;
	}
	

	if (pBMContext->psMMUContext)
	{
		psDeviceNode->pfnMMUFinalise(pBMContext->psMMUContext);
	}

	

	if (pBMContext->pBufferHash)
	{
		HASH_Delete(pBMContext->pBufferHash);
	}

	if (pBMContext == psDeviceNode->sDevMemoryInfo.pBMKernelContext)
	{
		
		psDeviceNode->sDevMemoryInfo.pBMKernelContext = IMG_NULL;
	}
	else
	{
		
		List_BM_CONTEXT_Remove(pBMContext);
	}

	OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BM_CONTEXT), pBMContext, IMG_NULL);
	

	return PVRSRV_OK;
}
Esempio n. 9
0
/**
 * @brief Function to remove the cvar and free the space
 */
bool Cvar_Delete (const char* varName)
{
	unsigned hash;

	hash = Com_HashKey(varName, CVAR_HASH_SIZE);
	for (cvar_t** anchor = &cvarVarsHash[hash]; *anchor; anchor = &(*anchor)->hash_next) {
		cvar_t* const var = *anchor;
		if (!Q_strcasecmp(varName, var->name)) {
			cvarChangeListener_t* changeListener;
			if (var->flags != 0) {
				Com_Printf("Can't delete the cvar '%s' - it's a special cvar\n", varName);
				return false;
			}
			HASH_Delete(anchor);
			if (var->prev) {
				assert(var->prev->next == var);
				var->prev->next = var->next;
			} else
				cvarVars = var->next;
			if (var->next) {
				assert(var->next->prev == var);
				var->next->prev = var->prev;
			}

			for (CvarListeners::iterator i = cvarListeners.begin(); i != cvarListeners.end(); ++i) {
				(*i)->onDelete(var);
			}

			Mem_Free(var->name);
			Mem_Free(var->string);
			Mem_Free(var->description);
			Mem_Free(var->oldString);
			Mem_Free(var->defaultString);
			/* latched cvars should not be removable */
			assert(var->latchedString == nullptr);
			changeListener = var->changeListener;
			while (changeListener) {
				cvarChangeListener_t* changeListener2 = changeListener->next;
				Mem_Free(changeListener);
				changeListener = changeListener2;
			}
			Mem_Free(var);

			return true;
		}
	}
	Com_Printf("Cvar '%s' wasn't found\n", varName);
	return false;
}
Esempio n. 10
0
void RA_Delete(struct RA_ARENA *pArena)
{
	u32 uIndex;

	PVR_ASSERT(pArena != NULL);

	if (pArena == NULL) {
		PVR_DPF(PVR_DBG_ERROR,
			 "RA_Delete: invalid parameter - pArena");
		return;
	}

	PVR_DPF(PVR_DBG_MESSAGE, "RA_Delete: name='%s'", pArena->name);

	for (uIndex = 0; uIndex < FREE_TABLE_LIMIT; uIndex++)
		pArena->aHeadFree[uIndex] = NULL;

	while (pArena->pHeadSegment != NULL) {
		struct BT *pBT = pArena->pHeadSegment;
		PVR_ASSERT(pBT->type == btt_free);
		_SegmentListRemove(pArena, pBT);
		OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BT), pBT,
			  NULL);
#ifdef RA_STATS
		pArena->sStatistics.uSpanCount--;
#endif
	}
#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_DEBUG_EXTRA)
	{
		void (*pfnRemoveProcEntry) (const char *);

		pfnRemoveProcEntry =
		    pArena->
		    bInitProcEntry ? RemoveProcEntry :
		    RemovePerProcessProcEntry;

		if (pArena->szProcInfoName[0] != 0)
			pfnRemoveProcEntry(pArena->szProcInfoName);

		if (pArena->szProcSegsName[0] != 0)
			pfnRemoveProcEntry(pArena->szProcSegsName);
	}
#endif
	HASH_Delete(pArena->pSegmentHash);
	OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct RA_ARENA), pArena,
		  NULL);
}
Esempio n. 11
0
struct RA_ARENA *RA_Create(char *name, u32 base, size_t uSize,
			   struct BM_MAPPING *psMapping, size_t uQuantum,
			   IMG_BOOL(*imp_alloc) (void *, size_t uSize,
						 size_t *pActualSize,
						 struct BM_MAPPING **ppsMapping,
						 u32 _flags, u32 *pBase),
			   void (*imp_free) (void *, u32, struct BM_MAPPING *),
			   void(*backingstore_free) (void *, u32, u32, void *),
			   void *pImportHandle)
{
	struct RA_ARENA *pArena;
	struct BT *pBT;
	int i;

	PVR_DPF(PVR_DBG_MESSAGE, "RA_Create: "
		 "name='%s', base=0x%x, uSize=0x%x, alloc=0x%x, free=0x%x",
		 name, base, uSize, imp_alloc, imp_free);

	if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
		       sizeof(*pArena),
		       (void **) &pArena, NULL) != PVRSRV_OK)
		goto arena_fail;

	pArena->name = name;
	pArena->pImportAlloc =
	    (imp_alloc != NULL) ? imp_alloc : _RequestAllocFail;
	pArena->pImportFree = imp_free;
	pArena->pBackingStoreFree = backingstore_free;
	pArena->pImportHandle = pImportHandle;
	for (i = 0; i < FREE_TABLE_LIMIT; i++)
		pArena->aHeadFree[i] = NULL;
	pArena->pHeadSegment = NULL;
	pArena->pTailSegment = NULL;
	pArena->uQuantum = uQuantum;

#ifdef RA_STATS
	pArena->sStatistics.uSpanCount = 0;
	pArena->sStatistics.uLiveSegmentCount = 0;
	pArena->sStatistics.uFreeSegmentCount = 0;
	pArena->sStatistics.uFreeResourceCount = 0;
	pArena->sStatistics.uTotalResourceCount = 0;
	pArena->sStatistics.uCumulativeAllocs = 0;
	pArena->sStatistics.uCumulativeFrees = 0;
	pArena->sStatistics.uImportCount = 0;
	pArena->sStatistics.uExportCount = 0;
#endif

#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_DEBUG_EXTRA)
	if (strcmp(pArena->name, "") != 0) {
		int ret;
		int (*pfnCreateProcEntry) (const char *, read_proc_t,
					   write_proc_t, void *);

		pArena->bInitProcEntry =
		    !PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL);

		pfnCreateProcEntry = pArena->bInitProcEntry ? CreateProcEntry :
					    CreatePerProcessProcEntry;

		ret = snprintf(pArena->szProcInfoName,
			     sizeof(pArena->szProcInfoName), "ra_info_%s",
			     pArena->name);
		if (ret > 0 && ret < sizeof(pArena->szProcInfoName)) {
			(void)pfnCreateProcEntry(ReplaceSpaces
					       (pArena->szProcInfoName),
					       RA_DumpInfo, NULL, pArena);
		} else {
			pArena->szProcInfoName[0] = 0;
			PVR_DPF(PVR_DBG_ERROR, "RA_Create: "
			      "couldn't create ra_info proc entry for arena %s",
				 pArena->name);
		}

		ret = snprintf(pArena->szProcSegsName,
			     sizeof(pArena->szProcSegsName), "ra_segs_%s",
			     pArena->name);
		if (ret > 0 && ret < sizeof(pArena->szProcInfoName)) {
			(void)pfnCreateProcEntry(ReplaceSpaces
					       (pArena->szProcSegsName),
					       RA_DumpSegs, NULL, pArena);
		} else {
			pArena->szProcSegsName[0] = 0;
			PVR_DPF(PVR_DBG_ERROR, "RA_Create: "
			      "couldn't create ra_segs proc entry for arena %s",
				 pArena->name);
		}
	}
#endif

	pArena->pSegmentHash = HASH_Create(MINIMUM_HASH_SIZE);
	if (pArena->pSegmentHash == NULL)
		goto hash_fail;
	if (uSize > 0) {
		uSize = (uSize + uQuantum - 1) / uQuantum * uQuantum;
		pBT = _InsertResource(pArena, base, uSize);
		if (pBT == NULL)
			goto insert_fail;
		pBT->psMapping = psMapping;

	}
	return pArena;

insert_fail:
	HASH_Delete(pArena->pSegmentHash);
hash_fail:
	OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct RA_ARENA), pArena,
		  NULL);
arena_fail:
	return NULL;
}
Esempio n. 12
0
RA_ARENA *
RA_Create (IMG_CHAR *name,
		   IMG_UINTPTR_T base,
		   IMG_SIZE_T uSize,
		   BM_MAPPING *psMapping,
		   IMG_SIZE_T uQuantum,
		   IMG_BOOL (*imp_alloc)(IMG_VOID *, IMG_SIZE_T uSize, IMG_SIZE_T *pActualSize,
		                     BM_MAPPING **ppsMapping, IMG_UINT32 _flags, IMG_UINTPTR_T *pBase),
		   IMG_VOID (*imp_free) (IMG_VOID *, IMG_UINTPTR_T, BM_MAPPING *),
		   IMG_VOID (*backingstore_free) (IMG_VOID*, IMG_SIZE_T, IMG_SIZE_T, IMG_HANDLE),
		   IMG_VOID *pImportHandle)
{
	RA_ARENA *pArena;
	BT *pBT;
	IMG_INT i;

	PVR_DPF ((PVR_DBG_MESSAGE,
			  "RA_Create: name='%s', base=0x%x, uSize=0x%x, alloc=0x%x, free=0x%x",
			  name, base, uSize, (IMG_UINTPTR_T)imp_alloc, (IMG_UINTPTR_T)imp_free));


	if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
					 sizeof (*pArena),
					 (IMG_VOID **)&pArena, IMG_NULL,
					 "Resource Arena") != PVRSRV_OK)
	{
		goto arena_fail;
	}

	pArena->name = name;
	pArena->pImportAlloc = (imp_alloc!=IMG_NULL) ? imp_alloc : &_RequestAllocFail;
	pArena->pImportFree = imp_free;
	pArena->pBackingStoreFree = backingstore_free;
	pArena->pImportHandle = pImportHandle;
	for (i=0; i<FREE_TABLE_LIMIT; i++)
		pArena->aHeadFree[i] = IMG_NULL;
	pArena->pHeadSegment = IMG_NULL;
	pArena->pTailSegment = IMG_NULL;
	pArena->uQuantum = uQuantum;

#ifdef RA_STATS
	pArena->sStatistics.uSpanCount = 0;
	pArena->sStatistics.uLiveSegmentCount = 0;
	pArena->sStatistics.uFreeSegmentCount = 0;
	pArena->sStatistics.uFreeResourceCount = 0;
	pArena->sStatistics.uTotalResourceCount = 0;
	pArena->sStatistics.uCumulativeAllocs = 0;
	pArena->sStatistics.uCumulativeFrees = 0;
	pArena->sStatistics.uImportCount = 0;
	pArena->sStatistics.uExportCount = 0;
#endif

#if defined(CONFIG_PROC_FS) && defined(DEBUG)
	if(strcmp(pArena->name,"") != 0)
	{
		IMG_INT ret;
		IMG_CHAR szProcInfoName[PROC_NAME_SIZE];
		IMG_CHAR szProcSegsName[PROC_NAME_SIZE];
		struct proc_dir_entry* (*pfnCreateProcEntrySeq)(const IMG_CHAR *,
										 IMG_VOID*,
										 pvr_next_proc_seq_t,
										 pvr_show_proc_seq_t,
										 pvr_off2element_proc_seq_t,
										 pvr_startstop_proc_seq_t,
										 write_proc_t);

		pArena->bInitProcEntry = !PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL);

		
		pfnCreateProcEntrySeq = pArena->bInitProcEntry ? CreateProcEntrySeq : CreatePerProcessProcEntrySeq;

		ret = snprintf(szProcInfoName, sizeof(szProcInfoName), "ra_info_%s", pArena->name);
		if (ret > 0 && ret < sizeof(szProcInfoName))
		{
			pArena->pProcInfo =  pfnCreateProcEntrySeq(ReplaceSpaces(szProcInfoName), pArena, NULL,
											 RA_ProcSeqShowInfo, RA_ProcSeqOff2ElementInfo, NULL, NULL);
		}
		else
		{
			pArena->pProcInfo = 0;
			PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_info proc entry for arena %s", pArena->name));
		}

		ret = snprintf(szProcSegsName, sizeof(szProcSegsName), "ra_segs_%s", pArena->name);
		if (ret > 0 && ret < sizeof(szProcInfoName))
		{
			pArena->pProcSegs = pfnCreateProcEntrySeq(ReplaceSpaces(szProcSegsName), pArena, NULL,
											 RA_ProcSeqShowRegs, RA_ProcSeqOff2ElementRegs, NULL, NULL);
		}
		else
		{
			pArena->pProcSegs = 0;
			PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_segs proc entry for arena %s", pArena->name));
		}
	}
#endif 

	pArena->pSegmentHash = HASH_Create (MINIMUM_HASH_SIZE);
	if (pArena->pSegmentHash==IMG_NULL)
	{
		goto hash_fail;
	}
	if (uSize>0)
	{
		uSize = (uSize + uQuantum - 1) / uQuantum * uQuantum;
		pBT = _InsertResource (pArena, base, uSize);
		if (pBT == IMG_NULL)
		{
			goto insert_fail;
		}
		pBT->psMapping = psMapping;

	}
	return pArena;

insert_fail:
	HASH_Delete (pArena->pSegmentHash);
hash_fail:
	OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RA_ARENA), pArena, IMG_NULL);
	
arena_fail:
	return IMG_NULL;
}