#ifndef __OSPHEAP__
#define __OSPHEAP__

#define ECS_SM_DM_BASE_PHY_ADDR        0x007200000UL
#define PET_SM_DM_BASE_PHY_ADDR        0x008700000UL
#define APE_DM_BASE_PHY_ADDR           0x009400000UL //APCx(x:0-3):0x009400000+x*0x200000,2M per APC
#define SHARE_MEM_BASE_PHY_ADDR        0x009D00000UL
#define APE_PHY_BASE_PHY_ADDR          0x010000000UL
#define APE_TEXT_BASE_PHY_ADDR         0x090000000UL
#define ARM_APE_MSG_BASE_PHY_ADDR      0x0A0000000UL
#define APE_LOG_BASE_PHY_ADDR          0x0A8000000UL
#define RESERVED_BASE_PHY_ADDR         0x100000000UL
#define ARM_STACK_BASE_PHY_ADDR        0x100000000UL

#define LEN_OF_ECS_SM_DM               0x000060000UL   //sm(0x20000) + dm(0x40000)
#define LEN_OF_PET_SM_DM               0x000060000UL   //sm(0x20000) + dm(0x40000)
#define LEN_OF_APE_DM                  0x000800000UL
#define LEN_OF_SHARE_MEM               0x000800000UL
#define LEN_OF_APE_PHY                 0x080000000UL
#define LEN_OF_APE_TEXT                0x010000000UL
#define LEN_OF_ARM_APE_MSG             0x008000000UL
#define LEN_OF_APE_LOG                 0x010000000UL
#define LEN_OF_ARM_STACK               0x100000000UL

#define OSP_DISPLAY_MAX_LEN   0x400
#define OSP_DISPLAY_PAGE_LEN  0x1000

typedef enum
{
    ECS_SM = 0,   //actual ECS_SM_DM 384 total  SM:128KB:0x007200000UL,DM:256KB:0x007220000UL
    PET_SM,       //actual PET_SM_DM 384 total  SM:128KB:0x008700000UL,DM:256KB:0x008720000UL
    APE_DM,
    SHARE_MEM,
    APE_PHY,
    APE_TEXT,
    ARM_APE_MSG,
    APE_LOG,
    ARM_STACK,
    MEM_RESERVE
}module_type_e;

/******************************************************************
*    Input(s):    
*       module：module_type_e类型枚举值，FAPI消息类型为ARM_APE_MSG；
*       virt_addr：待转换的虚拟地址。
*
*    Output(s):
*        phy_addr：物理地址
*
*    Returns:
*        0：成功
*      非0：失败
********************************************************************/
int32_t osp_virt_to_phy(module_type_e       module, uint64_t virt_addr, uint64_t *phy_addr);

/******************************************************************
*    Input(s):    
*       module：module_type_e类型枚举值，FAPI消息类型为ARM_APE_MSG；
*       phy_addr：待转换的物理地址。
*
*    Output(s):
*        virt_addr：虚拟地址
*
*    Returns:
*        0：成功
*      非0：失败
********************************************************************/
int32_t osp_phy_to_virt(module_type_e       module, uint64_t phy_addr, uint64_t *virt_addr);

/******************************************************************
*    Input(s):    
*       addr：虚拟地址；
*       len：长度。
*
*    Output(s):
*        <none>
*
*    Returns:
*        <none>
********************************************************************/
void   osp_flush_dcache_area(void * volatile addr, uint64_t volatile len);
void   osp_clean_dcache_area(void * volatile addr, uint64_t volatile len);

/******************************************************************
*    Input(s): 
*       module：module_type_e类型枚举值，FAPI消息类型为ARM_APE_MSG；
*       addr：虚拟地址；
*       len：长度。
*
*    Output(s):
*        <none>
*
*    Returns:
*        0：成功
*      非0：失败
********************************************************************/
int32_t osp_invalid_dcache_area(module_type_e          module, uint64_t virt_addr, uint64_t len);

/**********************************************************************************************/
/*                                     testmac interface                                      */
void *get_static_mem(module_type_e      module, uint64_t *len);
void *osp_heap_mem_init(char *pbuf, uint64_t size,void *head_of_static_mem,module_type_e module);
int8_t *osp_alloc_heap_mem(void *heap, uint32_t size);
int32_t osp_free_heap_mem(void *heap, char *pbuf);
int32_t osp_show_heap_mem(void *heap);
int32_t osp_display_phy_mem(uint64_t phy_addr, uint32_t len);

#endif

