#ifndef __ARM_INTERFACE_H__
#define __ARM_INTERFACE_H__

typedef int OSP_STATUS;

/********************** header files **********************/
#include "msg_transfer_layer.h"
#include "ospHeap.h"

typedef enum
{
    ZERO_FLAG = 0,      /*0标志*/
    TRUE_FLAG           /*1 标志*/
}clk_flag_e;

typedef enum
{
    CLK_DISABLE = 0,    /* clock unuseable status */
    CLK_WARM_UP = 1,    /* warm up status */
    CLK_TRACKING,       /* tracking status */
    CLK_HOLD_OVER       /* hold over status */
}clk_sync_state_e;

typedef struct
{
    uint32_t common_alarm;
    uint32_t hold_over_time;
    clk_sync_state_e status;
}clock_module_status_s;

/****************** Msg_transfer function *****************/
/*
name: msg_transfer_mem_init
para: null
brief: msg_transfer memory init(before call msg_transfer_init)
*/
void msg_transfer_mem_init(void);

/*
name: ucp_handshake
para: null
brief: handshake with host(after call msg_transfer_init)
*/
void ucp_handshake(void);

/*
name: rx_callback_oam
para: Input: buf: the address of the data
para: Input: payloadSize: the length of the data
brief: ape/rfm log receive callback
*/
uint32_t rx_callback_oam(const char* buf,uint32_t payloadSize);

/********************** Init function *********************/
/*
name: osp_init
para: null
brief: osp function init
*/
OSP_STATUS osp_init();

/********************** set task function *********************/
/*
name: osp_set_taskcpu
para: uint8_t cpu :0-7
para: uint8_t pri :1-99
brief: osp function init
return value:0:success
*/
int32_t osp_set_taskcpu(uint8_t cpu, uint8_t pri);

uint32_t read_stc_local_timer(void);

/*
name: drv_init
para: null
brief: drv function init
*/
int32_t drv_init(void);

/*
name: get_heartbeat_status
para: null
brief: get the status of spu cores
return value: 0:success other:bitmap for all cores(1:missing heartbeat)
*/
uint32_t get_heartbeat_status(void);

/**********************************************************************************************/
/*                                     testmac interface                                      */

/********************** Init function *********************/
/*
name: osp_arm_log_proc
para: Input: pbuf: the log's address
para: Input: len: the log's length
para: Input: logid: the log's id
para: Input: msg_type: the log's type
brief: arm log output
*/
OSP_STATUS osp_arm_log_proc(char *pbuf, uint32_t len ,uint32_t logid, uint32_t msg_type);

/********************** Osp function *********************/
/*
name: osp_read_spe_cfg_file
para: Input: path: the config file's path
para: Input: cellid: the index of the cell
brief: load the spe config file by the path
*/
int32_t osp_read_spe_cfg_file(char* path, uint8_t cellid);

/*
name: osp_get_cfg_file
para: Input: name: the config file's name
para: Input: cellid: the index of the cell
para: Output: paddr: the config file's address
para: Output: psize: the config file's size
brief: get a config file's address and size
*/
int32_t  osp_get_cfg_file(char* name, uint8_t cellid, uint64_t *paddr, uint32_t *psize);

int32_t  get_clock_module_status(volatile clock_module_status_s* clk_module_status_ptr);
int32_t  set_clk_mode(clk_flag_e pseudo_flag);

/* arm csu function  */
int arm_csu_dma_1D_transfer(uint64_t addrSrc, uint64_t addrDst, uint32_t dataLen);
int arm_csu_wait_done(uint8_t tag);

/*
 函数名称：osp_insert_cmd
 函数入参：name : shell命令，长度不要超过11个字符
 函数入参：pfunc : 对应shell命令的回调函数
 函数入参：desc : 对应shell命令的描述
 函数入参：argnum : 对应shell命令的参数个数,小于等于6
 函数功能：动态注册shell命令 
 return value:0:success -1:error
 说明：动态注册命令中的打印需使用USHELL_PRINT
 比如：USHELL_PRINT("arg1:%d arg2:%d arg3:%d\n", arg1, arg2, arg3);
*/
int32_t osp_insert_cmd(char *name, OSP_FUNCPTR pfunc, char *desc, uint32_t argnum);
void osp_ushell_output(const char *fmt, ...);
#define USHELL_PRINT(fmt, args...) osp_ushell_output(fmt "\n", ##args)

#endif /* __ARM_INTERFACE_H__  */

