1. New Feature#910

2. Feature Enhancement#914
3. update from V2.0, by msg_transfer synch
4. add osp_send_msg/osp_var_init by synch
This commit is contained in:
lishuang.xie 2023-07-22 17:27:21 +08:00
parent 08d1dc80d5
commit 7e2437c0d6
17 changed files with 996 additions and 32 deletions

View File

@ -10,7 +10,7 @@ extern char *osp_malloc(int size);
extern void osp_free(char *p);
extern void osp_heapmem_test(void);
extern int osp_mem_init(void);
extern uint32_t osp_get_ddr_mem(void);
//extern uint32_t osp_get_ddr_mem(void);
/*
IM的地址空间0x0000 0000 -- 0x0003 FFFF256K
@ -19,8 +19,5 @@ extern uint32_t osp_get_ddr_mem(void);
//#define OSP_MEM_POOL_START (0x00020000) /* 平台内存管理的空间在IM内存空间 */
#define OSP_MEM_POOL_SIZE (0x00009400) /* 平台可分配的IM内存空间大小[32K(任务栈)+5K(配置文件4K+预留1K)=37K] */
#define OSP_PHY_DDR_ADDR (0x14400000) /* DDR规划 */
#define OSP_PHY_DDR_SIZE (0x70800000) /* 1G+776M */ //(0x59000000) /* 1G+400M */ /* 2G-64M-4M */
#endif

View File

@ -9,10 +9,20 @@ typedef struct OSP_MSG_DBG_INFO
uint32_t u32msg_inner_send_ok;
uint32_t u32msg_inner_send_ng;
uint32_t u32msg_swque_recv;
uint32_t u32msg_swque_in_ok;
uint32_t u32msg_swque_in_ng;
uint32_t u32msg_post_sem_cnt;
uint32_t u32msg_inter_send_ok;
uint32_t u32msg_inter_send_ng;
uint32_t u32msg_hwque_recv;
}osp_msg_dbg_info_t;
void osp_show_msg_dbg_info_by_taskid(uint8_t taskid);
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
void osp_show_msg_dbg_info_by_coreid_taskid(uint8_t coreid, uint8_t taskid);
#endif /* UCP_OSP_DBG_HW_CNT_ENABLE */
#endif
/* 消息类型 */

View File

@ -18,8 +18,9 @@ typedef void sem_t;
#define OS_ENTER_CRITICAL() smart_int_disable()
#define OS_EXIT_CRITICAL() smart_int_enable()
#define OSP_DEBUG_POT(ape_id, idx) (DBG_DDR_IDX_OSP_BASE + (ape_id*240) + idx)
#define OSP2_DEBUG_POT(ape_id, idx) (DBG_DDR_IDX_OSP2_BASE + (ape_id*1024) + idx)
#define OSP_DEBUG_POT(ape_id, idx) (DBG_DDR_IDX_OSP_BASE + (ape_id*240) + idx)
#define OSP2_DEBUG_POT(ape_id, idx) (DBG_DDR_IDX_OSP2_BASE + (ape_id*1024) + idx)
#if 0
#define CMD_DEBUG_LEVEL (0)
#define ERR_DEBUG_LEVEL (1)

View File

@ -6,7 +6,6 @@
#include "osp_sw_queue.h"
#include "osp_task.h"
#include "osp_timer.h"
#include "osp_heap.h"
#include "osp_mem.h"
#include "osp_cfgfile.h"
#include "smartos.h" /* OS */
@ -186,6 +185,7 @@ APE侧 OSP业务平台初始化
void osp_init()
{
int ret;
uint8_t flag = 0;
spu_log_init(LOG_ERROR);
ret = osp_hw_que_init(g_ape_id, g_que_id);
@ -194,7 +194,8 @@ void osp_init()
UCP_PRINT_ERROR("osp_hw_que_init failed\r\n");
return ;
}
debug_write(OSP_DEBUG_POT(g_ape_id, 0), 1);
//debug_write(OSP_DEBUG_POT(g_ape_id, 0), 1);
debug_write(OSP_DEBUG_POT(g_ape_id, 0), ++flag); //0x1
/* 内存模块初始化 */
ret = osp_mem_init(); /* 根据讨论平台侧可使用的内存为IM区域 */
@ -202,24 +203,30 @@ void osp_init()
UCP_PRINT_ERROR("osp_mem_init failed\r\n");
return ;
}
debug_write(OSP_DEBUG_POT(g_ape_id, 1), 2);
debug_write(OSP_DEBUG_POT(g_ape_id, 0), ++flag); //0x2
//debug_write(OSP_DEBUG_POT(g_ape_id, 1), 2);
UCP_PRINT_LOG("osp_mem_init OK\r\n");
/* 配置文件模块初始化 */
osp_cfgfile_init();
UCP_PRINT_LOG("osp_cfgfile_init OK\r\n");
debug_write(OSP_DEBUG_POT(g_ape_id, 2), 3);
//debug_write(OSP_DEBUG_POT(g_ape_id, 2), 3);
debug_write(OSP_DEBUG_POT(g_ape_id, 0), ++flag); //0x3
/* 任务模块初始化 */
osp_task_init();
UCP_PRINT_LOG("osp_task_init OK\r\n");
debug_write(OSP_DEBUG_POT(g_ape_id, 3), 4);
//debug_write(OSP_DEBUG_POT(g_ape_id, 3), 4);
debug_write(OSP_DEBUG_POT(g_ape_id, 0), ++flag); //0x4
/* DDR二次管理 */
osp_heap_mem_init(OSP_PHY_DDR_ADDR, OSP_PHY_DDR_SIZE);
//osp_heap_mem_init(OSP_PHY_DDR_ADDR, OSP_PHY_DDR_SIZE);
//debug_write(OSP_DEBUG_POT(g_ape_id, 0), ++flag); //0x5
/* Msg init */
spu_shell_init();
debug_write(OSP_DEBUG_POT(g_ape_id, 0), ++flag); //0x5
osp_task_info_ex ape_shell_recv = {56, (int8_t*)"ape_shell_task", 56, 2048, OSP_NORMAL_TYPE, 1, 0, 0, NULL, (OSP_TASKENTRY_FUNC)spu_shell_task};
//printf("osp shell ok\r\n");
@ -238,7 +245,8 @@ void osp_init()
//osp_cfgfile_read();
//debug_write(OSP_DEBUG_POT(g_ape_id, 4), 5);
debug_write(OSP_DEBUG_POT(g_ape_id, 4), 5);
debug_write(OSP_DEBUG_POT(g_ape_id, 0), ++flag); //0x6
//debug_write(OSP_DEBUG_POT(g_ape_id, 4), 5);
UCP_PRINT_LOG("osp_init done \r\n");
return ;
@ -262,18 +270,18 @@ void osp_start()
g_que_id = g_ape_id;
#if 1
ret = smart_os_debug_init((0xb7fcd000+apeId*0x400), 0x400); // 推荐768, 实际1024
ret = smart_os_debug_init((DBG_DDR_OS_ADDR_BASE+apeId*DBG_DDR_OS_LEN), DBG_DDR_OS_LEN); // 推荐768, 实际1024
if (0 != ret)
{
debug_write(DBG_DDR_ERR_IDX(apeId, 31), ret); // ape0: 0xb7e2407c
}
ret = smart_hq_debug_init((0xb7fd0400+apeId*0x200), 0x200); // 推荐384实际512
ret = smart_hq_debug_init((DBG_DDR_HW_ADDR_BASE+apeId*DBG_DDR_HW_LEN), DBG_DDR_HW_LEN); // 推荐384实际512
if (0 != ret)
{
debug_write(DBG_DDR_ERR_IDX(apeId, 32), ret); // ape0: 0xb7e24080
}
ret = smart_spin_debug_init((0xb7fc1400+apeId*0x40), 0x40); // 推荐36, 实际1024
ret = smart_spin_debug_init((DBG_DDR_SPIN_ADDR_BASE+apeId*DBG_DDR_SPIN_LEN), DBG_DDR_SPIN_LEN); // 推荐36, 实际64
if (0 != ret)
{
debug_write(DBG_DDR_ERR_IDX(apeId, 39), ret); // ape0: 0xb7e2407c
@ -287,7 +295,8 @@ void osp_var_init()
/* 设置配置文件标识位 */
do_write(OSP_CFG_PHY_ADDR, OSP_CFG_FLAG_START);
debug_write(OSP_DEBUG_POT(g_ape_id, 100), OSP_CFG_FLAG_START);
__ucps2_synch(0);
return ;
}

View File

@ -308,11 +308,12 @@ void osp_show_memory(void)
osp_show_im_mem();
}
#if 0
/********************************************************/
/* DDR */
uint32_t osp_get_ddr_mem(void)
{
return OSP_PHY_DDR_ADDR;
}
#endif

View File

@ -77,6 +77,50 @@ static uint32_t g_u32_inter_cnt_ok = 0;
static uint32_t g_u32_inner_cnt_err = 0;
static uint32_t g_u32_inter_cnt_err = 0;
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
static uint32_t gu32_osp_sendto_que0_ok = 0; // #0
static uint32_t gu32_osp_sendto_que1_ok = 0;
static uint32_t gu32_osp_sendto_que2_ok = 0;
static uint32_t gu32_osp_sendto_que3_ok = 0;
static uint32_t gu32_osp_sendto_que4_ok = 0;
static uint32_t gu32_osp_sendto_que5_ok = 0;
static uint32_t gu32_osp_sendto_que6_ok = 0;
static uint32_t gu32_osp_sendto_que7_ok = 0;
static uint32_t gu32_osp_sendto_que8_ok = 0;
static uint32_t gu32_osp_sendto_que9_ok = 0;
static uint32_t gu32_osp_sendto_que10_ok = 0;
static uint32_t gu32_osp_sendto_que11_ok = 0;
static uint32_t gu32_osp_sendto_que0_ng = 0; // #12
static uint32_t gu32_osp_sendto_que1_ng = 0;
static uint32_t gu32_osp_sendto_que2_ng = 0;
static uint32_t gu32_osp_sendto_que3_ng = 0;
static uint32_t gu32_osp_sendto_que4_ng = 0;
static uint32_t gu32_osp_sendto_que5_ng = 0;
static uint32_t gu32_osp_sendto_que6_ng = 0;
static uint32_t gu32_osp_sendto_que7_ng = 0;
static uint32_t gu32_osp_sendto_que8_ng = 0;
static uint32_t gu32_osp_sendto_que9_ng = 0;
static uint32_t gu32_osp_sendto_que10_ng = 0;
static uint32_t gu32_osp_sendto_que11_ng = 0;
static uint32_t gu32_osp_recv_que0 = 0; // #24
static uint32_t gu32_osp_recv_que1 = 0;
static uint32_t gu32_osp_recv_que2 = 0;
static uint32_t gu32_osp_recv_que3 = 0;
static uint32_t gu32_osp_recv_que4 = 0;
static uint32_t gu32_osp_recv_que5 = 0;
static uint32_t gu32_osp_recv_que6 = 0;
static uint32_t gu32_osp_recv_que7 = 0;
static uint32_t gu32_osp_recv_que8 = 0;
static uint32_t gu32_osp_recv_que9 = 0;
static uint32_t gu32_osp_recv_que10 = 0;
static uint32_t gu32_osp_recv_que11 = 0;
static uint32_t gu32_osp_sendto_inner_ok = 0; // #36
static uint32_t gu32_osp_sendto_inner_ng = 0; // #37
#endif
/*
osp_send_msg
@ -122,6 +166,7 @@ int osp_send_msg(uint32_t msg_addr,
st_msg_head.dst_task_id = dst_task_id;
memcpy_ucp((void*)pmsg_head, (void*)&st_msg_head, OSP_MSG_HEAD_LEN);
__ucps2_synch(0);
/*do_write((char*)(&pmsg_head->msg_size), msg_len);
do_write_byte((char*)(&pmsg_head->msg_type), msg_type);
do_write_byte((char*)(&pmsg_head->src_core_id), src_core_id);
@ -150,7 +195,13 @@ int osp_send_msg(uint32_t msg_addr,
osp_post_event_sem(dst_task_id);
#ifdef OSP_MSG_DBG_ENABLE
gst_osp_msg_dbg_info[src_task_id].u32msg_inner_send_ok++;
gst_osp_msg_dbg_info[dst_task_id].u32msg_swque_in_ok++;
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 36), ++gu32_osp_sendto_inner_ok);
#endif
#ifdef UCP_TICK_ENABLE
rdmcycle(&st_tick_info.u32_sem_post_tick);
#endif
@ -160,8 +211,12 @@ int osp_send_msg(uint32_t msg_addr,
//g_u32_inner_cnt_err++;
#ifdef OSP_MSG_DBG_ENABLE
gst_osp_msg_dbg_info[src_task_id].u32msg_inner_send_ng++;
gst_osp_msg_dbg_info[dst_task_id].u32msg_swque_in_ng++;
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 37), ++gu32_osp_sendto_inner_ng);
#endif
}
#ifdef UCP_OSP_DBG_ENABLE
debug_write(OSP_DEBUG_POT(g_ape_id, 73), g_u32_inner_cnt_err);
@ -189,6 +244,76 @@ int osp_send_msg(uint32_t msg_addr,
#ifdef OSP_MSG_DBG_ENABLE
gst_osp_msg_dbg_info[src_task_id].u32msg_inter_send_ng++;
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
switch (dst_core_id)
{
case 0:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 12), ++gu32_osp_sendto_que0_ng);
break;
}
case 1:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 13), ++gu32_osp_sendto_que1_ng);
break;
}
case 2:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 14), ++gu32_osp_sendto_que2_ng);
break;
}
case 3:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 15), ++gu32_osp_sendto_que3_ng);
break;
}
case 4:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 16), ++gu32_osp_sendto_que4_ng);
break;
}
case 5:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 17), ++gu32_osp_sendto_que5_ng);
break;
}
case 6:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 18), ++gu32_osp_sendto_que6_ng);
break;
}
case 7:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 19), ++gu32_osp_sendto_que7_ng);
break;
}
case 8:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 20), ++gu32_osp_sendto_que8_ng);
break;
}
case 9:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 21), ++gu32_osp_sendto_que9_ng);
break;
}
case 10:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 22), ++gu32_osp_sendto_que10_ng);
break;
}
case 11:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 23), ++gu32_osp_sendto_que11_ng);
break;
}
default:
{
break;
}
}
#endif
}
else
{
@ -196,6 +321,76 @@ int osp_send_msg(uint32_t msg_addr,
#ifdef OSP_MSG_DBG_ENABLE
gst_osp_msg_dbg_info[src_task_id].u32msg_inter_send_ok++;
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
switch (dst_core_id)
{
case 0:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 0), ++gu32_osp_sendto_que0_ok);
break;
}
case 1:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 1), ++gu32_osp_sendto_que1_ok);
break;
}
case 2:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 2), ++gu32_osp_sendto_que2_ok);
break;
}
case 3:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 3), ++gu32_osp_sendto_que3_ok);
break;
}
case 4:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 4), ++gu32_osp_sendto_que4_ok);
break;
}
case 5:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 5), ++gu32_osp_sendto_que5_ok);
break;
}
case 6:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 6), ++gu32_osp_sendto_que6_ok);
break;
}
case 7:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 7), ++gu32_osp_sendto_que7_ok);
break;
}
case 8:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 8), ++gu32_osp_sendto_que8_ok);
break;
}
case 9:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 9), ++gu32_osp_sendto_que9_ok);
break;
}
case 10:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 10), ++gu32_osp_sendto_que10_ok);
break;
}
case 11:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 11), ++gu32_osp_sendto_que11_ok);
break;
}
default:
{
break;
}
}
#endif
}
#ifdef UCP_OSP_DBG_ENABLE
debug_write(OSP_DEBUG_POT(g_ape_id, 76), g_u32_inter_cnt_err);
@ -243,6 +438,7 @@ uint32_t g_irq_num = 0;
uint32_t g_irq_out_err = 0;
uint32_t g_irq_sw_err = 0;
uint32_t g_irq_ok = 0;
uint32_t g_irq_task_id_err = 0;
/* 硬件队列回调函数 */
void osp_hw_que_irq(void)
@ -257,7 +453,11 @@ void osp_hw_que_irq(void)
#endif
g_irq_num++;
//debug_write(OSP_DEBUG_POT(g_ape_id, 58), g_irq_num);
debug_write(OSP_DEBUG_POT(g_ape_id, 58), g_irq_num);
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 38), g_irq_num);
#endif
ret = smart_que_is_empty(g_que_id);
//while(ret!= 0)
@ -279,16 +479,93 @@ void osp_hw_que_irq(void)
debug_write(OSP_DEBUG_POT(g_ape_id, 59), g_irq_out_err);
debug_write(DBG_DDR_ERR_IDX(g_ape_id, 27), ret);
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 40), g_irq_out_err);
#endif
return ;
}
UCP_PRINT_LOG("[osp_hw_que_irq]: smart_out_que(0x%x), addr = 0x%08x\r\n", g_que_id, idx);
/* 出队后走软件队列通知 */
pmsg_head = (osp_msg_head*)((uint32_t)idx - (uint32_t)OSP_MSG_HEAD_LEN);
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
uint8_t src_core_id = do_read_byte((char*)(&pmsg_head->src_core_id));
switch (src_core_id)
{
case 0:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 24), ++gu32_osp_recv_que0);
break;
}
case 1:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 25), ++gu32_osp_recv_que1);
break;
}
case 2:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 26), ++gu32_osp_recv_que2);
break;
}
case 3:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 27), ++gu32_osp_recv_que3);
break;
}
case 4:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 28), ++gu32_osp_recv_que4);
break;
}
case 5:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 29), ++gu32_osp_recv_que5);
break;
}
case 6:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 30), ++gu32_osp_recv_que6);
break;
}
case 7:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 31), ++gu32_osp_recv_que7);
break;
}
case 8:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 32), ++gu32_osp_recv_que8);
break;
}
case 9:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 33), ++gu32_osp_recv_que9);
break;
}
case 10:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 34), ++gu32_osp_recv_que10);
break;
}
case 11:
{
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 35), ++gu32_osp_recv_que11);
break;
}
default:
{
break;
}
}
#endif
dst_task_id = do_read_byte((char*)(&pmsg_head->dst_task_id));
if (OSP_OK != osp_task_id_is_true(dst_task_id))
{
debug_write(OSP_DEBUG_POT(g_ape_id, 66), dst_task_id);
debug_write(OSP_DEBUG_POT(g_ape_id, 67), ++g_irq_task_id_err);
return ;
}
#ifdef OSP_MSG_DBG_ENABLE
@ -309,19 +586,36 @@ void osp_hw_que_irq(void)
UCP_PRINT_ERROR("[osp_hw_que_irq]: osp_sw_enque error (dst_task_id = 0x%08x)\r\n", dst_task_id);
debug_write(OSP_DEBUG_POT(g_ape_id, 60), dst_task_id);
debug_write(OSP_DEBUG_POT(g_ape_id, 61), g_irq_sw_err);
#ifdef OSP_MSG_DBG_ENABLE
gst_osp_msg_dbg_info[dst_task_id].u32msg_swque_in_ng++;
#endif
return ;
}
#ifdef OSP_MSG_DBG_ENABLE
gst_osp_msg_dbg_info[dst_task_id].u32msg_swque_in_ok++;
#endif
/* osp_sw_enque ok --> send sem */
osp_post_event_sem(dst_task_id);
#ifdef OSP_MSG_DBG_ENABLE
gst_osp_msg_dbg_info[dst_task_id].u32msg_post_sem_cnt++;
#endif
#ifdef UCP_TICK_ENABLE
rdmcycle(&st_tick_info.u32_irq_post_tick);
#endif
g_irq_ok++;
//debug_write(OSP_DEBUG_POT(g_ape_id, 62), g_irq_ok);
debug_write(OSP_DEBUG_POT(g_ape_id, 62), g_irq_ok);
//debug_write(OSP_DEBUG_POT(g_ape_id, 60), dst_task_id);
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
debug_write(OSP_DEBUG_HW_POT(g_ape_id, 39), g_irq_ok);
#endif
/* 继续取下一个 */
ret = smart_que_is_empty(g_que_id);
}
@ -423,7 +717,7 @@ void osp_get_hw_que_cnt(uint32_t *pu32irq_cnt, uint32_t *pu32irq_ok, uint32_t *p
void osp_show_msg_info(void)
{
int i;
osp_tcb *tcb_val;
osp_tcb *tcb_val;
char pbuf[2048];
int len = 0;
uint8_t ucCoreId = 0;
@ -431,19 +725,93 @@ void osp_show_msg_info(void)
ucCoreId = get_core_id();
len = sprintf(pbuf,"\n\r%-8s%-8s%-25s%-10s%-5s\n\r","coreId", "Id", "name","inner","inter");
len = sprintf(pbuf,"\n\r%-8s%-8s%-25s%-10s%-5s\n\r","coreId", "Id", "name","inner","inter");
for(i=0; i< g_taskid_num; i++,len=0)
{
tcb_val = (osp_tcb*)g_tcb_handler_tbl[g_task_id_table[i]];
{
tcb_val = (osp_tcb*)g_tcb_handler_tbl[g_task_id_table[i]];
len += sprintf(pbuf +len,"%-8u%-8u%-25s%-10u%-5u\n\r",ucCoreId,tcb_val->task_id, tcb_val->task_name,
len += sprintf(pbuf +len,"%-8u%-8u%-25s%-10u%-5u\n\r",ucCoreId,tcb_val->task_id, tcb_val->task_name,
gst_osp_msg_dbg_info[g_task_id_table[i]].u32msg_inner_send_ok,
gst_osp_msg_dbg_info[g_task_id_table[i]].u32msg_inter_send_ok);
spu_shellinfo_to_arm(pbuf, len, UCP4008_OSP_SHELL);
}
}
return;
}
void osp_show_msg_dbg_info_by_taskid(uint8_t taskid)
{
int len = 0;
char pbuf[2048];
if (OSP_OK != osp_task_id_is_true(taskid))
{
debug_write(OSP_DEBUG_POT(g_ape_id, 68), taskid);
return ;
}
len = sprintf(pbuf,"\n\r%-8s%-4s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n\r",
"coreId", "Id","inner_ok", "inner_ng",
"sw_in_ok", "sw_in_ng", "post_sem",
"inter_ok", "inter_ng", "sw_recv", "hw_recv");
len += sprintf(pbuf +len,"%-8u%-4u%-10u%-10u%-10u%-10u%-10u%-10u%-10u%-10u%-10u\n\r",
g_ape_id, taskid,
gst_osp_msg_dbg_info[taskid].u32msg_inner_send_ok,
gst_osp_msg_dbg_info[taskid].u32msg_inner_send_ng,
gst_osp_msg_dbg_info[taskid].u32msg_swque_in_ok,
gst_osp_msg_dbg_info[taskid].u32msg_swque_in_ng,
gst_osp_msg_dbg_info[taskid].u32msg_post_sem_cnt,
gst_osp_msg_dbg_info[taskid].u32msg_inter_send_ok,
gst_osp_msg_dbg_info[taskid].u32msg_inter_send_ng,
gst_osp_msg_dbg_info[taskid].u32msg_swque_recv,
gst_osp_msg_dbg_info[taskid].u32msg_hwque_recv);
spu_shellinfo_to_arm(pbuf, len, UCP4008_OSP_SHELL);
return ;
}
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
void osp_show_msg_dbg_info_by_coreid_taskid(uint8_t coreid, uint8_t taskid)
{
int len = 0;
char pbuf[2048];
if (g_ape_id != coreid)
{
return ;
}
if (OSP_OK != osp_task_id_is_true(taskid))
{
debug_write(OSP_DEBUG_POT(g_ape_id, 68), taskid);
return ;
}
len = sprintf(pbuf,"\n\r%-8s%-4s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n\r",
"coreId", "Id","inner_ok", "inner_ng",
"sw_in_ok", "sw_in_ng", "post_sem",
"inter_ok", "inter_ng", "sw_recv", "hw_recv");
len += sprintf(pbuf +len,"%-8u%-4u%-10u%-10u%-10u%-10u%-10u%-10u%-10u%-10u%-10u\n\r",
g_ape_id, taskid,
gst_osp_msg_dbg_info[taskid].u32msg_inner_send_ok,
gst_osp_msg_dbg_info[taskid].u32msg_inner_send_ng,
gst_osp_msg_dbg_info[taskid].u32msg_swque_in_ok,
gst_osp_msg_dbg_info[taskid].u32msg_swque_in_ng,
gst_osp_msg_dbg_info[taskid].u32msg_post_sem_cnt,
gst_osp_msg_dbg_info[taskid].u32msg_inter_send_ok,
gst_osp_msg_dbg_info[taskid].u32msg_inter_send_ng,
gst_osp_msg_dbg_info[taskid].u32msg_swque_recv,
gst_osp_msg_dbg_info[taskid].u32msg_hwque_recv);
spu_shellinfo_to_arm(pbuf, len, UCP4008_OSP_SHELL);
return ;
}
#endif /* UCP_OSP_DBG_HW_CNT_ENABLE */
#endif

View File

@ -46,6 +46,11 @@ void osp_task_init(void)
spu_insert_cmd_ext("i_ape", (OSP_FUNCPTR)osp_show_task_info, "osp show task info", 0);
#ifdef OSP_MSG_DBG_ENABLE
spu_insert_cmd_ext("e_ape", (OSP_FUNCPTR)osp_show_msg_info, "osp show msg info", 0);
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
spu_insert_cmd_ext("em_ape", (OSP_FUNCPTR)osp_show_msg_dbg_info_by_coreid_taskid, "osp show msg by id", 2);
#endif /* UCP_OSP_DBG_HW_CNT_ENABLE */
#endif
return ;
}

View File

@ -35,6 +35,34 @@ uint32_t g_spu_rfm_ddr_msg_addr[] = {0x102AA000, /* PET RFM0 */
0x10354800, /* ECS RFM0 */
0x103A9C00}; /* ECS RFM1 */
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
static uint32_t gu32_app_sendto_que0_ok = 0; // #0
static uint32_t gu32_app_sendto_que1_ok = 0;
static uint32_t gu32_app_sendto_que2_ok = 0;
static uint32_t gu32_app_sendto_que3_ok = 0;
static uint32_t gu32_app_sendto_que4_ok = 0;
static uint32_t gu32_app_sendto_que5_ok = 0;
static uint32_t gu32_app_sendto_que6_ok = 0;
static uint32_t gu32_app_sendto_que7_ok = 0;
static uint32_t gu32_app_sendto_que8_ok = 0;
static uint32_t gu32_app_sendto_que9_ok = 0;
static uint32_t gu32_app_sendto_que10_ok = 0;
static uint32_t gu32_app_sendto_que11_ok = 0;
static uint32_t gu32_app_sendto_que0_ng = 0; // #12
static uint32_t gu32_app_sendto_que1_ng = 0;
static uint32_t gu32_app_sendto_que2_ng = 0;
static uint32_t gu32_app_sendto_que3_ng = 0;
static uint32_t gu32_app_sendto_que4_ng = 0;
static uint32_t gu32_app_sendto_que5_ng = 0;
static uint32_t gu32_app_sendto_que6_ng = 0;
static uint32_t gu32_app_sendto_que7_ng = 0;
static uint32_t gu32_app_sendto_que8_ng = 0;
static uint32_t gu32_app_sendto_que9_ng = 0;
static uint32_t gu32_app_sendto_que10_ng = 0;
static uint32_t gu32_app_sendto_que11_ng = 0;
#endif
#define APP_PALLADIUM_TEST
#ifdef APP_PALLADIUM_TEST
typedef struct ECS_APP_IFC_STRUCT
@ -163,6 +191,7 @@ int32_t osp_send_msg(uint32_t msg_addr,
st_msg_head.dst_task_id = dst_task_id;
memcpy_ucp((void*)pmsg_head, (void*)&st_msg_head, ECS_MSG_HEAD_LEN);
__ucps2_synch(0);
UCP_PRINT_LOG("ecs_send_msg: dst_que_id = 0x%08x, addr = 0x%08x\r\n", dst_core_id, msg_addr);
ret_queue = smart_in_que(dst_core_id, msg_addr);
@ -174,11 +203,150 @@ int32_t osp_send_msg(uint32_t msg_addr,
debug_write(DBG_DDR_COMMON_IDX(core_id, 13), g_ecs_app_debug_info.ecs_msg_InQue_err);
debug_write(DBG_DDR_ERR_IDX(core_id, 19), ret_queue);
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
switch (dst_core_id)
{
case 0:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 12), ++gu32_app_sendto_que0_ng);
break;
}
case 1:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 13), ++gu32_app_sendto_que1_ng);
break;
}
case 2:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 14), ++gu32_app_sendto_que2_ng);
break;
}
case 3:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 15), ++gu32_app_sendto_que3_ng);
break;
}
case 4:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 16), ++gu32_app_sendto_que4_ng);
break;
}
case 5:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 17), ++gu32_app_sendto_que5_ng);
break;
}
case 6:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 18), ++gu32_app_sendto_que6_ng);
break;
}
case 7:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 19), ++gu32_app_sendto_que7_ng);
break;
}
case 8:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 20), ++gu32_app_sendto_que8_ng);
break;
}
case 9:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 21), ++gu32_app_sendto_que9_ng);
break;
}
case 10:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 22), ++gu32_app_sendto_que10_ng);
break;
}
case 11:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 23), ++gu32_app_sendto_que11_ng);
break;
}
default:
{
break;
}
}
#endif
}
#ifdef APP_PALLADIUM_TEST
debug_write(DBG_DDR_COMMON_IDX(core_id, 14), g_ecs_app_debug_info.ecs_msg_send_num);
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
switch (dst_core_id)
{
case 0:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 0), ++gu32_app_sendto_que0_ok);
break;
}
case 1:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 1), ++gu32_app_sendto_que1_ok);
break;
}
case 2:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 2), ++gu32_app_sendto_que2_ok);
break;
}
case 3:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 3), ++gu32_app_sendto_que3_ok);
break;
}
case 4:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 4), ++gu32_app_sendto_que4_ok);
break;
}
case 5:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 5), ++gu32_app_sendto_que5_ok);
break;
}
case 6:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 6), ++gu32_app_sendto_que6_ok);
break;
}
case 7:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 7), ++gu32_app_sendto_que7_ok);
break;
}
case 8:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 8), ++gu32_app_sendto_que8_ok);
break;
}
case 9:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 9), ++gu32_app_sendto_que9_ok);
break;
}
case 10:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 10), ++gu32_app_sendto_que10_ok);
break;
}
case 11:
{
debug_write(OSP_DEBUG_HW_POT(src_core_id, 11), ++gu32_app_sendto_que11_ok);
break;
}
default:
{
break;
}
}
#endif
return ret_queue;
}

View File

@ -200,6 +200,8 @@ int32_t msg_transfer_send_msg(int32_t handle_id, uint16_t cu_flag, uint8_t* msg_
uint16_t idx = (uint16_t)offset;//redefine offset to buf_id
MsgMemBufAttr_t *mbuf = (MsgMemBufAttr_t *)get_mbuf_ptr(ch->bufBase, ch->bufSize, idx);
do_write(&mbuf->msgSize, msg_len);
__ucps2_synch(0);
uint32_t value = (inst_id << 24) + (que_id << 16) + idx;
int32_t ret = ecs_hw_que_send(ECS_RFM_SPU0_HW_QUEUE, value);
#endif

View File

@ -25,11 +25,27 @@ typedef struct ECS_DEBUG_INFO_STRUCT
uint32_t ecs_msg_OutQue_err;
uint32_t ecs_msg_irq_num;
uint32_t ecs_msg_OutQue_num;
uint32_t ecs_msg_QutQue_ok;
uint32_t ecs_msg_QueIsEmpty_num;
}ecs_debug_info;
ecs_debug_info g_ecs_debug_info; /* ECS硬件队列调试信息 */
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
static uint32_t gu32_app_recv_que0 = 0; // #24
static uint32_t gu32_app_recv_que1 = 0;
static uint32_t gu32_app_recv_que2 = 0;
static uint32_t gu32_app_recv_que3 = 0;
static uint32_t gu32_app_recv_que4 = 0;
static uint32_t gu32_app_recv_que5 = 0;
static uint32_t gu32_app_recv_que6 = 0;
static uint32_t gu32_app_recv_que7 = 0;
static uint32_t gu32_app_recv_que8 = 0;
static uint32_t gu32_app_recv_que9 = 0;
static uint32_t gu32_app_recv_que10 = 0;
static uint32_t gu32_app_recv_que11 = 0;
#endif
ecs_hw_que_info_withirq_t g_ecs_hw_que_info; /* ECS带中断的硬件队列相关信息 */
ecs_hw_que_info_noirq_t gst_ecs_hw_que_info_noirq; /* ECS不带中断的硬件队列相关信息 */
@ -212,6 +228,11 @@ void ecs_hw_que_irq(void)
#ifdef ECS_PALLADIUM_TEST
g_ecs_debug_info.ecs_msg_irq_num++;
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
debug_write(OSP_DEBUG_HW_POT(core_id, 38), g_ecs_debug_info.ecs_msg_irq_num);
#endif
ret = smart_que_is_empty(g_ecs_hw_que_info.ecs_hq_id);
while(ret == 0)
{
@ -230,9 +251,17 @@ void ecs_hw_que_irq(void)
debug_write(DBG_DDR_COMMON_IDX(core_id, 35), g_ecs_debug_info.ecs_msg_OutQue_num);
#endif
debug_write(DBG_DDR_ERR_IDX(core_id, 28), ret);
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
debug_write(OSP_DEBUG_HW_POT(core_id, 40), g_ecs_debug_info.ecs_msg_OutQue_err);
#endif
return ;
}
#ifdef ECS_PALLADIUM_TEST
g_ecs_debug_info.ecs_msg_QutQue_ok++;
#endif
UCP_PRINT_LOG("[ecs_hw_que_irq]: smart_out_que(0x%08x), addr = 0x%08x\r\n", g_ecs_hw_que_info.ecs_hq_id, idx);
if (NULL != g_ecs_hw_que_info.irq_entry)
{
@ -242,6 +271,79 @@ void ecs_hw_que_irq(void)
debug_write(DBG_DDR_COMMON_IDX(core_id, 36), g_ecs_debug_info.ecs_msg_irq_num);
debug_write(DBG_DDR_COMMON_IDX(core_id, 37), g_ecs_debug_info.ecs_msg_OutQue_num);
#endif
#ifdef UCP_OSP_DBG_HW_CNT_ENABLE
uint8_t src_core_id = do_read_byte((char*)(&pmsg_head->src_core_id));
switch (src_core_id)
{
case 0:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 24), ++gu32_app_recv_que0);
break;
}
case 1:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 25), ++gu32_app_recv_que1);
break;
}
case 2:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 26), ++gu32_app_recv_que2);
break;
}
case 3:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 27), ++gu32_app_recv_que3);
break;
}
case 4:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 28), ++gu32_app_recv_que4);
break;
}
case 5:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 29), ++gu32_app_recv_que5);
break;
}
case 6:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 30), ++gu32_app_recv_que6);
break;
}
case 7:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 31), ++gu32_app_recv_que7);
break;
}
case 8:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 32), ++gu32_app_recv_que8);
break;
}
case 9:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 33), ++gu32_app_recv_que9);
break;
}
case 10:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 34), ++gu32_app_recv_que10);
break;
}
case 11:
{
debug_write(OSP_DEBUG_HW_POT(core_id, 35), ++gu32_app_recv_que11);
break;
}
default:
{
break;
}
}
debug_write(OSP_DEBUG_HW_POT(core_id, 49), g_ecs_debug_info.ecs_msg_QutQue_ok);
#endif
g_ecs_hw_que_info.irq_entry(idx, len);
}
ret = smart_que_is_empty(g_ecs_hw_que_info.ecs_hq_id);

View File

@ -8,7 +8,6 @@
#include "typedef.h"
#include "phy_para.h"
OSP_CMD_RTN gastCmdRtnTblExt[MAX_EXT_CMD_NUM];
OSP_CMD_EXT gastCmdExt[MAX_EXT_CMD_NUM];
@ -36,7 +35,6 @@ static char argchar[10][32] = {0};
static char shellOut[64] ={0};
OSP_CMD_RTN ospCmdRtnTbl[] =
{
//{"level_ape", (OSP_FUNCPTR)spu_shell_wrapper, (OSP_FUNCPTR)spu_set_log_level},

View File

@ -72,10 +72,21 @@ void ucp_nop(uint32_t cycleCnt);
#define DBG_DDR_IDX_CPRI_BASE (2048*20)
#define DBG_DDR_IRQ_ADDR_BASE (0xB7FC0000)
#define DBG_DDR_IRQ_LEN (0x1000)
#define DBG_DDR_OS_ADDR_BASE (0xB7FCD000)
#define DBG_DDR_OS_LEN (0x400)
#define DBG_DDR_HW_ADDR_BASE (0xB7FD0400)
#define DBG_DDR_HW_LEN (0x200)
#define DBG_DDR_SPIN_ADDR_BASE (0xB7FD1400)
#define DBG_DDR_SPIN_LEN (0x40)
#define DBG_DDR_OSP_HW_BASE (476544) // 0xB7FD1600
#define DBG_DDR_OSP_HW_LEN (0x30) // 48
#define DBG_DDR_COMMON_IDX(core_id,x) (DBG_DDR_IDX_COMMON_BASE + (core_id) * 128 + (x))
#define DBG_DDR_MSG_IDX(queue_no,x) (DBG_DDR_IDX_MSG_BASE + (queue_no) * 192 + (x))
#define DBG_DDR_ERR_IDX(core_id,x) (DBG_DDR_IDX_ERR_BASE + (core_id)*128 + (x))
#define OSP_DEBUG_HW_POT(core_id, idx) (DBG_DDR_OSP_HW_BASE + ((core_id)*DBG_DDR_OSP_HW_LEN) + idx)
#define UCP_OSP_DBG_HW_CNT_ENABLE
#ifdef DBG_DDR_PALLADIUM
void pld_debug_write(uint32_t idx, uint32_t value);

View File

@ -14,6 +14,7 @@
#include "hw_gpio.h"
#include "gtimer_drv.h"
#include "rfm1_gtimer2.h"
#include "ecs_rfm_spu1_heap.h"
#ifdef DISTRIBUTED_BS
#include "hw_cpri.h"
@ -122,9 +123,10 @@ void ecs_rfm1_drv_init(void)
ecs_msg_que_init(apeId);
ecs_hw_que_init_noirq(apeId, ECS_RFM_SPU1_HW_QUEUE);
spu_log_init(LOG_ERROR);
ecs_heap_mem_init(ECS_PHY_DDR_ADDR, ECS_PHY_DDR_SIZE);
#ifdef PALLADIUM_TEST
flag++;
debug_write((DBG_DDR_IDX_DRV_BASE+(apeId<<2)), flag); // 0xB4
flag++;
debug_write((DBG_DDR_IDX_DRV_BASE+(apeId<<2)), flag); // 0xB4
#endif
}

View File

@ -0,0 +1,12 @@
#ifndef __ECS_RFM_SPU1_HEAP__
#define __ECS_RFM_SPU1_HEAP__
#define ECS_PHY_DDR_ADDR (0x14400000) /* DDR规划 */
#define ECS_PHY_DDR_SIZE (0x70800000) /* 1G+776M */ //(0x59000000) /* 1G+400M */ /* 2G-64M-4M */
extern int8_t ecs_heap_mem_init(uint32_t addr, uint32_t size);
extern char *osp_heap_malloc(uint32_t size);
extern void osp_heap_free(char *p);
#endif

View File

@ -0,0 +1,278 @@
#include <stdio.h>
#include <stdlib.h>
#include "ecs_rfm_spu1_heap.h"
#include "ucp_utility.h"
#define DDR_ALIGN(x, align) (((unsigned int)(x)+(align -1))&~(align-1))
typedef struct DoubleLinkNode
{
uint32_t len;
int32_t IsBusy;
struct DoubleLinkNode *prev;
struct DoubleLinkNode *next;
}osp_heap_node;
#define OSP_HEAP_NODE_SIZE sizeof(osp_heap_node)
#define OSP_HEAP_BUF_TO_HEAD(pbuf) (osp_heap_node *)((unsigned int)pbuf - OSP_HEAP_NODE_SIZE)
typedef struct heap_mem
{
osp_heap_node *root;
osp_heap_node *cur_avaliable;
}osp_heap_mem_cb;
osp_heap_mem_cb g_st_osp_heap_mem;
osp_heap_node *osp_search_heap_node(osp_heap_node *head, uint32_t size)
{
osp_heap_node *pddr_node = NULL;
osp_heap_node im_node;
pddr_node = head;
while (pddr_node)
{
memcpy_ucp(&im_node, pddr_node, sizeof(osp_heap_node));
__ucps2_synch(0);
if ((im_node.len > (size + OSP_HEAP_NODE_SIZE)) && (!im_node.IsBusy))
{
return pddr_node;
}
pddr_node = im_node.next;
}
return 0;
}
osp_heap_node *osp_split_heap_node(osp_heap_node *node, uint32_t size)
{
osp_heap_node *new = NULL;
osp_heap_node *next = NULL;
osp_heap_node im_node;
osp_heap_node im_newnode;
int32_t len;
memcpy_ucp(&im_node, node, sizeof(osp_heap_node));
__ucps2_synch(0);
if (im_node.len-size < OSP_HEAP_NODE_SIZE)
{
return node;
}
len = im_node.len;
//node->len = size;
do_write(node, size);
new = (osp_heap_node *)((unsigned int)node + size + OSP_HEAP_NODE_SIZE);
//new->len = len - size - OSP_HEAP_NODE_SIZE;
//new->IsBusy = 0;
do_write(new, (len - size - OSP_HEAP_NODE_SIZE)); // len
do_write(((int8_t*)new + 4), 0); // busy
//new->next = node->next;
do_write(((int8_t*)new + 12), im_node.next); // next
memcpy_ucp(&im_newnode, new, sizeof(osp_heap_node));
__ucps2_synch(0);
next = im_newnode.next;
if (next)
{
//next->prev = new;
do_write(((int8_t*)next + 8), new); // prev
}
//new->prev = node;
do_write(((int8_t*)new + 8), node);
//node->next = new;
do_write(((int8_t*)node + 12), new);
__ucps2_synch(0);
return new;
}
int32_t osp_set_heap_node_busy(osp_heap_node *node)
{
//node->IsBusy = 1;
do_write(((int8_t*)node + 4), 1);
return 0;
}
int32_t osp_clear_heap_node_busy(osp_heap_node *node)
{
//node->IsBusy = 0;
do_write(((int8_t*)node + 4), 0);
return 0;
}
osp_heap_node *osp_get_next_heap_node(osp_heap_node *node)
{
return node->next;
}
osp_heap_node *osp_get_pre_heap_node(osp_heap_node *node)
{
return node->prev;
}
int32_t osp_heap_node_need_merge(osp_heap_node *node, osp_heap_node *nextnode)
{
int32_t node_isbusy = 0;
int32_t nextnode_isbusy = 0;
node_isbusy = do_read((int8_t*)node + 4);
nextnode_isbusy = do_read((int8_t*)nextnode + 4);
__ucps2_synch(0);
if ((0 == node_isbusy)&&(0 == nextnode_isbusy))
{
return 1;
}
return 0;
}
int32_t osp_heap_node_merge(osp_heap_node *node, osp_heap_node *nextnode)
{
osp_heap_node im_node;
osp_heap_node im_nextnode;
osp_heap_node *nextnext = NULL;
memcpy_ucp(&im_node, node, sizeof(osp_heap_node));
memcpy_ucp(&im_nextnode, nextnode, sizeof(osp_heap_node));
nextnext = im_nextnode.next;
//node->next = nextnext;
do_write(((int8_t*)node + 12), nextnext);
if (nextnext)
{
//nextnext->prev = node;
do_write(((int8_t*)nextnext + 8), node);
}
//len = do_read(nextnode);
//node->len += nextnode->len + OSP_HEAP_NODE_SIZE;
do_write(node, (im_node.len + im_nextnode.len + OSP_HEAP_NODE_SIZE));
if(nextnode == g_st_osp_heap_mem.cur_avaliable)
{
g_st_osp_heap_mem.cur_avaliable = node;
}
__ucps2_synch(0);
return 0;
}
int8_t ecs_heap_mem_init(uint32_t addr, uint32_t size)
{
osp_heap_node temp_node;
if ((0 == addr) || (0 == size))
{
return -1;
}
memset(&g_st_osp_heap_mem, 0, sizeof(g_st_osp_heap_mem));
g_st_osp_heap_mem.root = (osp_heap_node *)((void*)addr);
memset(&temp_node, 0, sizeof(temp_node));
if (size < OSP_HEAP_NODE_SIZE)
{
temp_node.len = 0;
//g_st_osp_heap_mem.root->len = 0;
}
else
{
temp_node.len = size - OSP_HEAP_NODE_SIZE;
//g_st_osp_heap_mem.root->len = size - OSP_HEAP_NODE_SIZE;
}
temp_node.IsBusy = 0;
temp_node.next = NULL;
temp_node.prev = NULL;
memcpy_ucp(g_st_osp_heap_mem.root, &temp_node, sizeof(temp_node));
__ucps2_synch(0);
//g_st_osp_heap_mem.root->IsBusy = 0;
//g_st_osp_heap_mem.root->next = NULL;
//g_st_osp_heap_mem.root->prev = NULL;
g_st_osp_heap_mem.cur_avaliable = g_st_osp_heap_mem.root;
return 0;
}
char *osp_malloc_ddr_mem(uint32_t size)
{
osp_heap_node *node;
uint32_t len = DDR_ALIGN(size, 4);
node = osp_search_heap_node(g_st_osp_heap_mem.cur_avaliable, len);
if(!node)
{
node = osp_search_heap_node(g_st_osp_heap_mem.root, len);
if (!node)
{
return NULL;
}
}
//osp_set_heap_node_busy(node);
//node->IsBusy = 1;
do_write(((int8_t*)node + 4), 1);
__ucps2_synch(0);
//new = osp_split_heap_node(node, len);
g_st_osp_heap_mem.cur_avaliable = osp_split_heap_node(node, len);
return (char*)((unsigned int)node + OSP_HEAP_NODE_SIZE);
}
char *osp_heap_malloc(uint32_t size)
{
char *p;
//OS_ENTER_CRITICAL();
p = osp_malloc_ddr_mem(size);
//OS_EXIT_CRITICAL();
return p;
}
int osp_free_ddr_mem(char* pbuf)
{
osp_heap_node *node = OSP_HEAP_BUF_TO_HEAD(pbuf);
osp_heap_node *nextnode = NULL;
osp_heap_node *prenode = NULL;
osp_heap_node im_node;
//osp_clear_heap_node_busy(node);
//node->IsBusy = 0;
do_write(((int8_t*)node + 4), 0);
memcpy_ucp(&im_node, node, sizeof(osp_heap_node));
__ucps2_synch(0);
//nextnode = osp_get_next_heap_node(node);
//nextnode = node->next;
nextnode = im_node.next;
//prenode = osp_get_pre_heap_node(node);
//prenode = node->prev;
prenode = im_node.prev;
if(nextnode){
if(osp_heap_node_need_merge(node, nextnode)){
osp_heap_node_merge(node, nextnode);
}
}
if(prenode){
if(osp_heap_node_need_merge(prenode, node)){
osp_heap_node_merge(prenode, node);
}
}
return 0;
}
void osp_heap_free(char *p)
{
//OS_ENTER_CRITICAL();
osp_free_ddr_mem(p);
p = NULL;
//OS_EXIT_CRITICAL();
return ;
}

View File

@ -105,7 +105,8 @@ void msg_transfer_enqueue(void)
uint16_t idx = ch->in & ch->ringMask;
do_write_short(&pIdxBase[idx],buf_id);
do_write(&chCommon->in, (ch->in+1));
__ucps2_synch(0);
return;
}

View File

@ -20,7 +20,6 @@
#include "msg_transfer_layer.h"
#include "ucp_port.h"
#include "ape_mtimer.h"
#include "osp_heap.h"
/***************************************************************/
/* 事件任务相关打点 */