static void channel_fifo_dump(u32 real_channel_id, u32 fifo_type, const char* fifo_name)
{
	void *base_addr = 0;
	struct icc_channel* channel = g_icc_ctrl.channels[real_channel_id%g_icc_ctrl.channel_size];
	struct icc_channel_fifo* fifo = NULL;

	if(!channel)
	{
		icc_print_error("channel pointer is NULL!\n");
		return;
	}
	
	fifo = (0 == fifo_type)? channel->fifo_recv: channel->fifo_send;
	if(!fifo)
	{
		icc_print_error("fifo pointer is NULL!\n");
		return;
	}
	
	base_addr = (void*)fifo + sizeof(struct icc_channel_fifo);

	icc_print_info("***************************%s**********************************\n", fifo_name);
	icc_print_info("icc_channel_fifo address:      %p\n", fifo);
	icc_print_info("icc_channel_fifo.base_addr:    %p\n", base_addr);
	icc_print_info("icc_channel_fifo.magic:        0x%x\n", fifo->magic);
	icc_print_info("icc_channel_fifo.size:         0x%x\n", fifo->size);
	icc_print_info("icc_channel_fifo.write:        0x%x\n", fifo->write);
	icc_print_info("icc_channel_fifo.read:         0x%x\n", fifo->read);
	icc_print_info("icc_channel_fifo.data:         0x%x\n\n", *((s32*)(fifo->data)));
}
Exemplo n.º 2
0
/* 收对方核回过来的确认信息: 如果信息是ICC_CONF_MSG_TYPE1 */
s32 icc_send_test_cb1_new(u32 channel_id , u32 len, void* context)
{
	u8  confirm = (u8)ICC_RECV_OK;
	u32 channel_idx = GET_CHN_ID(channel_id);
	u32 sub_chn_idx = GET_FUNC_ID(channel_id);
	s32 read_len = sizeof(confirm);

	icc_print_debug("enter\n");

	if(read_len == bsp_icc_read(channel_id, &confirm, len))
	{
		icc_print_debug("confirm:0x%x\n", confirm);
		if(ICC_CONF_MSG_TYPE1 == confirm)
		{
			g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx-1].success_cnt++;
			osl_sem_up(&(g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx-1].confirm_sem)); /*lint !e40 !e516 */
		}
		else if(ICC_CONF_MSG_TYPE2 == confirm)
		{
			g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx+1].success_cnt++;
			osl_sem_up(&(g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx+1].confirm_sem)); /*lint !e40 !e516 */
		}
		else
		{
			icc_print_error("error: wrong confirm:0x%x\n", confirm);
		}
	}
	else
	{
		icc_print_error("icc read error\n", confirm);
	}

	return ICC_OK;
}
Exemplo n.º 3
0
/* 测试发送函数 */
static s32 icc_send_test(enum CPU_ID send_cpu_id, u32 channel_id, u8 *buf, u32 data_len, u32 start, u32 timeout)
{
	u32 i = 0;

	for(i = 0; i < data_len; i++)
	{
		buf[i]= (u8)(i + start);
	}

	icc_print_debug("enter: channel_id=0x%x\n", channel_id);

	if((s32)data_len != bsp_icc_send(send_cpu_id, channel_id, buf, data_len))
	{
		icc_print_error("bsp_icc_send error\n");
		return ICC_ERR;
	}

	if(osl_sem_downtimeout(&(g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)].confirm_sem), (long)timeout)) /*lint !e732 */
	{
		icc_print_error("icc_sem_take error\n");
		return ICC_ERR;
	}

	return ICC_OK;
}
BSP_S32 BSP_ICC_Open(BSP_U32 u32ChanId, ICC_CHAN_ATTR_S *pChanAttr)
{
	u32 func_id = ICC_DEFAULT_SUB_CHANNEL; /* 除ifc通道外,其他通道只有一个回调 */
	u32 channel_id = u32ChanId << 16 | func_id;
	u32 i = 0;
	u32 real_channel_size = bsp_icc_channel_size_get();

	/* coverity[REVERSE_INULL] */
	if(!pChanAttr)
	{
		icc_print_error("pChanAttr is null!\n");
		goto out;
	}
	else if(pChanAttr->u32FIFOOutSize != pChanAttr->u32FIFOInSize || u32ChanId >= ICC_CHN_ID_MAX)
	{
		icc_print_error("invalid param u32ChanId[%d],pChanAttr[%p],fifo_in[0x%x],fifo_out[0x%x]\n",
			u32ChanId, pChanAttr, pChanAttr->u32FIFOInSize, pChanAttr->u32FIFOOutSize);
		goto out;
	}

	for(i = 0; i < real_channel_size; i++)
	{
		if(u32ChanId == g_icc_init_info[i].real_channel_id)
		{
			break;
		}
	}

	if(i >= real_channel_size)
	{
		icc_print_error("channel_id[%d] cannot find in g_icc_init_info array\n", u32ChanId);
		goto out;
	}
	else
	{
		if(pChanAttr->u32FIFOInSize > g_icc_init_info[i].fifo_size)/*lint !e574 */
		{
			icc_print_error("user fifo_size(%d) > fifo_size(%d) defined in bsp(g_icc_init_info)\n",
					 pChanAttr->u32FIFOInSize, g_icc_init_info[i].fifo_size);
			goto out;
		}
	}

	return (BSP_S32)bsp_icc_event_register(channel_id, icc_read_cb_wraper, (void*)pChanAttr->read_cb, icc_write_cb_wraper, (void*)pChanAttr->write_cb);

out:
	return BSP_ERR_ICC_INVALID_PARAM;
}
BSP_S32 BSP_ICC_Ioctl(BSP_U32 u32ChanId, BSP_U32 cmd, BSP_VOID *param)
{
	/*lint --e{701} */
	u32 channel_id = 0;
	s32 ret = ICC_OK;

	if ((u32ChanId >= UDI_ICC_GUOM0 ) && (u32ChanId <= UDI_ICC_GUOM5))
	{
		u32ChanId = u32ChanId - UDI_ICC_GUOM0 + ICC_CHN_GUOM0;
	}
	channel_id = ((u16)u32ChanId << 16 | (u16)ICC_DEFAULT_SUB_CHANNEL);/* [false alarm]:屏蔽Fortify错误 */
	
	if(u32ChanId >= ICC_CHN_ID_MAX)
	{
		icc_print_error("invalid param[%d].\n", u32ChanId);
		return ICC_INVALID_PARA;
	}
	switch(cmd)
	{
		case ICC_IOCTL_SET_READ_CB:
		{
			ret = (s32)bsp_icc_event_register(channel_id, icc_read_cb_wraper ,(void*)param, NULL, NULL);
			break;
		}
		case ICC_IOCTL_SET_WRITE_CB:
		{
			ret = (s32)bsp_icc_event_register(channel_id, NULL, NULL, icc_write_cb_wraper ,(void*)param);
			break;
		}
		case ICC_IOCTL_GET_STATE:
		{
			ret = (s32)bsp_icc_channel_status_get((u32)u32ChanId, (u32*)param);
			break;
		}
		case ICC_IOCTL_SET_EVENT_CB:
		{
			break;
		}
		default:
		{
			icc_print_error("channel[%d] invalid cmd[%d].\n", u32ChanId, cmd);
			ret = ICC_INVALID_PARA;
			break;
		}
	}
	
	return ret;
}
Exemplo n.º 6
0
/* 子通道重新分配, 每个通道分配64个子通道, 0-31为实际使用子通道, 32-64为测试用子通道 */
static s32 icc_test_channel_reinit(u32 channel_idx, u32 new_sub_chn_size)
{
	struct icc_channel *channel = g_icc_ctrl.channels[channel_idx];
	struct icc_channel_vector *buf = NULL;
	
	/* 备份原通道的子通道 */
	g_icc_test.channels[channel_idx].vec_bak = channel->rector;
	g_icc_test.channels[channel_idx].func_size_bak = channel->func_size;

	/* 分配64个子通道 */
	buf = (struct icc_channel_vector *)osl_malloc(sizeof(struct icc_channel_vector) * new_sub_chn_size);
	if (!buf)
	{
		icc_print_error("malloc memory failed\n");
		return ICC_MALLOC_VECTOR_FAIL;
	}
	memset(buf, 0, sizeof(struct icc_channel_vector) * new_sub_chn_size); /*lint !e665 */

	/* 实际使用通道保留,实际子通道不超过32个 */
	memcpy(buf, channel->rector, sizeof(struct icc_channel_vector) * channel->func_size);/*lint !e516 */

	/* 实际通道+测试用通道 */
	channel->rector = buf;
	channel->func_size = new_sub_chn_size;
	channel->fifo_send->read = channel->fifo_send->write= 0;

	/* fifo长度减小,以便进行压力测试 */
	g_icc_test.channels[channel_idx].fifo_size_bak = channel->fifo_send->size;
	channel->fifo_recv->size = channel->fifo_send->size = ICC_TEST_FIFO_SIZE;

	return ICC_OK;
}
Exemplo n.º 7
0
void icc_channel_packet_dump(struct icc_channel_packet *packet)
{
	if ((0 == g_icc_dbg.msg_print_sw) && (0 == g_icc_ctrl.wake_up_flag))
	{
		return;
	}

	if (1 == g_icc_ctrl.wake_up_flag)
	{
		g_icc_ctrl.wake_up_flag = 0;
		icc_print_info("[C SR]icc recv msg dump\n");
	}

	if(!packet)
	{
		icc_print_error("packet pointer is NULL!\n");
		return;
	}

	icc_print_info("***********************************************************************\n");
	icc_print_info("icc_channel_packet.channel_id:     0x%x\n", packet->channel_id);
	icc_print_info("icc_channel_packet.len:            0x%x\n", packet->len);
	icc_print_info("icc_channel_packet.src_cpu_id:     0x%x\n", packet->src_cpu_id);
	icc_print_info("icc_channel_packet.timestamp:      0x%x\n", packet->timestamp);
	icc_print_info("icc_channel_packet.task_id:        0x%x\n", packet->task_id);
	icc_print_info("***********************************************************************\n");
}
Exemplo n.º 8
0
/* 回复确认信息或者核间函数调用结果返回 */
static s32 icc_send_test_001_cb1(u32 channel_id , u32 len, void* context)
{
	s32 confirm = ICC_RECV_OK;
	u8 *buf = NULL;

	buf = g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)].rd_buf;
	if(!buf)
	{
		icc_print_error("malloc mem error!\n");
		return ICC_ERR;
	}

	icc_print_debug("channel_id:0x%x\n", channel_id);
	//icc_task_delay(20);
	icc_print_debug("confirm_sem:0x%x\n", &(g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)-1].confirm_sem)); /*lint !e40 */

	if((s32)len == bsp_icc_read(channel_id, buf, len))
	{
		memcpy(&confirm, buf, sizeof(confirm));
		icc_print_debug("confirm:0x%x\n", confirm);
		if(ICC_RECV_OK == confirm)
		{
			g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)-1].success_cnt++;
			osl_sem_up(&(g_icc_test.channels[GET_CHN_ID(channel_id)].sub_channels[GET_FUNC_ID(channel_id)-1].confirm_sem)); /*lint !e40 !e516 */
		}
	}

	return ICC_SEND_SYNC_RET;
}
void icc_dbg_info_print(const char *fifo_name, u32 channel_id, u8 *data, u32 data_len)
{
	if(g_icc_dbg.msg_print_sw)
	{
		icc_print_error("%s: channel[0x%x], msg[0x%p], len[%d]:\n", fifo_name, channel_id, data, data_len);
	}
}
s32  icc_debug_init(u32 channel_num)
{
	u32 i = 0;
	struct icc_channel_info * channel = NULL;
	struct icc_channel_stat_info *sub_channel = NULL;
	struct icc_channel *icc_channel = NULL;
	
	memset(&g_icc_dbg, 0, sizeof(struct icc_dbg));

	for(i = 0; i < channel_num; i++)
	{
		/* 使用g_icc_ctrl而不是g_icc_init_info,因为测试编进去以后,统计通道不需要再处理 */
		icc_channel = g_icc_ctrl.channels[g_icc_init_info[i].real_channel_id];
		channel = (struct icc_channel_info *)osl_malloc(sizeof(struct icc_channel_info));
		if (!channel)
		{
			icc_print_error("malloc icc_channel_info memory fail!\n");
			return (s32)ICC_ERR;
		}

		/* 收发子通道一同分配 */
		sub_channel = (struct icc_channel_stat_info *)osl_malloc(sizeof(struct icc_channel_stat_info) * icc_channel->func_size * 2);
		if (!sub_channel)
		{
			osl_free((void *)channel);
			icc_print_error("malloc icc_channel_stat_info memory fail!\n");
			return (s32)ICC_ERR;
		}

		/* channel init */
		memset((void *)channel, 0, sizeof(struct icc_channel_info));
		channel->id = icc_channel->id;
		channel->recv.func_size= icc_channel->func_size;
		channel->send.func_size= icc_channel->func_size;

		/* sub channel init */
		memset((void *)sub_channel, 0, sizeof(struct icc_channel_stat_info) * icc_channel->func_size * 2); /*lint !e665 */
		channel->send.sub_chn  = sub_channel;
		channel->recv.sub_chn  = &(sub_channel[icc_channel->func_size]);
		
		g_icc_dbg.channel_stat[channel->id] = channel;
	}

	icc_dump_init();

	return ICC_OK;
}
BSP_S32 BSP_ICC_Ioctl(BSP_U32 u32ChanId, BSP_U32 cmd, BSP_VOID *param)
{
	u32 func_id = ICC_DEFAULT_SUB_CHANNEL;
	u32 channel_id = u32ChanId << 16 | func_id;
	s32 ret = ICC_OK;
	
	if(u32ChanId >= ICC_CHN_ID_MAX)
	{
		icc_print_error("invalid param[%d].\n", u32ChanId);
		return BSP_ERR_ICC_INVALID_PARAM;
	}
	switch(cmd)
	{
		case ICC_IOCTL_SET_READ_CB:
		{
			ret = (s32)bsp_icc_event_register(channel_id, icc_read_cb_wraper ,(void*)param, NULL, NULL);
			break;
		}
		case ICC_IOCTL_SET_WRITE_CB:
		{
			ret = (s32)bsp_icc_event_register(channel_id, NULL, NULL, icc_write_cb_wraper ,(void*)param);
			break;
		}
		case ICC_IOCTL_GET_STATE:
		{
			ret = (s32)bsp_icc_channel_status_get((u32)u32ChanId, (u32*)param);
			break;
		}
		case ICC_IOCTL_SET_EVENT_CB:
		{
			break;
		}
		default:
		{
			icc_print_error("channel[%d] invalid cmd[%d].\n", u32ChanId, cmd);
			ret = BSP_ERR_ICC_INVALID_PARAM;
			break;
		}
	}
	
	return ret;
}
Exemplo n.º 12
0
int mdrv_icc_register_resume_cb(unsigned int u32ChanId, FUNCPTR_1 debug_routine, int param)
{
    u32 channel_id = 0;

    if (icc_channel_logic2phy(u32ChanId, &channel_id))
    {
        icc_print_error("icc_channel_logic2phy err logic id 0x%x\n", u32ChanId);
        return ICC_INVALID_PARA;
    }

	return bsp_icc_debug_register(channel_id,debug_routine,param);
}
Exemplo n.º 13
0
int BSP_ICC_Write(unsigned int u32ChanId, unsigned char* pData, int s32Size)
{
    u32 channel_id = 0;
    u32 channel_index = 0;

    if (icc_channel_logic2phy(u32ChanId, &channel_id))
    {
        icc_print_error("icc_channel_logic2phy err logic id 0x%x\n", u32ChanId);
        return ICC_INVALID_PARA;
    }

    channel_index = channel_id >> 16;

    if(!pData || channel_index >= ICC_CHN_ID_MAX)
    {
        icc_print_error("invalid param[%d], pData[0x%p]\n", channel_index, pData);
        return ICC_INVALID_PARA;
    }

    return (BSP_S32)bsp_icc_send(ICC_SEND_CPU, channel_id, (u8*)pData, (u32)s32Size);
}
BSP_S32 BSP_ICC_Read(BSP_U32 u32ChanId, BSP_U8* pData, BSP_S32 s32Size)
{
	u32 func_id = ICC_DEFAULT_SUB_CHANNEL;
	u32 channel_id = u32ChanId << 16 | func_id;
	
	if(!pData || u32ChanId >= ICC_CHN_ID_MAX)
	{
		icc_print_error("invalid param[%d], pData[%p]\n", u32ChanId, pData);
		return BSP_ERR_ICC_INVALID_PARAM;
	}

	return (BSP_S32)bsp_icc_read(channel_id, (u8*)pData, (u32)s32Size);
}
Exemplo n.º 15
0
static s32 icc_test_multi_send_wait_ack_init(u32 flag)
{
	icc_print_debug("************entry");
#if defined(__KERNEL__) || defined(__VXWORKS__)
	osl_sem_init(ICC_SEM_EMPTY, &(g_icc_test.multi_send_confirm_sem)); /*lint !e40 */
	if(ICC_ERR == osl_task_init("icc_wait", ICC_TEST_TASK_PRI+1, ICC_TASK_STK_SIZE,
			(task_entry)icc_test_wait, (void*)(flag), &g_icc_test.task_id))
    {
        icc_print_error("create icc_wait task error\n");
        return ICC_ERR;
    }
#elif defined(__CMSIS_RTOS)
	g_icc_test.multi_send_confirm_sem = osl_sem_init(1, multi_send_confirm_sem);
	g_icc_test.task_id = osThreadCreate(osThread(icc_test_wait), (void*)flag);
	if(NULL == g_icc_test.task_id)
	{
        icc_print_error("create icc_wait task error\n");
        return ICC_ERR;
    }
#endif

	return ICC_OK;
}
Exemplo n.º 16
0
static s32 icc_test_multi_send_test_init(u32 sn, u32 channel_id, task_entry entry)
{
	u32 channel_idx = GET_CHN_ID(channel_id);
	u32 sub_chn_idx = GET_FUNC_ID(channel_id);
	s32 *task_id = NULL;
	u8 name[30] = {0};
	
	icc_print_debug("************entry");

	g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx].success_cnt = 0;
	icc_print_debug("i:0x%x, channel_id:0x%x", sn, channel_id);
		
	task_id = &(g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx].task_id);
	sprintf((char*)name, "icc_mul%d", channel_id);

#if defined(__KERNEL__) || defined(__VXWORKS__)
	if(ICC_ERR == osl_task_init((char *)name, ICC_TEST_TASK_PRI, ICC_TASK_STK_SIZE,
		(task_entry)entry, (void*)(channel_id), (u32 *)task_id))
    {
        icc_print_error("create send test task error\n");
        return ICC_ERR;
    }
#elif defined(__CMSIS_RTOS)
	*task_id = osThreadCreate(osThread(icc_test_multi_send_func), (void*)channel_id);
	if(NULL == *task_id)
	{
		icc_print_error("create icc_wait task error\n");
		return ICC_ERR;
	}
#endif
	
	icc_print_debug("create send test task successfully\n");

	return ICC_OK;

}
Exemplo n.º 17
0
BSP_S32 BSP_ICC_Close(BSP_U32 u32ChanId)
{
    if ((u32ChanId >= UDI_ICC_GUOM0 ) && (u32ChanId <= UDI_ICC_GUOM5))
    {
        u32ChanId = u32ChanId - UDI_ICC_GUOM0 + ICC_CHN_GUOM0;
    }
    else
    {
        icc_print_error("invalid ChanId 0x%x\n", u32ChanId);
        return (BSP_S32)ICC_INVALID_PARA;
    }

    bsp_icc_channel_uninit((u32)u32ChanId);
    return ICC_OK;
}
Exemplo n.º 18
0
/* 该回调用于接收核不读数据,直接回确认信息给发送核 */
s32 icc_send_test_cb0_new(u32 channel_id , u32 len, void* context)
{
	u8  confirm     = ICC_CONF_MSG_TYPE1;
	u32 channel_idx = GET_CHN_ID(channel_id);
	u32 sub_chn_idx = GET_FUNC_ID(channel_id);
	u32 send_len    = sizeof(confirm);

	icc_print_debug("enter: channel_id=0x%x\n", ((channel_idx << 16) | (sub_chn_idx + 1)));

	if((s32)send_len != bsp_icc_send(g_icc_dbg.send_cpu_id, ((channel_idx << 16) | (sub_chn_idx + 1)), &confirm, send_len))
	{
		icc_print_error("send error!\n");
	}

	return ICC_OK;
}
Exemplo n.º 19
0
int BSP_ICC_Open(unsigned int u32ChanId, ICC_CHAN_ATTR_S *pChanAttr)
{
    u32 channel_id = 0;
    u32 channel_index = 0;
    struct bsp_icc_cb_info *pICC_cb_info;

    if (icc_channel_logic2phy(u32ChanId, &channel_id))
    {
        icc_print_error("icc_channel_logic2phy err logic id 0x%x\n", u32ChanId);
        goto out; /*lint !e801 */
    }

    channel_index = channel_id >> 16;
    if ((ICC_CHN_ID_MAX <= channel_index) || (!g_icc_ctrl.channels[channel_index]))
    {
        icc_print_error("invalid channel_index[%d]\n", channel_index);
        goto out; /*lint !e801 */
    }

    /* coverity[REVERSE_INULL] */
    if(!pChanAttr)
    {
        icc_print_error("pChanAttr is null!\n");
        goto out; /*lint !e801 */
    }
    else if(pChanAttr->u32FIFOOutSize != pChanAttr->u32FIFOInSize)
    {
        icc_print_error("invalid param u32ChanId[%d],pChanAttr[0x%p],fifo_in[0x%x],fifo_out[0x%x]\n",
            channel_index, pChanAttr, pChanAttr->u32FIFOInSize, pChanAttr->u32FIFOOutSize);
        goto out; /*lint !e801 */
    }

    if(pChanAttr->u32FIFOInSize > g_icc_ctrl.channels[channel_index]->fifo_send->size)/*lint !e574 */
    {
        icc_print_error("channel_id 0x%x user fifo_size(0x%x) > fifo_size(0x%x) defined in icc\n",
                        channel_id,
                        pChanAttr->u32FIFOInSize, g_icc_ctrl.channels[channel_index]->fifo_send->size);
        goto out; /*lint !e801 */
    }

    pICC_cb_info = osl_malloc(sizeof(struct bsp_icc_cb_info));
    if (pICC_cb_info == NULL) {
        icc_print_error("Fail to malloc memory \n");
        return ICC_MALLOC_MEM_FAIL;
    }

    pICC_cb_info->read_cb = pChanAttr->read_cb;
    pICC_cb_info->channel = u32ChanId;
    /* coverity[leaked_storage] */
    return (BSP_S32)bsp_icc_event_register(channel_id, icc_read_cb_wraper, pICC_cb_info, icc_write_cb_wraper, (void*)pChanAttr->write_cb);

out:
    return ICC_INVALID_PARA;
}
Exemplo n.º 20
0
/* 子通道初始化 */
static s32 icc_test_sub_chn_init(u32 channel_idx, u32 test_sub_chn_size, u32 start)
{
	u32 i = 0;
	u8 *buf = NULL;
	read_cb_func read_cb = NULL;
	u32 sub_chn_idx = 0;
	struct icc_test_sub_channel *sub_channel = NULL;

	/* 读写buffer一起分配 */
	buf = (u8 *)osl_malloc(ICC_TEST_FIFO_SIZE * test_sub_chn_size * 2); /*lint !e516 */
	if(NULL == buf)
	{
		icc_print_error("buf=0x%x, \n", buf);
		return ICC_MALLOC_MEM_FAIL;
	}
	memset(buf, 0x00,  ICC_TEST_FIFO_SIZE * test_sub_chn_size * 2); /*lint !e665 */

	for(i = 0; i < test_sub_chn_size; i++)
	{
		/* 32-64为测试用子通道 */
		sub_chn_idx = i + start;
		sub_channel = &(g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx]);
		sub_channel->wr_buf = buf + i * ICC_TEST_FIFO_SIZE;
		sub_channel->rd_buf = buf + i * (ICC_TEST_FIFO_SIZE + test_sub_chn_size);
#if defined(__KERNEL__) || defined(__VXWORKS__)
		osl_sem_init(ICC_SEM_EMPTY, &(sub_channel->confirm_sem)); /*lint !e40 */
#endif
		/* 子通道交替注册cb0和cb1 */
		read_cb = ((i & 0x01)? icc_send_test_001_cb1: icc_send_test_001_cb0);
		g_icc_ctrl.channels[channel_idx]->rector[sub_chn_idx].read_cb = read_cb;
		g_icc_ctrl.channels[channel_idx]->rector[sub_chn_idx].read_context = (void *)sub_chn_idx;

#ifdef ICC_HAS_DEBUG_FEATURE		
		icc_print_debug("i:0x%x, read_cb: 0x%x", i, read_cb);
		if(g_icc_dbg.msg_print_sw)
		{
			icc_channel_vector_dump(channel_idx,sub_chn_idx);
		}
#endif

	}

	return ICC_OK;
}
void icc_init_info_dump(u32 real_channel_id)
{
	struct icc_init_info* info = &(g_icc_init_info[real_channel_id%g_icc_ctrl.channel_size]);

	if(!info) /*lint !e774 */
	{
		icc_print_error("init_info pointer is NULL!\n");
		return;
	}
	icc_print_info("***********************************************************************\n");
	icc_print_info("icc_init_fifo.real_channel_id:     0x%x\n", info->real_channel_id);
	icc_print_info("icc_init_fifo.mode:                0x%x\n", info->mode);
	icc_print_info("icc_init_fifo.send_addr:           0x%p\n", info->send_addr);
	icc_print_info("icc_init_fifo.fifo_size:           0x%x\n", info->fifo_size);
	icc_print_info("icc_init_fifo.recv_addr:           0x%p\n", info->recv_addr);
	icc_print_info("icc_init_fifo.func_size:           0x%x\n", info->func_size);
	icc_print_info("icc_init_fifo.ipc_send_irq_id:     0x%x\n", info->ipc_send_irq_id);
	icc_print_info("icc_init_fifo.ipc_recv_irq_id:     0x%x\n", info->ipc_recv_irq_id);
	icc_print_info("***********************************************************************\n");
}
void icc_channel_vector_dump(u32 channel_id, u32 func_id)
{
	struct icc_channel_vector* vector = NULL;
	channel_id %= g_icc_ctrl.channel_size;
	func_id    %= g_icc_ctrl.channels[channel_id]->func_size;
	vector = &(g_icc_ctrl.channels[channel_id]->rector[func_id]);

	if(!vector)
	{
		icc_print_error("vector pointer is NULL!\n");
		return;
	}
	icc_print_info("***********************************************************************\n");
	icc_print_info("icc_channel_vector base addr:      %p\n", vector);
	icc_print_info("icc_channel_vector.read_cb:        %p\n", vector->read_cb);
	icc_print_info("icc_channel_vector.read_context:   %p\n", vector->read_context);
	icc_print_info("icc_channel_vector.write_cb:       %p\n", vector->write_cb);
	icc_print_info("icc_channel_vector.write_context:  %p\n", vector->write_context);
	icc_print_info("icc_channel_vector.return_data:    0x%x\n", vector->return_data);
	icc_print_info("***********************************************************************\n");
}
void icc_dump_init(void)
{
    /* reg the dump callback to om */
	if(bsp_dump_register_hook(ICC_DUMP_SAVE_MOD,(dump_save_hook)icc_dump_hook))
	{
	    goto err_ret;
	}

	if(bsp_dump_get_buffer(ICC_DUMP_SAVE_MOD,&g_icc_dbg.dump_buf_addr, &g_icc_dbg.dump_buf_size))
	{
	    goto err_ret;
	}

    return;

err_ret:
    g_icc_dbg.dump_buf_addr = NULL;
    g_icc_dbg.dump_buf_size = 0;
	icc_print_error("try to use dump fail!\n");
    return;
}
Exemplo n.º 24
0
/* 逻辑通道到物理通道的转换 */
int icc_channel_logic2phy(u32 u32ChanId, u32 *channel_id)
{
    int i = 0;
    int loop_cnt = sizeof(g_icc_channel_map_logic2phy)/sizeof(struct icc_channel_map_logic2phy);

    for (i = 0; i < loop_cnt; i++)
    {
        if (u32ChanId == g_icc_channel_map_logic2phy[i].logic_id)
        {
            *channel_id = g_icc_channel_map_logic2phy[i].channel_id;
            break;
        }
    }

    if (i >= loop_cnt)
    {
        icc_print_error("invalid logic id 0x%x\n", u32ChanId);
        return MDRV_ERROR;
    }

    return MDRV_OK;
}
void icc_channel_dump(u32 real_channel_id)
{
	struct icc_channel* channel = g_icc_ctrl.channels[real_channel_id%g_icc_ctrl.channel_size];
	u32 i = 0;

	if(!channel)
	{
		icc_print_error("channel pointer is NULL!\n");
		return;
	}

	icc_print_info("***********************************************************************\n");
	icc_print_info("icc_channel address:                  %p\n", channel);
	icc_print_info("icc_channel.id:                       0x%x\n", channel->id);
	icc_print_info("icc_channel.state:                    0x%x\n", channel->state);
	icc_print_info("icc_channel.mode:                     0x%x\n", channel->mode.val);
	icc_print_info("icc_channel.task_id:                  0x%p\n", channel->private_task_id);
	icc_print_info("icc_channel.ipc_send_irq_id:          0x%x\n", channel->ipc_send_irq_id);
	icc_print_info("icc_channel.ipc_recv_irq_id:          0x%x\n", channel->ipc_recv_irq_id);
	icc_print_info("icc_channel.fifo_recv:                %p\n", channel->fifo_recv);
	icc_print_info("icc_channel.fifo_send:                %p\n", channel->fifo_send);
	for(i = 0; i < channel->func_size; i++)
	{
		if(i < 10)
		{
			icc_print_info("icc_channel.channel->rector[%d]:       0x%p\n", i, &channel->rector[i]);
		}
		else
		{
			icc_print_info("icc_channel.channel->rector[%d]:      0x%p\n", i, &channel->rector[i]);
		}
	}
	icc_print_info("icc_channel.func_size:                0x%x\n", channel->func_size);
	icc_print_info("icc_channel.seq_num_recv              0x%x\n", channel->seq_num_recv);
	icc_print_info("icc_channel.seq_num_send:             0x%x\n", channel->seq_num_send);
	icc_print_info("***********************************************************************\n");
}
Exemplo n.º 26
0
static s32 icc_test_multi_send_sync_func(void *obj)
{
	u32 channel_id = (u32)obj;
	u32 channel_idx = GET_CHN_ID(channel_id);
	u32 sub_chn_idx = GET_FUNC_ID(channel_id);
	u32 i = 0;
	u32 send_data = 0x10305070;

#ifdef ICC_HAS_SYNC_SEND_FEATURE
	for(i = 0; i < ICC_TEST_SEND_CNT; i++)
	{
		if (ICC_SEND_SYNC_RET != bsp_icc_send_sync(ICC_SEND_CPU,channel_id,(u8*)&send_data,sizeof(send_data),MAX_SCHEDULE_TIMEOUT)) /*lint !e40 !e516*/
		{
			icc_print_error("[FAIL] synchronous send!\n");
			return ICC_TEST_PASS;
		}
		g_icc_test.channels[channel_idx].sub_channels[sub_chn_idx].success_cnt++;
	}
#endif

	icc_print_info("[PASS] synchronous send\n");

	return ICC_TEST_PASS;
}
Exemplo n.º 27
0
s32 bsp_icc_test_init(void)
{
	u32 i = 0;
	s32 ret = ICC_OK;
	
	if(ICC_TEST_CASE_INITILIZED == g_icc_test.state)
	{
		icc_print_error("icc_test has intilized\n");
		return ICC_OK;
	}

	memset(&g_icc_test, 0, sizeof(g_icc_test)); /*lint !e665 */

	icc_print_debug("icc_test initilizing\n");

	for(i = 0; i < ICC_VALIDE_CHN_NUM; i++)
	{
		ret = icc_test_channel_reinit(g_icc_init_info[i].real_channel_id, ICC_TEST_CHANNEL_SIZE);
		if(ICC_OK != ret)
		{
			icc_print_error("icc_test_channel_reinit error\n");
			return ICC_ERR;
		}

		ret = icc_test_sub_chn_init(g_icc_init_info[i].real_channel_id, ICC_TEST_CHANNEL_SIZE/2, ICC_TEST_CHANNEL_START);
		if(ICC_OK != ret)
		{
			icc_print_error("icc_test_sub_chn_init error\n");
			return ICC_ERR;
		}
	}

#ifdef ICC_HAS_DEBUG_FEATURE
	/* 测试打开打印开关 */
	icc_dbg_print_sw(0);
#endif

	ret = icc_test_channel_reinit(ICC_CHN_CSHELL, SUPPORT_ICC_READ_IN_OTHER_TASK);
	if(ICC_OK != ret)
	{
		icc_print_error("cshell_channel_reinit error\n");
		return ICC_ERR;
	}

	ret = icc_test_sub_chn_init(ICC_CHN_CSHELL, SUPPORT_ICC_READ_IN_OTHER_TASK, 0);
	if(ICC_OK != ret)
	{
		icc_print_error("cshell_test_sub_chn_init error\n");
		return ICC_ERR;
	}

	bsp_icc_event_unregister(ICC_CHN_CSHELL << 16 | 0);
	bsp_icc_event_unregister(ICC_CHN_CSHELL << 16 | 1);
	bsp_icc_event_unregister(ICC_CHN_CSHELL << 16 | 2);

	bsp_icc_event_register(ICC_CHN_CSHELL << 16 | 0, (read_cb_func)icc_send_test_cb0_new, NULL, NULL, NULL);
	bsp_icc_event_register(ICC_CHN_CSHELL << 16 | 1, (read_cb_func)icc_send_test_cb1_new, NULL, NULL, NULL);
	bsp_icc_event_register(ICC_CHN_CSHELL << 16 | 2, (read_cb_func)icc_send_test_cb2_new, NULL, NULL, NULL);

	osl_sem_init(ICC_SEM_EMPTY,  &g_icc_test.recv_task_sem); /*lint !e40 */

	g_icc_test.recv_task_flag = 1;
	if(ICC_ERR == osl_task_init("icc_read_test", ICC_TEST_TASK_PRI+1, ICC_TASK_STK_SIZE,
			(task_entry)icc_read_task_entry, (void *)(ICC_CHN_CSHELL << 16 | 2), (u32 *)&g_icc_test.recv_task_id))
    {
        icc_print_error("create icc_read_test task error\n");
        return ICC_ERR;
    }

	icc_debug_init(bsp_icc_channel_size_get());

	/* 状态最后更新 */
	g_icc_test.state = ICC_TEST_CASE_INITILIZED;

	return ICC_OK;
}
Exemplo n.º 28
0
/* 新增mcore后, 三核共用的测试代码开始 2012/06/13*/
s32 bsp_icc_mcore_test_init(void)
{
	u32 mcoore_test_channel_size = 0;
	u32 channel_idx[2]={0};
	s32 ret = ICC_OK;
	u32 i = 0;
	
	if(ICC_TEST_CASE_INITILIZED == g_icc_test.mcore_test_state)
	{
		icc_print_error("icc mcore test has initilized\n");
		return ICC_OK;
	}

	icc_print_debug("icc mcore test initilizing\n");

#ifdef __KERNEL__
	mcoore_test_channel_size = 1;
	channel_idx[0] = ICC_CHN_MCORE_ACORE;
#elif defined( __VXWORKS__)
	mcoore_test_channel_size = 1;
	channel_idx[0] = ICC_CHN_MCORE_CCORE;
#elif defined(__CMSIS_RTOS) /* rtx(cm3 os) */
	mcoore_test_channel_size = 2;
	channel_idx[0] = ICC_CHN_MCORE_CCORE;
	channel_idx[1] = ICC_CHN_MCORE_ACORE;
#endif

	for(i = 0; i < mcoore_test_channel_size; i++)
	{
		/* 20个子通道, 现有16个子通道的基础上再分配4个 */
		ret = icc_test_channel_reinit(channel_idx[i], ICC_TEST_MCORE_CHN_SIZE);
		if(ICC_OK != ret)
		{
			icc_print_error("icc_test_channel_reinit error\n");
			return ICC_ERR;
		}

		/* 使用后4个子通道进行测试 */
		ret = icc_test_sub_chn_init(channel_idx[i], ICC_TEST_USE_CHN_SIZE, ICC_TEST_MCORE_START_CHN);
		if(ICC_OK != ret)
		{
			icc_print_error("icc_test_sub_chn_init error\n");
			return ICC_ERR;
		}
	}
	
#ifdef __CMSIS_RTOS
		g_icc_test.channels[ICC_CHN_MCORE_CCORE].sub_channels[16].confirm_sem = osl_sem_init(1, confirm_sem01);/*lint !e416 !e831*/
		g_icc_test.channels[ICC_CHN_MCORE_CCORE].sub_channels[18].confirm_sem = osl_sem_init(1, confirm_sem02);/*lint !e416 !e831*/
		g_icc_test.channels[ICC_CHN_MCORE_ACORE].sub_channels[16].confirm_sem = osl_sem_init(1, confirm_sem03);/*lint !e416 !e831*/
		g_icc_test.channels[ICC_CHN_MCORE_ACORE].sub_channels[18].confirm_sem = osl_sem_init(1, confirm_sem04);/*lint !e416 !e831*/

		osl_sem_down(&(g_icc_test.channels[ICC_CHN_MCORE_CCORE].sub_channels[16].confirm_sem));/*lint !e416 !e831*/
		osl_sem_down(&(g_icc_test.channels[ICC_CHN_MCORE_CCORE].sub_channels[18].confirm_sem));/*lint !e416 !e831*/
		osl_sem_down(&(g_icc_test.channels[ICC_CHN_MCORE_ACORE].sub_channels[16].confirm_sem));/*lint !e416 !e831*/
		osl_sem_down(&(g_icc_test.channels[ICC_CHN_MCORE_ACORE].sub_channels[18].confirm_sem));/*lint !e416 !e831*/
#endif

#ifdef ICC_HAS_DEBUG_FEATURE
	/* 测试打开打印开关 */
	icc_dbg_print_sw(0);
#endif

	/* 状态最后更新 */
	g_icc_test.mcore_test_state = ICC_TEST_CASE_INITILIZED;

	return ICC_OK;
}