/*! ****************************************************************************** @Function rman_GetResource ******************************************************************************/ static IMG_VOID * rman_GetResource( IMG_HANDLE hResBHandle, IMG_UINT32 ui32ResId, IMG_UINT32 ui32TypeId, IMG_HANDLE * phResHandle ) { RMAN_sBucket * psBucket = (RMAN_sBucket *) hResBHandle; RMAN_sResource * psResource; IMG_RESULT i32Result; IMG_ASSERT(ui32ResId <= RMAN_CRESID_MAX_RES_ID); /* Loop over the resources in this bucket till we find the required id...*/ //SYSOSKM_DisableInt(); SYSOSKM_LockMutex(globalMutext); i32Result = IDGEN_GetHandle(psBucket->hIdGenerator, ui32ResId, (void**)&psResource); SYSOSKM_UnlockMutex(globalMutext); //SYSOSKM_EnableInt(); if(i32Result != IMG_SUCCESS) { IMG_ASSERT(!"failed to get RMAN resource"); return IMG_NULL; } /* If the resource handle is required...*/ if (phResHandle != IMG_NULL) { /* Return it...*/ *phResHandle = psResource; } /* If the resource was not found...*/ IMG_ASSERT(psResource != IMG_NULL); IMG_ASSERT((IMG_VOID*)psResource != &psBucket->sResList); if ( (psResource == IMG_NULL) || ((IMG_VOID*)psResource == &psBucket->sResList) ) { return IMG_NULL; } /* Cross check the type...*/ IMG_ASSERT(ui32TypeId == psResource->ui32TypeId); /* Return the resource....*/ return psResource->pvParam; }
/*! ****************************************************************************** @Function POOL_ResDestroy1 ******************************************************************************/ IMG_RESULT POOL_ResDestroy1( IMG_HANDLE hPoolHandle, IMG_UINT32 ui32ResId, IMG_BOOL bForce ) { POOL_sResPool * psResPool = hPoolHandle; IMG_UINT32 ui32Result; IMG_HANDLE hPoolResHandle; IMG_ASSERT(gInitialised); IMG_ASSERT(psResPool != IMG_NULL); if (!gInitialised || psResPool == IMG_NULL) { ui32Result = IMG_ERROR_INVALID_PARAMETERS; goto error_nolock; } /* Lock the pool...*/ SYSOSKM_LockMutex(psResPool->hMutexHandle); ui32Result = IDGEN_GetHandle(psResPool->hIdGenHandle, ui32ResId, &hPoolResHandle); IMG_ASSERT(ui32Result == IMG_SUCCESS); if (ui32Result != IMG_SUCCESS) { /* Unlock the pool...*/ SYSOSKM_UnlockMutex(psResPool->hMutexHandle); return ui32Result; } /* Unlock the pool...*/ SYSOSKM_UnlockMutex(psResPool->hMutexHandle); /* Call on to destroy resource...*/ return POOL_ResDestroy(hPoolResHandle, bForce); error_nolock: return ui32Result; }