1 #ifndef SUNXI_HAL_THREAD_H 2 #define SUNXI_HAL_THREAD_H 3 4 #ifdef __cplusplus 5 extern "C" 6 { 7 #endif 8 9 #ifdef CONFIG_KERNEL_FREERTOS 10 11 #include <pthread.h> 12 void *kthread_create(void (*threadfn)(void *data), void *data, const char *namefmt, ...); 13 int kthread_stop(void *thread); 14 15 #else 16 17 #include <rtthread.h> 18 19 #define HAL_THREAD_STACK_SIZE (0x2000) 20 #define HAL_THREAD_PRIORITY ( 15) 21 #define HAL_THREAD_TIMESLICE ( 10) 22 23 void *kthread_create(void (*threadfn)(void *data), void *data, const char *namefmt, ...); 24 int kthread_stop(void *thread); 25 int kthread_start(void *thread); 26 int kthread_wakeup(void *thread); 27 int kthread_suspend(void *thread); 28 29 /** 30 * kthread_run - create and wake a thread. 31 * @threadfn: the function to run until signal_pending(current). 32 * @data: data ptr for @threadfn. 33 * @namefmt: printf-style name for the thread. 34 * 35 * Description: Convenient wrapper for kthread_create() followed by 36 * wake_up_process(). Returns the kthread or ERR_PTR(-ENOMEM). 37 */ 38 #define kthread_run(threadfn, data, namefmt, ...) \ 39 ({ \ 40 struct rt_thread *__k \ 41 = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \ 42 if (!IS_ERR((unsigned long)__k)) \ 43 rt_thread_startup(__k); \ 44 __k; \ 45 }) 46 47 //#define in_interrupt(...) rt_interrupt_get_nest() 48 49 50 #endif 51 #ifdef __cplusplus 52 } 53 #endif 54 #endif 55