// // Description: // Allocate memory for driver log mechansim. // // Assumption: // Target address had been initalized to NULL pointer. // BOOLEAN AllocDrvLogMemory( IN PADAPTER pAdapter ) { u4Byte i; RT_STATUS status; PVOID pTmp; u4Byte Size; // // Allocate memory block to store pointers to DRV_LOG_POOL_T objects. // Size = LTYPE_TOTAL_COUNT * sizeof(PVOID); status = PlatformAllocateMemory(pAdapter, &pTmp, Size); if( RT_STATUS_SUCCESS != status ) { RT_TRACE(COMP_INIT, DBG_SERIOUS, ("AllocDrvLogMemory(): failed to allocate DRV_LOG_POOLS_HANDLE!!!\n")); return FALSE; } else { RT_TRACE(COMP_INIT, DBG_LOUD, ("AllocDrvLogMemory(): %p is allocated for DRV_LOG_POOLS_HANDLE\n", pTmp)); PlatformZeroMemory(pTmp, Size); SET_DRV_LOG_POOLS_HANDLE(pAdapter, (DRV_LOG_POOL_T**)pTmp); } // // Allocate DRV_LOG_POOL_T objects. // for(i = 0; i < (u4Byte)LTYPE_TOTAL_COUNT; i++) { Size = sizeof(DRV_LOG_POOL_T) + ( sizeof(DRV_LOG_DATA_IMP_T) << g_LogTypes[i].MaxLogCountPwr); status = PlatformAllocateMemory(pAdapter, &pTmp, Size); if( RT_STATUS_SUCCESS != status ) { RT_TRACE(COMP_INIT, DBG_SERIOUS, ("AllocDrvLogMemory(): failed driver log pool %d!!!\n", i)); return FALSE; } else { RT_TRACE(COMP_INIT, DBG_LOUD, ("AllocDrvLogMemory(): %p is allocated for driver log pool %d\n", pTmp, i)); PlatformZeroMemory(pTmp, Size); SET_DRV_LOG_POOL(pAdapter, i, pTmp); GET_DRV_LOG_POOL(pAdapter, i)->pLogDataRing = (PDRV_LOG_DATA_IMP_T)((pu1Byte)pTmp + sizeof(DRV_LOG_POOL_T)); RT_PRINT_DATA(COMP_INIT, DBG_TRACE, "driver log pool: ", (pu1Byte)pTmp, sizeof(DRV_LOG_POOL_T)); } } return TRUE; }
RT_STATUS MultiPortAllocateCloneRfdBuffer( PADAPTER pAdapter, PRT_RFD pRfd ) { RT_STATUS rtStatus = RT_STATUS_FAILURE; u4Byte MaxLen=pRfd->mbCloneRfdDataBuffer.Length; // Correctness Checking -------------------------------------- RT_ASSERT( pRfd->mbCloneRfdDataBuffer.Length != 0 && pRfd->mbCloneRfdDataBuffer.Buffer == NULL, ("DrvIFAssociateRFD: Wrong Parameters Observed!\n") ); // Get the non-shared memory --------------------------------- rtStatus = PlatformAllocateMemory( pAdapter, (PVOID*)&(pRfd->mbCloneRfdDataBuffer.Buffer), MaxLen ); return rtStatus; }
RT_STATUS MultiPortPrepareCloneRfd( PADAPTER pAdapter ) { RT_STATUS rtStatus = RT_STATUS_FAILURE; PRT_RFD pRfd = NULL; u4Byte i = 0; PMULTIPORT_COMMON_CONTEXT pMultiPortCommon = MultiPortGetCommonContext(pAdapter); const u4Byte SIZE_OF_CLONE_RFD_QUEUE = 256; do { // Allocate memory for the Multiport Clone RFD ------------------------------------------------- pMultiPortCommon->CloneRfdMemoryBuffer.Length = SIZE_OF_CLONE_RFD_QUEUE * sizeof(RT_RFD); rtStatus = PlatformAllocateMemory(pAdapter, &pMultiPortCommon->CloneRfdMemoryBuffer.Buffer, pMultiPortCommon->CloneRfdMemoryBuffer.Length ); if(rtStatus != RT_STATUS_SUCCESS) { RT_TRACE(COMP_INIT, DBG_SERIOUS, ("%s: MultiPort Clone RFD: Memory Allocation Failure !\n", __FUNCTION__)); break; } // --------------------------------------------------------------------------------------- // Insert the Clone RFDs into the queue -------------------------------------------------------- pMultiPortCommon->uNumberOfCloneRfds = SIZE_OF_CLONE_RFD_QUEUE; PlatformZeroMemory( pMultiPortCommon->CloneRfdMemoryBuffer.Buffer, pMultiPortCommon->CloneRfdMemoryBuffer.Length ); PlatformAcquireSpinLock(pAdapter,RT_RFD_SPINLOCK); pRfd = (PRT_RFD) pMultiPortCommon->CloneRfdMemoryBuffer.Buffer; for(i = 0; i < pMultiPortCommon->uNumberOfCloneRfds; i++) { RTInsertTailListWithCnt( &pMultiPortCommon->CloneRfdIdleQueue, &pRfd[i].List, &pMultiPortCommon->uCloneRfdIdleQueueSize ); } RT_TRACE(COMP_INIT, DBG_LOUD, ("MultiPortPrepareCloneRfd(), pMultiPortCommon->uCloneRfdIdleQueueSize = %d\n", pMultiPortCommon->uCloneRfdIdleQueueSize)); PlatformReleaseSpinLock(pAdapter,RT_RFD_SPINLOCK); // --------------------------------------------------------------------------------------- } while(FALSE); return rtStatus; }
// // ODM Memory relative API. // VOID ODM_AllocateMemory( IN PDM_ODM_T pDM_Odm, OUT PVOID *pPtr, IN u4Byte length ) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) *pPtr = kmalloc(length, GFP_ATOMIC); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE ) *pPtr = rtw_zvmalloc(length); #elif(DM_ODM_SUPPORT_TYPE & ODM_MP) PADAPTER Adapter = pDM_Odm->Adapter; PlatformAllocateMemory(Adapter, pPtr, length); #endif }
// // ODM Memory relative API. // void ODM_AllocateMemory( PDM_ODM_T pDM_Odm, void * *pPtr, u32 length ) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) *pPtr = kmalloc(length, GFP_ATOMIC); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE ) *pPtr = rtw_zvmalloc(length); #elif(DM_ODM_SUPPORT_TYPE & ODM_MP) struct rtw_adapter * Adapter = pDM_Odm->Adapter; PlatformAllocateMemory(Adapter, pPtr, length); #endif }
FRAME_BUF * FrameBuf_Alloc( IN u2Byte cap ) { FRAME_BUF *pBuf = NULL; u4Byte allocSize = sizeof(FRAME_BUF) + cap; PlatformAllocateMemory(NULL, (PVOID *)&pBuf, allocSize); if(!pBuf) return NULL; framebuf_Init(cap, 0, (pu1Byte)pBuf + sizeof(FRAME_BUF), 0, FRAME_BUF_DEFAULT_DBG_LEVEL, pBuf); return pBuf; }