/**
******************************************************************************************************************************************************************************************
*@file                       btmem.h
*@author         
*@data                       
*@version                    v1.0
*@par Copyright(c):
*
*@par History:
*     version:author,date,desc
*     v1.0   :create this file
*
*******************************************************************************************************************************************************************************************
*/
#ifndef _BTMEM_H_
#define _BTMEM_H_

#define ORDER_MIN			CONFIG_ORDER_MIN/* etc, 3. 8 octet min block */
#define ORDER_MAX			CONFIG_ORDER_MAX/* etc, 14 */
#define POOL_SIZEB			(1 << ORDER_MAX)/* 13->8K,14->16K,20->1M,25->32M */
#define BH_SIZE				((1 << (ORDER_MAX - ORDER_MIN + 1)) - 1)/* Binary tree leaf count */
#define BH_SIZET 			((BH_SIZE + 1) >> 3)/* 1bit each, 0 is available, 1 is split or used, last +1 is 1st pendding */
#define TOTAL_POOL			((POOL_SIZEB + sizeof(UINT32) - 1) / sizeof(UINT32))
#define TOTAL_BH			((BH_SIZET + sizeof(UINT32) - 1) / sizeof(UINT32))

#define ORDER_MAX2			CONFIG_ORDER_MAX2
#define POOL_SIZEB2			(1 << ORDER_MAX2)/* 13->8K,14->16K,20->1M,25->32M */
#define BH_SIZE2			((1 << (ORDER_MAX2 - ORDER_MIN + 1)) - 1)/* Binary tree leaf count */
#define BH_SIZET2 			((BH_SIZE2 + 1) >> 3)/* 1bit each, 0 is available, 1 is split or used, last +1 is 1st pendding */
#define TOTAL_POOL2			((POOL_SIZEB2 + sizeof(UINT32) - 1) / sizeof(UINT32))
#define TOTAL_BH2			((BH_SIZET2 + sizeof(UINT32) - 1) / sizeof(UINT32))

struct Buddy_Pool{
	UINT32 order_min;
	UINT32 order_max;
	UINT32 *pool;
	UINT32 pool_sizeb;
	UINT32 *bh;
};

#endif
