VSF Documented
vsf_thread.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_THREAD_H__
19#define __VSF_THREAD_H__
20
21/*============================ INCLUDES ======================================*/
22
24
25#if VSF_KERNEL_CFG_SUPPORT_THREAD == ENABLED && VSF_USE_KERNEL == ENABLED
26#include "../vsf_eda.h"
27
28#if VSF_KERNEL_CFG_EDA_SUPPORT_TASK == ENABLED
29# include "./vsf_task.h"
30#endif
31
32#if defined(__VSF_THREAD_CLASS_IMPLEMENT)
33# undef __VSF_THREAD_CLASS_IMPLEMENT
34# define __PLOOC_CLASS_IMPLEMENT__
35#elif defined(__VSF_THREAD_CLASS_INHERIT__)
36# undef __VSF_THREAD_CLASS_INHERIT__
37# define __PLOOC_CLASS_INHERIT__
38#endif
39
40#include "utilities/ooc_class.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/*============================ MACROS ========================================*/
47
48#ifndef VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE
49# define VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE 1
50#endif
51#ifndef VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE
52# define VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE 0
53#endif
54
55#ifndef VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT
56# ifdef VSF_ARCH_STACK_ALIGN_BIT
57# define VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT VSF_ARCH_STACK_ALIGN_BIT
58# else
59# define VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT 3
60# endif
61#endif
62
63#define __VSF_THREAD_STACK_SAFE_SIZE(__stack) \
64 ( ( ( ((__stack) + VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE - 1) \
65 / VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE) \
66 * VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE) \
67 + VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE)
68
69#ifdef VSF_ARCH_LIMIT_NO_SET_STACK
70// arch does not support set stack, use host_thread mode
71# define VSF_KERNEL_THREAD_USE_HOST ENABLED
72# ifdef VSF_ARCH_RTOS_DYNAMIC_STACK
73# define VSF_KERNEL_THREAD_DYNAMIC_STACK ENABLED
74# if VSF_KERNEL_CFG_THREAD_STACK_CHECK == ENABLED
75# warning VSF_KERNEL_CFG_THREAD_STACK_CHECK is not usable for dynamic stack
76# undef VSF_KERNEL_CFG_THREAD_STACK_CHECK
77# define VSF_KERNEL_CFG_THREAD_STACK_CHECK DISABLED
78# endif
79# endif
80#endif
81
82/*============================ MACROFIED FUNCTIONS ===========================*/
83
84#define __declare_vsf_thread(__name) \
85 typedef struct __name __name; \
86 typedef struct thread_cb_##__name##_t thread_cb_##__name##_t;
101#define declare_vsf_thread(__name) __declare_vsf_thread(__name)
114#define declare_vsf_thread_ex(__name) __declare_vsf_thread(__name)
115
124#define dcl_vsf_thread(__name) declare_vsf_thread(__name)
133#define dcl_vsf_thread_ex(__name) declare_vsf_thread(__name)
134
135#if VSF_KERNEL_THREAD_DYNAMIC_STACK == ENABLED
136# define __vsf_thread_set_stack_canery(__thread, __task) \
137 (__thread)->canary = 0xDEADBEEF;
138#else
139# define __vsf_thread_set_stack_canery(__thread, __task) \
140 (__task)->canary = 0xDEADBEEF;
141#endif
142
143#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
144# define __vsf_thread_set_stack(__thread, __task, __stack_ptr, __stack_bytesize)\
145 (__thread)->use_as__vsf_thread_cb_t.stack = (__stack_ptr); \
146 (__thread)->use_as__vsf_thread_cb_t.stack_size = (__stack_bytesize);\
147 __vsf_thread_set_stack_canery(__thread, __task)
148#else
149# define __vsf_thread_set_stack(__thread, __task, __stack_ptr, __stack_bytesize)\
150 (__thread)->stack = (__stack_ptr); \
151 (__thread)->stack_size = (__stack_bytesize); \
152 __vsf_thread_set_stack_canery(__thread, __task)
153#endif
154
155#if VSF_KERNEL_THREAD_DYNAMIC_STACK == ENABLED
156# define __vsf_thread_def_stack(__name, __bytesize) \
157 typedef enum { \
158 vsf_thread##__name##_stack_bytesize = (__bytesize), \
159 };
160# define __vsf_thread_def_stack_member(__name, __bytesize)
161# define __vsf_thread_imp_stack(__name, __thread, __task) \
162 __vsf_thread_set_stack((__thread), (__task), NULL, (vsf_thread##__name##_stack_bytesize))
163# define __vsf_eda_call_thread_prepare_stack(__name, __thread) \
164 .stack = NULL, \
165 .stack_size = (vsf_thread##__name##_stack_bytesize),
166#else
167# define __vsf_thread_def_stack(__name, __bytesize)
168# define __vsf_thread_def_stack_member(__name, __bytesize) \
169 uint32_t canary; \
170 uint64_t stack_arr[(__VSF_THREAD_STACK_SAFE_SIZE(__bytesize) + 7) / 8]\
171 VSF_CAL_ALIGN(1 << VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT);
172# define __vsf_thread_imp_stack(__name, __thread, __task) \
173 __vsf_thread_set_stack((__thread), (__task), (__task)->stack_arr, sizeof((__task)->stack_arr))
174# define __vsf_eda_call_thread_prepare_stack(__name, __thread) \
175 .stack = (__thread)->stack_arr, \
176 .stack_size = sizeof((__thread)->stack_arr),
177#endif
178
179#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
180# define __def_vsf_thread(__name, __stack_bytesize, ...) \
181 __vsf_thread_def_stack(__name, (__stack_bytesize)) \
182 struct thread_cb_##__name##_t { \
183 implement(vsf_thread_cb_t) \
184 __VA_ARGS__ \
185 __vsf_thread_def_stack_member(__name, (__stack_bytesize)) \
186 }; \
187 struct __name { \
188 implement(vsf_thread_t) \
189 implement_ex(thread_cb_##__name##_t, param) \
190 } VSF_CAL_ALIGN(8); \
191 extern void vsf_thread_##__name##_start(struct __name *task, \
192 vsf_prio_t priority); \
193 extern void vsf_thread_##__name##_entry( \
194 struct thread_cb_##__name##_t *vsf_pthis);
195
196# define __implement_vsf_thread(__name) \
197 void vsf_thread_##__name##_entry( \
198 struct thread_cb_##__name##_t *vsf_pthis); \
199 void vsf_thread_##__name##_start( struct __name *task, \
200 vsf_prio_t priority) \
201 { \
202 VSF_KERNEL_ASSERT(NULL != task); \
203 thread_cb_##__name##_t *__vsf_pthis = &(task->param); \
204 __vsf_pthis->use_as__vsf_thread_cb_t.entry = (vsf_thread_entry_t *)\
205 &vsf_thread_##__name##_entry; \
206 __vsf_thread_imp_stack(__name, __vsf_pthis, task) \
207 vsf_thread_start( &(task->use_as__vsf_thread_t), \
208 &(__vsf_pthis->use_as__vsf_thread_cb_t), \
209 priority); \
210 } \
211 void vsf_thread_##__name##_entry( \
212 struct thread_cb_##__name##_t *vsf_pthis)
213
214# define __vsf_eda_call_thread_prepare(__name, __thread_cb) \
215 do { \
216 thread_cb_##__name##_t *__vsf_pthis = (__thread_cb); \
217 const vsf_thread_prepare_cfg_t cfg = { \
218 .entry = (vsf_thread_entry_t *) \
219 &vsf_thread_##__name##_entry, \
220 __vsf_eda_call_thread_prepare_stack(__name, (__thread_cb)) \
221 }; \
222 vk_eda_call_thread_prepare(&(__vsf_pthis->use_as__vsf_thread_cb_t),\
223 (vsf_thread_prepare_cfg_t *)&cfg);\
224 } while(0)
225
248# define vsf_eda_call_thread_prepare(__name, __thread_cb) \
249 __vsf_eda_call_thread_prepare(__name, __thread_cb)
250
269# define vsf_eda_call_thread(__thread_cb) \
270 vk_eda_call_thread(&((__thread_cb)->use_as__vsf_thread_cb_t))
271
272
273# define __def_vsf_thread_ex(__name, ...) \
274 struct thread_cb_##__name##_t { \
275 implement(vsf_thread_cb_t) \
276 __VA_ARGS__ \
277 }; \
278 struct __name { \
279 implement(vsf_thread_t) \
280 implement_ex(thread_cb_##__name##_t, param) \
281 }; \
282 extern void vsf_thread_##__name##_start( struct __name *task, \
283 vsf_prio_t priority, \
284 void *stack, \
285 uint_fast32_t size); \
286 extern void vsf_thread_##__name##_entry( \
287 struct thread_cb_##__name##_t *vsf_pthis);
288
289
290# define __implement_vsf_thread_ex(__name) \
291 void vsf_thread_##__name##_entry( \
292 struct thread_cb_##__name##_t *vsf_pthis); \
293 void vsf_thread_##__name##_start( struct __name *task, \
294 vsf_prio_t priority, \
295 void *stack, \
296 uint_fast32_t size) \
297 { \
298 VSF_KERNEL_ASSERT(NULL != task && 0 != size && NULL != stack); \
299 thread_cb_##__name##_t *__vsf_pthis = &(task->param); \
300 __vsf_pthis->use_as__vsf_thread_cb_t.entry = (vsf_thread_entry_t *)\
301 &vsf_thread_##__name##_entry; \
302 __vsf_pthis->use_as__vsf_thread_cb_t.stack = stack; \
303 __vsf_pthis->use_as__vsf_thread_cb_t.stack_size = size; \
304 vsf_thread_start( &(task->use_as__vsf_thread_t), \
305 &(task->param.use_as__vsf_thread_cb_t), \
306 priority); \
307 } \
308 void vsf_thread_##__name##_entry( \
309 struct thread_cb_##__name##_t *vsf_pthis)
310
311# define __vsf_eda_call_thread_prepare_ex__( __name, \
312 __thread_cb, \
313 __stack, \
314 __stack_bytesize) \
315 do { \
316 VSF_KERNEL_ASSERT((NULL != (__stack)) && (0 != (__size))) \
317 thread_cb_##__name##_t *__vsf_pthis = (__thread_cb); \
318 const vsf_thread_prepare_cfg_t cfg = { \
319 .entry = (vsf_thread_entry_t *) \
320 &vsf_thread_##__name##_entry, \
321 .stack = (__stack), \
322 .stack_size = (__stack_bytesize), \
323 }; \
324 vk_eda_call_thread_prepare(&(__vsf_pthis->use_as__vsf_thread_cb_t),\
325 (vsf_thread_prepare_cfg_t *)&cfg);\
326 } while(0)
327
328
356# define vsf_eda_call_thread_prepare_ex( __name, \
357 __thread_cb, \
358 __stack, \
359 __stack_bytesize) \
360 __vsf_eda_call_thread_prepare_ex__( __name, \
361 (__thread_cb), \
362 (__stack), \
363 (__stack_bytesize))
364
384# define vsf_eda_call_thread_ex(__thread_cb) \
385 vk_eda_call_thread(&((__thread_cb)->use_as__vsf_thread_cb_t))
386
387#else
388# define __def_vsf_thread(__name, __stack_bytesize, ...) \
389 struct thread_cb_##__name##_t { \
390 implement(vsf_thread_t) \
391 __VA_ARGS__ \
392 }; \
393 __vsf_thread_def_stack(__name, (__stack_bytesize)) \
394 struct __name { \
395 __vsf_thread_def_stack_member(__name, (__stack_bytesize)) \
396 implement_ex(thread_cb_##__name##_t, param); \
397 } VSF_CAL_ALIGN(8); \
398 extern void vsf_thread_##__name##_start(struct __name *task, \
399 vsf_prio_t priority); \
400 extern void vsf_thread_##__name##_entry( \
401 struct thread_cb_##__name##_t *vsf_pthis);
402
403# define __implement_vsf_thread(__name) \
404 void vsf_thread_##__name##_entry( \
405 struct thread_cb_##__name##_t *vsf_pthis); \
406 void vsf_thread_##__name##_start( struct __name *task, \
407 vsf_prio_t priority) \
408 { \
409 VSF_KERNEL_ASSERT(NULL != task); \
410 vsf_thread_t *__vsf_pthis = \
411 &(task->param.use_as__vsf_thread_t); \
412 __vsf_pthis->entry = (vsf_thread_entry_t *) \
413 &vsf_thread_##__name##_entry; \
414 __vsf_thread_imp_stack(__name, __vsf_pthis, task) \
415 vsf_thread_start(__vsf_pthis, priority); \
416 } \
417 void vsf_thread_##__name##_entry( \
418 struct thread_cb_##__name##_t *vsf_pthis)
419
420# define __def_vsf_thread_ex(__name, ...) \
421 struct thread_cb_##__name##_t { \
422 implement(vsf_thread_t) \
423 __VA_ARGS__ \
424 }; \
425 struct __name { \
426 implement_ex(thread_cb_##__name##_t, param); \
427 } VSF_CAL_ALIGN(8); \
428 extern void vsf_thread_##__name##_start(struct __name *task, \
429 vsf_prio_t priority); \
430 extern void vsf_thread_##__name##_entry( \
431 struct thread_cb_##__name##_t *vsf_pthis);
432
433
434# define __implement_vsf_thread_ex(__name) \
435 void vsf_thread_##__name##_entry( \
436 struct thread_cb_##__name##_t *vsf_pthis); \
437 void vsf_thread_##__name##_start( struct __name *task, \
438 vsf_prio_t priority, \
439 void *stack, \
440 uint_fast32_t size) \
441 { \
442 VSF_KERNEL_ASSERT(NULL != task && 0 != size && NULL != stack); \
443 vsf_thread_t *__vsf_pthis = \
444 &(task->param.use_as__vsf_thread_t); \
445 __vsf_pthis->entry = (vsf_thread_entry_t *) \
446 &vsf_thread_##__name##_entry; \
447 __vsf_pthis->stack = stack; \
448 __vsf_pthis->stack_size = size; \
449 vsf_thread_start(__vsf_pthis, priority); \
450 } \
451 void vsf_thread_##__name##_entry( \
452 struct thread_cb_##__name##_t *vsf_pthis)
453
454#endif
455
456
479#define def_vsf_thread(__name, __stack_bytesize, ...) \
480 __def_vsf_thread(__name, (__stack_bytesize), __VA_ARGS__)
481
494#define define_vsf_thread(__name, __stack_bytesize, ...) \
495 def_vsf_thread(__name, (__stack_bytesize), __VA_ARGS__)
496
517#define def_vsf_thread_ex(__name, ...) \
518 __def_vsf_thread_ex(__name, __VA_ARGS__)
519
530#define define_vsf_thread_ex(__name, ...) \
531 def_vsf_thread_ex(__name, __VA_ARGS__)
532
539#define end_def_vsf_thread(...)
546#define end_define_vsf_thread(...)
547
562#define implement_vsf_thread(__name) __implement_vsf_thread(__name)
577#define implement_vsf_thread_ex(__name) __implement_vsf_thread_ex(__name)
578
587#define imp_vsf_thread(__name) implement_vsf_thread(__name)
596#define imp_vsf_thread_ex(__name) implement_vsf_thread_ex(__name)
597
598#define __init_vsf_thread(__name, __task, __pri) \
599 vsf_thread_##__name##_start((__task), (__pri))
600
601#define __init_vsf_thread_ex(__name, __task, __pri, __stack, __stack_bytesize) \
602 vsf_thread_##__name##_start((__task), (__pri), (__stack), (__stack_bytesize))
603
624#define init_vsf_thread(__name, __task, __pri) \
625 __init_vsf_thread(__name, (__task), (__pri))
626
651#define init_vsf_thread_ex(__name, __task, __pri, __stack, __stack_bytesize) \
652 __init_vsf_thread_ex(__name, (__task), (__pri), (__stack), (__stack_bytesize))
653
654#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
655# define __vsf_thread(__name) thread_cb_##__name##_t
670# define vsf_thread(__name) __vsf_thread(__name)
671
672#endif
673
682#define vsf_thread_wfm vsf_thread_wait_for_msg
691#define vsf_thread_wfe vsf_thread_wait_for_evt
692
693#if VSF_KERNEL_CFG_SUPPORT_EVT_MESSAGE == ENABLED
706# define vsf_thread_wfem vsf_thread_wait_for_evt_msg
707#endif
708
709
710#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
711# define __vsf_thread_call_sub(__name, __target, ...) \
712 vk_thread_call_eda( (uintptr_t)(__name), \
713 (uintptr_t)(__target), \
714 (0, ##__VA_ARGS__), \
715 0, \
716 0)
717
718
740# define vsf_thread_call_sub(__name, __target, ...) \
741 __vsf_thread_call_sub(__name, (__target), (0, ##__VA_ARGS__))
742
743
766# define vsf_thread_call_pt(__name, __target, ...) \
767 (__target)->fsm_state = 0; \
768 vsf_thread_call_sub(vsf_pt_func(__name), (__target), (0, ##__VA_ARGS__))
769
770#endif
771
772#if VSF_KERNEL_CFG_EDA_SUPPORT_TASK == ENABLED && VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
795# define vsf_thread_call_task(__name, __target, ...) \
796 vk_thread_call_task(vsf_task_func(__name), __target, (0, ##__VA_ARGS__))
797#endif
798
799#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
816# define vsf_thread_delay_ms(__ms) vsf_thread_delay(vsf_systimer_ms_to_tick(__ms))
833# define vsf_thread_delay_us(__us) vsf_thread_delay(vsf_systimer_us_to_tick(__us))
834#endif
835
836#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
849# define vsf_thread_sem_post(__sem) vsf_eda_sem_post(__sem)
870# define vsf_thread_sem_pend(__sem, timeout) __vsf_thread_wait_for_sync(__sem, timeout)
871
886# define vsf_thread_trig_set(__trig, ...) vsf_eda_trig_set(__trig, ##__VA_ARGS__)
899# define vsf_thread_trig_reset(__trig) vsf_eda_trig_reset(__trig)
920# define vsf_thread_trig_pend(__trig, timeout) __vsf_thread_wait_for_sync(__trig, timeout)
921
943# define vsf_thread_mutex_enter(__mtx, timeout) __vsf_thread_wait_for_sync(&(__mtx)->use_as__vsf_sync_t, timeout)
944#endif
945
946/*============================ TYPES =========================================*/
947
948declare_class(vsf_thread_t)
949
950# if VSF_KERNEL_CFG_THREAD_SIGNAL == ENABLED
966typedef void vsf_thread_sighandler_t(vsf_thread_t *thread, int sig);
967# endif
968
969#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
970declare_class(vsf_thread_cb_t)
981typedef void vsf_thread_entry_t(vsf_thread_cb_t *thread);
982#else
993typedef void vsf_thread_entry_t(vsf_thread_t *thread);
994#endif
995
998
1011def_class(vsf_thread_cb_t,
1012
1013 public_member(
1016 vsf_thread_entry_t *entry;
1019#if VSF_KERNEL_CFG_THREAD_STACK_LARGE == ENABLED
1020 uint32_t stack_size;
1021#else
1022 uint16_t stack_size;
1023#endif
1026 uint64_t *stack;
1027 )
1028
1029 private_member(
1030#if VSF_KERNEL_THREAD_USE_HOST == ENABLED
1031 vsf_arch_irq_thread_t host_thread;
1032 vsf_arch_irq_request_t req, *rep;
1033 vsf_evt_t evt;
1034# if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1035 bool is_inited;
1036# endif
1037#else
1038 jmp_buf *pos;
1039 jmp_buf *ret;
1040#endif
1041 )
1042)
1043end_def_class(vsf_thread_cb_t)
1045
1046#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1047
1064def_class( vsf_thread_t,
1065 public_member(
1067 implement(vsf_teda_t)
1068#else
1069 implement(vsf_eda_t)
1070#endif
1072 vsf_thread_sighandler_t *sighandler;
1073#endif
1074 )
1075#if VSF_KERNEL_CFG_THREAD_SIGNAL == ENABLED && VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1076 private_member(
1077 // set sig_pending if current thread is in subcall,
1078 // sighandler will be called if sig_pending is set and subcall returns.
1080 )
1081#endif
1082)
1083end_def_class(vsf_thread_t)
1084
1085
1097typedef struct {
1100 vsf_thread_entry_t *entry;
1103 void *stack;
1106 uint_fast32_t stack_size;
1107 //vsf_prio_t priority; //!< TODO do we need this??
1108} vsf_thread_prepare_cfg_t;
1109
1110
1111#else
1112
1115
1131def_class(vsf_thread_t,
1132 public_member(
1134 implement(vsf_teda_t)
1135#else
1136 implement(vsf_eda_t)
1137#endif
1139 vsf_thread_sighandler_t *sighandler;
1140#endif
1141 implement(vsf_thread_cb_t)
1142 )
1143
1144#if VSF_KERNEL_CFG_THREAD_SIGNAL == ENABLED && VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1145 private_member(
1146 // set sig_pending if current thread is in subcall,
1147 // sighandler will be called if sig_pending is set and subcall returns.
1149 )
1150#endif
1151)
1152end_def_class(vsf_thread_t)
1154#endif
1155/*============================ GLOBAL VARIABLES ==============================*/
1156/*============================ PROTOTYPES ====================================*/
1157
1158#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1159VSF_CAL_SECTION(".text.vsf.kernel.vk_eda_call_thread_prepare")
1181extern vsf_err_t vk_eda_call_thread_prepare( vsf_thread_cb_t *thread_cb,
1182 vsf_thread_prepare_cfg_t *cfg);
1183
1184VSF_CAL_SECTION(".text.vsf.kernel.vk_eda_call_thread")
1199extern vsf_err_t vk_eda_call_thread(vsf_thread_cb_t *thread_cb);
1200
1201#if VSF_KERNEL_CFG_EDA_SUPPORT_TASK == ENABLED && VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
1202VSF_CAL_SECTION(".text.vsf.kernel.vk_thread_call_task")
1225extern
1226fsm_rt_t vk_thread_call_task(vsf_task_entry_t task_handler, uintptr_t param, size_t local_size);
1227#endif
1228
1229VSF_CAL_SECTION(".text.vsf.kernel.vk_thread_call_eda")
1250extern
1251vsf_err_t vk_thread_call_eda( uintptr_t eda_handler,
1252 uintptr_t param,
1253 size_t local_size,
1254 size_t local_buff_size,
1255 uintptr_t local_buff);
1256
1257VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_call_thread")
1275extern vsf_err_t vk_thread_call_thread( vsf_thread_cb_t *thread_cb,
1276 vsf_thread_prepare_cfg_t *cfg);
1277
1278#endif
1279
1280
1281VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread")
1282#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1306extern vsf_err_t vsf_thread_start( vsf_thread_t *thread,
1307 vsf_thread_cb_t *thread_cb,
1308 vsf_prio_t priority);
1309#else
1316extern vsf_err_t vsf_thread_start(vsf_thread_t *this_ptr, vsf_prio_t priority);
1317#endif
1318
1319#if VSF_KERNEL_CFG_THREAD_STACK_CHECK == ENABLED
1320VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_stack_check")
1338extern void vsf_thread_stack_check(void);
1339#endif
1340
1341VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_exit")
1357extern VSF_CAL_NO_RETURN void vsf_thread_exit(void);
1358
1359VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_get_cur")
1372extern vsf_thread_t *vsf_thread_get_cur(void);
1373
1374VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_wait")
1387extern vsf_evt_t vsf_thread_wait(void);
1388
1389VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_wait_for_evt")
1408extern void vsf_thread_wait_for_evt(vsf_evt_t evt);
1409
1410VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_sendevt")
1425extern void vsf_thread_sendevt(vsf_thread_t *thread, vsf_evt_t evt);
1426
1427#if VSF_KERNEL_CFG_SUPPORT_EVT_MESSAGE == ENABLED
1428VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_wait_for_evt_msg")
1445extern uintptr_t vsf_thread_wait_for_evt_msg(vsf_evt_t evt);
1446#endif
1447
1448VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_wait_for_evt_msg")
1463extern uintptr_t vsf_thread_wait_for_msg(void);
1464
1465#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1466VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_delay")
1483extern void vsf_thread_delay(vsf_systimer_tick_t tick);
1484#endif
1485
1486VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_yield")
1501void vsf_thread_yield(void);
1502
1503#if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
1504VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_set_priority")
1524extern vsf_prio_t vsf_thread_set_priority(vsf_prio_t priority);
1525#endif
1526
1527#if VSF_KERNEL_CFG_THREAD_SIGNAL == ENABLED
1528VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_signal")
1554extern void vsf_thread_signal(vsf_thread_t *thread, int sig);
1555#endif
1556
1557#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1558VSF_CAL_SECTION(".text.vsf.kernel.__vsf_thread_wait_for_sync")
1582vsf_sync_reason_t __vsf_thread_wait_for_sync(vsf_sync_t *sync, vsf_timeout_tick_t time_out);
1583
1584VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_mutex")
1597extern vsf_err_t vsf_thread_mutex_leave(vsf_mutex_t *mtx);
1598
1599VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_queue")
1622vsf_sync_reason_t vsf_thread_queue_send(vsf_eda_queue_t *queue, void *node, vsf_timeout_tick_t timeout);
1623
1624VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_queue")
1647vsf_sync_reason_t vsf_thread_queue_recv(vsf_eda_queue_t *queue, void **node, vsf_timeout_tick_t timeout);
1648
1649# if VSF_KERNEL_CFG_SUPPORT_BITMAP_EVENT == ENABLED
1650VSF_CAL_SECTION(".text.vsf.kernel.vsf_thread_bmpevt_pend")
1676extern vsf_sync_reason_t vsf_thread_bmpevt_pend(
1677 vsf_bmpevt_t *bmpevt,
1678 vsf_bmpevt_pender_t *pender,
1680# endif
1681#endif
1682
1683#ifdef __cplusplus
1684}
1685#endif
1686
1687#endif
1688#endif
#define VSF_CAL_SECTION(__SEC_STR)
Definition __compiler.h:189
#define ENABLED
Definition __type.h:28
vsf_err_t
Definition __type.h:42
Definition linux_generic.h:99
Definition linux_generic.h:117
Wait condition of a bitmap-event wait.
Definition vsf_eda.h:2104
Bitmap-event group.
Definition vsf_eda.h:2129
OS-aware queue; send pends while full, recv pends while empty; backend ops are supplied by the user (...
Definition vsf_eda.h:2193
The event-driven task (TCB); every VSF task is an eda at the bottom. Tasks share stacks and only occu...
Definition vsf_eda.h:1838
Sync object with an owner (mutex base); supports priority inheritance; the owner must leave it itself...
Definition vsf_eda.h:2009
Base sync IPC object; sem/mutex/trig/crit are built on it.
Definition vsf_eda.h:1964
eda with timer support (can use vsf_teda_set_timer() etc.); derived classes (task/pt/thread) inherit ...
Definition vsf_eda.h:1916
uint64_t vsf_systimer_tick_t
Definition cortex_a_generic.h:70
bool is_inited
Definition driver_gptimer_port.c:88
__le16 timeout
Definition ieee80211.h:94
uint32_t uintptr_t
Definition stdint.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
unsigned long long uint64_t
Definition stdint.h:11
void sync(void)
Definition vsf_linux_fs.c:2266
int16_t vsf_evt_t
Kernel event type.
Definition vsf_eda.h:1658
VSF_KERNEL_TIMEOUT_TICK_T vsf_timeout_tick_t
Timeout type in system timer ticks: negative means wait forever, 0 means non-blocking try,...
Definition vsf_eda.h:1491
vsf_sync_reason_t
Result of a sync wait, returned by the *_get_reason() APIs and thread IPC.
Definition vsf_eda.h:2262
fsm_rt_t
Definition vsf_fsm.h:771
#define VSF_KERNEL_CFG_THREAD_SIGNAL
Definition vsf_kernel_cfg.h:151
#define VSF_KERNEL_CFG_EDA_SUPPORT_TIMER
Definition vsf_kernel_cfg.h:78
#define VSF_KERNEL_CFG_THREAD_SIGNAL_MASK_T
Definition vsf_kernel_cfg.h:155
vsf_prio_t
Kernel priority enumeration.
Definition vsf_kernel_common.h:55
def_class(vsf_stream_fifo_t, public:vsf_stream_tx_t TX;vsf_stream_rx_t RX;private:vsf_slist_queue_t union { vsf_stream_fifo_cfg_t cfg;struct { vsf_stream_dat_rdy_evt_t tDataReadyEventHandling;vsf_stream_dat_drn_evt_t tDataDrainEventHandling;vsf_stream_status_t Status;#if !defined(VSF_PBUF_QUEUE_CFG_ATOM_ACCESS) vsf_protect_region_t *pregion;#endif };};) end_def_class(vsf_stream_fifo_t) extern vsf_err_t vsf_stream_fifo_init(vsf_stream_fifo_t *obj_ptr
fsm_rt_t(* vsf_task_entry_t)(uintptr_t target, vsf_evt_t evt)
Task entry function (the event handler of the task), returning fsm_rt_t when VSF_KERNEL_CFG_EDA_SUBCA...
Definition vsf_task.h:632
vsf_err_t vsf_thread_start(vsf_thread_t *pthis, vsf_thread_cb_t *thread_cb, vsf_prio_t priority)
Start a thread.
Definition vsf_thread.c:484
int sig
Definition vsf_thread.h:966
declare_class(vsf_thread_t) typedef void vsf_thread_sighandler_t(vsf_thread_t *thread
POSIX-like thread signal handler, invoked when a signal is delivered to the thread.
Generated from commit: vsfteam/vsf@a5104db