Ejemplo n.º 1
0
/*---------------------------------------------------------------------- 
 * Func : __alloc_mcpb 
 *
 * Desc : alloc a mcp buffer with specified length
 *
 * Parm : len : size of mcp buffer
 *
 * Retn : handle of mcp buffer
 *----------------------------------------------------------------------*/ 
static mcp_buff* __alloc_mcpb(unsigned int len)
{
    mcp_buff* p_buff;
    
    len += sizeof(mcp_buff);
        
#ifdef USE_DVR_MALLOC                                          
    p_buff =(len >= MAX_MCPB_LEN) ? dvr_malloc(len)
                                   : (mcp_buff*) kmalloc(len, GFP_KERNEL);
#else    
    p_buff = (len >= MAX_MCPB_LEN) ? (mcp_buff*) __get_free_pages(GFP_KERNEL, get_order(len))
                                   : (mcp_buff*) kmalloc(len, GFP_KERNEL);    
#endif

    if (p_buff)
    {
        mcpb_dbg("[MCP][BUF] Alloc Buffer %p (len = %d)\n", p_buff, len);
        p_buff->head = (unsigned char*) p_buff + sizeof(mcp_buff);
        p_buff->data = p_buff->head;
        p_buff->tail = p_buff->head;
        p_buff->end  = p_buff->head + len - sizeof(mcp_buff);
        p_buff->len  = 0;
    }

    return p_buff;
}
Ejemplo n.º 2
0
u8* _rtw_malloc(u32 sz)
{

	u8 	*pbuf=NULL;

#ifdef PLATFORM_LINUX
#ifdef RTK_DMP_PLATFORM
	if(sz > 0x4000)
		pbuf = (u8 *)dvr_malloc(sz);
	else
#endif		
		pbuf = kmalloc(sz,in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); 		

#endif	
#ifdef PLATFORM_FREEBSD
	pbuf = malloc(sz,M_DEVBUF,M_NOWAIT);	
#endif		
#ifdef PLATFORM_WINDOWS

	NdisAllocateMemoryWithTag(&pbuf,sz, RT_TAG);

#endif

#ifdef DBG_MEMORY_LEAK
#ifdef PLATFORM_LINUX
	if ( pbuf != NULL) {
		atomic_inc(&_malloc_cnt);
		atomic_add(sz, &_malloc_size);
	}
#endif
#endif /* DBG_MEMORY_LEAK */

	return pbuf;	
	
}
Ejemplo n.º 3
0
u8* _malloc(u32 sz)
{

	u8 	*pbuf;

#ifdef PLATFORM_LINUX
#ifdef RTK_DMP_PLATFORM
	if(sz > 0x4000)
		pbuf = dvr_malloc(sz);
	else
#endif
		pbuf = 	kmalloc(sz, /*GFP_KERNEL*/GFP_ATOMIC);

#endif	
	
#ifdef PLATFORM_WINDOWS

	NdisAllocateMemoryWithTag(&pbuf,sz, RT_TAG);

#endif
	if ( pbuf == NULL )
		printk( "[%s] allocate memory failed! sz = %d\n", __FUNCTION__, sz);
	
	return pbuf;	
	
}
Ejemplo n.º 4
0
u8* _rtw_malloc(u32 sz)
{

	u8 	*pbuf=NULL;

#ifdef PLATFORM_LINUX
#ifdef RTK_DMP_PLATFORM
	if(sz > 0x4000)
		pbuf = (u8 *)dvr_malloc(sz);
	else
#endif
		pbuf = kmalloc(sz, /*GFP_KERNEL*/GFP_ATOMIC);

#endif	
	
#ifdef PLATFORM_WINDOWS

	NdisAllocateMemoryWithTag(&pbuf,sz, RT_TAG);

#endif

#ifdef MEMORY_LEAK_DEBUG
#ifdef PLATFORM_LINUX
	if ( pbuf != NULL) {
		atomic_inc(&_malloc_cnt);
		atomic_add(sz, &_malloc_size);
	}
#endif
#endif /* MEMORY_LEAK_DEBUG */

	return pbuf;	
	
}
u8* _malloc(u32 sz)
{

	u8 	*pbuf;

#ifdef PLATFORM_LINUX
#ifdef RTK_DMP_PLATFORM
	if(sz > 0x4000)
		pbuf = dvr_malloc(sz);
	else
#endif
	pbuf = 	kmalloc(sz, /*GFP_KERNEL*/GFP_ATOMIC);

#endif	
	
#ifdef PLATFORM_WINDOWS

	NdisAllocateMemoryWithTag(&pbuf,sz, RT_TAG);

#endif

	return pbuf;	
	
}
Ejemplo n.º 6
0
#ifdef RTK_DMP_PLATFORM
if(sz > 0x4000)
		pbuf = (u8 *)dvr_malloc(sz);
	else
#endif		
		pbuf = kmalloc(sz,in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);