#ifndef __SMARTOS_H__ #define __SMARTOS_H__ typedef unsigned int uint32_t; typedef unsigned short uint16_t; typedef unsigned char uint8_t; typedef void (*start_hook_func)(int); typedef void (*irq_handler)(); typedef enum { smart_all_irq, smart_fun_s, smart_fun_e, smart_clear_cnt_error, smart_irq_check_error }smart_irq_cnt_type_t; /* 函数名称:smart_kernel_init 输入参数: usr_startup 输入参数: cpuid 返回类型:void 函数功能:smart系统初始化接口 */ extern void smart_kernel_init(start_hook_func *usr_startup,int cpuid); /* 函数名称:smart_irq_enable 输入参数: vector 返回类型:int 返回值 : 小于0 注册 返回值:等于0 成功 函数功能: 使能对应中断号的intmask */ int smart_irq_enable(uint32_t vector); /* 函数名称:smart_irq_disable 输入参数: vector 返回类型:int 返回值 : 小于0 注册 返回值:等于0 成功 函数功能: 屏蔽对应中断号对应的intmask */ int smart_irq_disable(uint32_t vector); /* 函数名称:smart_irq_request 输入参数: vector 输入参数: func 函数指针 返回类型:int 返回值 : 小于0 注册失败 返回值:等于0 注册成功 函数功能: 中断注册接口 */ extern int smart_irq_request(uint32_t vector,irq_handler func); /* 函数名称:smart_irq_free 参数:vector 返回值:0:成功 非0:失败 函数功能:中断注销 */ extern int smart_irq_free(uint32_t vector); /* 函数名称:smart_int_disable 参数:无 返回值:无 函数功能:关中断 */ extern void smart_int_disable(); /* 函数名称:smart_int_enable 参数:无 返回值:无 函数功能:开中断 */ extern void smart_int_enable(); /* 函数名称:smart_get_curprio 输入参数: 无 返回类型:int 返回值 : 小于0获取失败 返回值:大于0获取成功 */ extern int smart_get_curprio(); /* 函数名称:smart_get_cpuid 输入参数: 无 返回类型:int 返回值 : 小于0获取失败 返回值:大于0获取成功 */ extern int smart_get_cpuid(); /* 函数名称:smart_task_create 输入参数: void (*task)(void *p_arg) 输入参数:*p_arg 输入参数:*ptos; 栈顶 输入参数:prio 优先级 输入参数:id 任务id 号 输入参数:*pbos 栈底 输入参数:stk_size; 堆栈大小 返回类型:int 返回值:0任务注册成功 函数功能:注册任务 */ extern uint8_t smart_task_create (void (*task)(void *p_arg), void *p_arg, uint32_t *ptos, uint8_t prio, uint16_t id, uint32_t *pbos, uint32_t stk_size); /* 函数名称:smart_tick_sleep 输入参数: cycle 参数类型: int 返回值:无 函数功能:休眠tick 时间 */ extern void smart_tick_sleep(int cycle); /* 函数名称:smart_task_del 输入参数: prio 参数类型: int 返回类型:int 返回值:非0 删除失败 函数功能:删除任务 注意事项:如果当前任务使用了信号量,或者其它资源,要首先删除任务,然后再删除资源,否则资源会被一直占用。 低优先级任务删除其它任务删除成功有可能不会立刻返回;删除失败立刻返回。 */ extern int smart_task_del(int prio); /***************************************************************** sem relation ****************************************************************/ /****************************************** 函数名称:smart_sem_create 输入参数: cnt 参数类型: int 返回值:void * 函数功能:创建计数信号量,返回信号量句柄 *****************************************/ extern void *smart_sem_create(int cnt); /****************************************** 函数名称:smart_sem_pend 输入参数: void *sem 信号量句柄 参数类型: void * 返回值:无 函数功能:获取信号量,失败休眠 *****************************************/ extern void smart_sem_pend(void *sem); /****************************************** 函数名称:smart_sem_post 输入参数: void *sem 信号量句柄 参数类型: void * 返回值: 0 成功,小于0 失败 函数功能:释放信号量 *****************************************/ extern int smart_sem_post(void *sem); /******************************************* 函数名称:smart_sem_del 输入参数: void *sem 信号量句柄 参数类型: void * 返回值: 0 成功,小于0 失败 函数功能:释放信号量 注意事项: 删除信号量时一定要进行判断,确认信号量删除是否成功 ******************************************/ extern int smart_sem_del(void *sem); extern int smart_get_reg_prio(int *buf); /* 函数名称:smart_reclaim_init_res 输入参数:无 返回类型:void 返回值 : 无 函数功能:系统初始化任务资源回收 */ extern void smart_reclaim_init_res(); /* 函数名称:smart_irq_debug_init 输入参数:debug_base_addr 调试buf 首地址 输入参数:len_bytes 调试buf 长度 返回类型:int 返回值 : 小于0 返回失败 返回值: 等于0 返回成功 函数功能:中断调试初始化接口 */ extern int smart_irq_debug_init(uint32_t debug_base_addr, uint32_t len_bytes); /* 函数名称:smart_irq_get_type_cnt 输入参数:num_type 输入参数:参数类型 irq_cnt_type_t typedef enum { all_irq, fun_s, fun_e, clear_cnt_error, irq_check_error }irq_cnt_type_t; 返回类型:uint32_t 返回值 : 小于0 返回失败 返回值: 等于0 返回成功 函数功能:获取各类型中断计数 */ extern uint32_t smart_irq_get_type_cnt(smart_irq_cnt_type_t num_type); /* 函数名称:smart_irq_get_run_cnt 输入参数:irqnum 返回类型:int 返回值 : 小于0 返回失败 返回值: 大于0 返回成功 函数功能:获取中断入口统计计数 */ extern int smart_irq_get_run_cnt(uint32_t irqnum); /* 函数名称:smart_os_debug_init 输入参数:debug_base_addr 调试buf 首地址 输入参数:len_bytes 调试buf 长度,长度不小于0x40 返回类型:int 返回值 : 小于0 返回失败 返回值: 等于0 返回成功 函数功能:任务切换调试表初始化接口 */ extern int smart_os_debug_init( uint32_t debug_base_addr, uint32_t len_bytes); /* 函数名称:smart_no_idle_sw_init 输入参数:debug_base_addr 调试buf 首地址 输入参数:lens 调试buf 长度长度不小于0x40 返回类型:int 返回值 : 小于0 返回失败 返回值: 等于0 返回成功 函数功能:任务切换调试表初始化接口,切换表不记录idle 任务 */ extern int smart_no_idle_sw_init(uint32_t debug_base_addr, uint32_t lens); #endif