1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __FRW_TASK_H__ 20 #define __FRW_TASK_H__ 21 22 /* **************************************************************************** 23 1 其他头文件包含 24 **************************************************************************** */ 25 #include "oal_ext_if.h" 26 27 #ifdef __cplusplus 28 #if __cplusplus 29 extern "C" { 30 #endif 31 #endif 32 33 /* **************************************************************************** 34 枚举定义 35 **************************************************************************** */ 36 /* 线程的运行状态 */ 37 typedef enum { 38 FRW_TASK_STATE_IRQ_UNBIND = 0, /* 线程处于暂停状态 */ 39 FRW_TASK_STATE_IRQ_BIND, /* 线程处于运行状态 */ 40 41 FRW_TASK_BUTT 42 } frw_task_state_enum; 43 typedef hi_u8 frw_task_state_enum_uint8; 44 45 /* **************************************************************************** 46 4 STRUCT定义 47 **************************************************************************** */ 48 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 49 typedef struct { 50 #if (_PRE_FRW_FEATURE_PROCESS_ENTITY_TYPE == _PRE_FRW_FEATURE_PROCESS_ENTITY_THREAD) 51 hi_u32 taskid; /* task变量 */ 52 oal_wait_queue_head_stru frw_wq; /* waitqueue */ 53 hi_void (*event_handler_func)(hi_void *_pst_bind_cpu); /* kthread主程序 */ 54 55 #elif (_PRE_FRW_FEATURE_PROCESS_ENTITY_TYPE == _PRE_FRW_FEATURE_PROCESS_ENTITY_TASKLET) 56 oal_tasklet_stru event_tasklet; /* tasklet变量 */ 57 hi_void (*event_handler_func)(hi_u32); /* tasklet处理程序 */ 58 #endif 59 } frw_task_stru; 60 61 #else /* (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) */ 62 63 typedef struct { 64 oal_kthread_stru *pst_event_kthread; 65 oal_wait_queue_head_stru frw_wq; 66 hi_u8 uc_task_state; 67 hi_u8 auc_resv[3]; /* resv 3 byte */ 68 hi_u32 ul_total_loop_cnt; 69 hi_u32 ul_total_event_cnt; 70 hi_u32 ul_max_empty_count; 71 hi_void (*p_event_handler_func)(hi_void *_pst_bind_cpu); 72 } frw_task_stru; 73 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) */ 74 75 /* **************************************************************************** 76 函数声明 77 **************************************************************************** */ 78 hi_u32 frw_task_init(hi_void); 79 hi_void frw_task_exit(hi_void); 80 hi_void frw_task_event_handler_register(hi_void (*func)(hi_void)); 81 hi_void frw_task_sched(hi_void); 82 83 #ifdef __cplusplus 84 #if __cplusplus 85 } 86 #endif 87 #endif 88 89 #endif /* end of frw_task.h */ 90