update dev_ck_v2.1_feature#1609 to dev_ck_v2.1
1. add error return(inc/err_num.h and osp/inc/err_num.h) 2. change the task init function: old: typedef void(*OSP_TASKINIT_FUNC)(void); new: typedef int(*OSP_TASKINIT_FUNC)(void); 3. osp_task_create: 3.1 before create task should call the init function first 3.2 if the init function return error, don't call the create task, return error 4. Test: 4.1 spu_case0_arm_case0_cpri: Pass 4.2 spu_case14_arm_case20_cpri: Pass 4.3 spu_case20_arm_case20_cpri: Pass 4.4 spu_case21_arm_case21_cpri: Pass 4.5 spu_case34_arm_case5: Pass 4.6 spu_case44_arm_case5: Pass 4.7 spu_case20_arm_case20_task_ok: Pass 4.8 spu_case20_arm_case20_task_ng: Pass
This commit is contained in:
parent
0456ba42e4
commit
c42c2cea82
@ -8,5 +8,7 @@
|
||||
#define OSP_QUE_EMPT (4) /* 软队列空 */
|
||||
#define OSP_MEM_FULL (5) /* 内存申请失败 */
|
||||
|
||||
#define OSP_TASK_INIT_ERR (12) /* 任务初始化函数返回失败 */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -57,7 +57,7 @@ typedef enum OSP_TASK_TYPE
|
||||
|
||||
/* 函数类型*/
|
||||
typedef void(*OSP_TASKENTRY_FUNC)();
|
||||
typedef void(*OSP_TASKINIT_FUNC)(void);
|
||||
typedef int(*OSP_TASKINIT_FUNC)(void);
|
||||
|
||||
/* 任务信息结构体 */
|
||||
typedef struct OSP_TASK_INFO_EX
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define OSP_HW_VECT (9) /* 硬件队列获取中断号失败 */
|
||||
#define OSP_HW_IRQ (10) /* 硬件队列注册中断服务失败 */
|
||||
#define OSP_HW_EMPTY_ERR (11) /* 硬件队列非空中断使能失败 */
|
||||
#define OSP_TASK_INIT_ERR (12) /* 任务初始化函数返回失败 */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,7 +36,7 @@ typedef enum OSP_TASK_TYPE
|
||||
|
||||
/* 函数类型*/
|
||||
typedef void(*OSP_TASKENTRY_FUNC)();
|
||||
typedef void(*OSP_TASKINIT_FUNC)(void);
|
||||
typedef int(*OSP_TASKINIT_FUNC)(void);
|
||||
|
||||
typedef struct osp_task_data{
|
||||
uint32_t end_flag; /* 0xffff --> end */
|
||||
@ -110,7 +110,7 @@ typedef struct tcb_struct
|
||||
int once_value;
|
||||
sem_t *sem;
|
||||
sem_t *event_sem;
|
||||
void (*init_func)(void);
|
||||
int (*init_func)(void);
|
||||
void (*loop_fun)();
|
||||
osp_sw_queue *que_head; // dm space
|
||||
int period;
|
||||
|
@ -64,7 +64,7 @@ static void osp_event_task(void *data)
|
||||
{
|
||||
osp_tcb *tcb_val = (osp_tcb*)data;
|
||||
osp_msg_head *ptr = NULL;
|
||||
(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
//(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
while(1)
|
||||
{
|
||||
osp_wait_sem(tcb_val->event_sem);
|
||||
@ -94,7 +94,7 @@ static void osp_mtimer_task(void *data)
|
||||
{
|
||||
osp_tcb *tcb_val = (osp_tcb*)data;
|
||||
//osp_msg_head *ptr = NULLPTR;
|
||||
(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
//(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
while(1)
|
||||
{
|
||||
osp_wait_sem(tcb_val->sem); //本文件不要存在os 接口函数
|
||||
@ -116,7 +116,7 @@ static void osp_loop_task(void *data)
|
||||
{
|
||||
osp_tcb *tcb_val = (osp_tcb*)data;
|
||||
//osp_msg_head *ptr = NULLPTR;
|
||||
(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
//(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
while(1)
|
||||
{
|
||||
osp_delay_cycle(tcb_val->delay_cycle);
|
||||
@ -141,7 +141,7 @@ static void osp_driver_task(void *data)
|
||||
{
|
||||
osp_tcb *tcb_val = (osp_tcb*)data;
|
||||
osp_msg_head *ptr = NULL;
|
||||
(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
//(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
while(1)
|
||||
{
|
||||
osp_delay_cycle(tcb_val->delay_cycle);
|
||||
@ -171,7 +171,7 @@ static void osp_osp_task(void *data)
|
||||
{
|
||||
osp_tcb *tcb_val = (osp_tcb*)data;
|
||||
osp_msg_head *ptr = NULL;
|
||||
(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
//(tcb_val->init_func == NULL)? 0:tcb_val->init_func();
|
||||
while(1)
|
||||
{
|
||||
osp_delay_cycle(tcb_val->delay_cycle);
|
||||
@ -480,6 +480,7 @@ malloc_stack_failed:
|
||||
0x1b: sw_que init failed(event task)
|
||||
0x1c: timer point is overflow(timer task)
|
||||
0x1d: os create task failed
|
||||
0x1e: task_init return error
|
||||
#21: task id
|
||||
*/
|
||||
int osp_task_create(osp_task_info_ex *t_info_val)
|
||||
@ -495,6 +496,8 @@ int osp_task_create(osp_task_info_ex *t_info_val)
|
||||
char *stack_top = NULL;
|
||||
void (*ptask_fun)(void *);
|
||||
int ret = -1;
|
||||
|
||||
/* 任务主函数不能为空 */
|
||||
if(t_info_val->task_entry == NULL)
|
||||
{
|
||||
UCP_PRINT_ERROR("task(%d) entry is none", t_info_val->task_id);
|
||||
@ -504,6 +507,21 @@ int osp_task_create(osp_task_info_ex *t_info_val)
|
||||
#endif
|
||||
return -OSP_PAR_ILL;
|
||||
}
|
||||
|
||||
/* 若任务有初始化函数,先执行初始化函数 */
|
||||
if (t_info_val->task_init != NULL)
|
||||
{
|
||||
if (-1 == t_info_val->task_init())
|
||||
//if (-1 == ret)
|
||||
{
|
||||
#ifdef OSP_DEBUG_TEST
|
||||
debug_write(OSP_DEBUG_POT(g_ape_id, 20), 0x1e);
|
||||
debug_write(OSP_DEBUG_POT(g_ape_id, 21), t_info_val->task_id);
|
||||
#endif
|
||||
return -OSP_TASK_INIT_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
if(t_info_val->task_id > TASK_ID_MAX)
|
||||
{
|
||||
UCP_PRINT_ERROR("task(%d) id is error", t_info_val->task_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user