VSF Documented
vsf_eda.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_EDA_H__
19#define __VSF_EDA_H__
20
21/*============================ INCLUDES ======================================*/
22
24
25#if VSF_USE_KERNEL == ENABLED
26#include "hal/arch/vsf_arch.h"
27#include "service/vsf_service.h"
28
29// for vsf_prio_t
30#include "./vsf_kernel_common.h"
31
37#if defined(__VSF_EDA_CLASS_IMPLEMENT)
38# define __VSF_CLASS_IMPLEMENT__
39#elif defined(__VSF_EDA_CLASS_INHERIT__)
40# define __VSF_CLASS_INHERIT__
41#endif
42
43#include "utilities/ooc_class.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/*============================ MACROS ========================================*/
50
51#define VSF_SYNC_AUTO_RST 0x0000
52#define VSF_SYNC_MANUAL_RST 0x8000
53#define VSF_SYNC_HAS_OWNER 0x8000
54
55#define VSF_SYNC_MAX 0x7FFF
56
57#ifndef VSF_KERNEL_CFG_EDA_USER_BITLEN
58# define VSF_KERNEL_CFG_EDA_USER_BITLEN 5
59#endif
60
61/*============================ MACROFIED FUNCTIONS ===========================*/
62
63// SEMAPHORE
64#define __vsf_eda_sem_init2(__psem, __init_cnt, __max_cnt) \
65 vsf_eda_sync_init((__psem), (__init_cnt), (__max_cnt) | VSF_SYNC_AUTO_RST)
66#define __vsf_eda_sem_init1(__psem, __init_cnt) \
67 __vsf_eda_sem_init2((__psem), (__init_cnt), VSF_SYNC_MAX)
68#define __vsf_eda_sem_init0(__psem) \
69 __vsf_eda_sem_init1((__psem), 0)
70// prototype: vsf_err_t vsf_eda_sem_init(vsf_sem_t *sem, uint_fast16_t init_cnt = 0, uint_fast16_t max_cnt = VSF_SYNC_MAX);
71#define vsf_eda_sem_init(__psem, ...) \
72 __PLOOC_EVAL(__vsf_eda_sem_init, __VA_ARGS__)((__psem), ##__VA_ARGS__)
73
74#define vsf_eda_sem_post(__psem) vsf_eda_sync_increase((__psem))
75
76#define __vsf_eda_sem_pend1(__psem, __timeout) vsf_eda_sync_decrease((__psem), (__timeout))
77#define __vsf_eda_sem_pend0(__psem) __vsf_eda_sem_pend1((__psem), -1)
78// prototype: vsf_err_t vsf_eda_sem_pend(vsf_sem_t *sem, vsf_timeout_tick_t timeout = -1);
79#define vsf_eda_sem_pend(__psem, ...) \
80 __PLOOC_EVAL(__vsf_eda_sem_pend, __VA_ARGS__)((__psem), ##__VA_ARGS__)
81
82#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
83# define vsf_eda_sem_post_isr(__psem) vsf_eda_sync_increase_isr((__psem))
84#endif
85
86// MUTEX
87#define vsf_eda_mutex_init(__pmtx) \
88 vsf_eda_sync_init( &((__pmtx)->use_as__vsf_sync_t), \
89 1 | VSF_SYNC_HAS_OWNER, \
90 1 | VSF_SYNC_AUTO_RST)
91
92#define __vsf_eda_mutex_enter1(__pmtx, __timeout) \
93 vsf_eda_sync_decrease(&((__pmtx)->use_as__vsf_sync_t), (__timeout))
94#define __vsf_eda_mutex_enter0(__pmtx) __vsf_eda_mutex_enter1((__pmtx), -1)
95// prototype: vsf_err_t vsf_eda_mutex_enter(vsf_mutex_t *mutex, vsf_timeout_tick_t timeout = -1);
96#define vsf_eda_mutex_enter(__pmtx, ...) \
97 __PLOOC_EVAL(__vsf_eda_mutex_enter, __VA_ARGS__)((__pmtx), ##__VA_ARGS__)
98
99#define vsf_eda_mutex_leave(__pmtx) \
100 vsf_eda_sync_increase(&((__pmtx)->use_as__vsf_sync_t))
101#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
102# define vsf_eda_mutex_leave_isr(__pmtx) vsf_eda_sync_increase_isr(&(__pmtx)->use_as__vsf_sync_t)
103#endif
104
105// CRIT
106#define vsf_eda_crit_init(__pcrit) \
107 vsf_eda_mutex_init((__pcrit))
108
109#define __vsf_eda_crit_enter1(__pcrit, __timeout) \
110 vsf_eda_mutex_enter((__pcrit), (__timeout))
111#define __vsf_eda_crit_enter0(__pcrit) __vsf_eda_crit_enter1((__pcrit), -1)
112// prototype: vsf_err_t vsf_eda_crit_enter(vsf_crit_t *crit, vsf_timeout_tick_t timeout = -1);
113#define vsf_eda_crit_enter(__pcrit, ...) \
114 __PLOOC_EVAL(__vsf_eda_crit_enter, __VA_ARGS__)((__pcrit), ##__VA_ARGS__)
115
116#define vsf_eda_crit_leave(__pcrit) \
117 vsf_eda_mutex_leave((__pcrit))
118
119// EVENT
120#define vsf_eda_trig_init(__pevt, __set, __auto_rst) \
121 vsf_eda_sync_init((__pevt), (__set), \
122 1 | ((__auto_rst) ? VSF_SYNC_AUTO_RST : VSF_SYNC_MANUAL_RST))
123
124#define vsf_eda_trig_set0(__pevt) vsf_eda_sync_increase((__pevt))
125#define vsf_eda_trig_set1(__pevt, __manual) \
126 __vsf_eda_sync_increase_ex((__pevt), NULL, (__manual))
127// prototype: vsf_err_t vsf_eda_trig_set(vsf_trig_t *trig, bool manual);
128// prototype: vsf_err_t vsf_eda_trig_set(vsf_trig_t *trig);
129#define vsf_eda_trig_set(__pevt, ...) \
130 __PLOOC_EVAL(vsf_eda_trig_set, __VA_ARGS__)((__pevt), ##__VA_ARGS__)
131
132#define vsf_eda_trig_reset(__pevt) vsf_eda_sync_force_reset((__pevt))
133
134#define __vsf_eda_trig_wait1(__pevt, __timeout) \
135 vsf_eda_sync_decrease((__pevt), (__timeout))
136#define __vsf_eda_trig_wait0(__pevt) __vsf_eda_trig_wait1((__pevt), -1)
137#define vsf_eda_trig_wait(__pevt, ...) \
138 __PLOOC_EVAL(__vsf_eda_trig_wait, __VA_ARGS__)((__pevt), ##__VA_ARGS__)
139
140#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
141# define vsf_eda_trig_set_isr(__pevt) vsf_eda_sync_increase_isr((__pevt))
142#endif
143
144// CRIT without priority boost, internal use only
145// only used for edas with same priority
146#define __vsf_eda_crit_npb_init(__pcrit) \
147 vsf_eda_sync_init((__pcrit), 1, 1 | VSF_SYNC_AUTO_RST)
148
149#define __vsf_eda_crit_npb_enter1(__pcrit, __timeout) \
150 vsf_eda_sync_decrease((__pcrit), (__timeout))
151#define __vsf_eda_crit_npb_enter0(__pcrit) __vsf_eda_crit_npb_enter1((__pcrit), -1)
152// prototype: vsf_err_t __vsf_eda_crit_npb_enter(__vsf_crit_npb_t *crit_npb, vsf_timeout_tick_t timeout = -1);
153#define __vsf_eda_crit_npb_enter(__pcrit, ...) \
154 __PLOOC_EVAL(__vsf_eda_crit_npb_enter, __VA_ARGS__)((__pcrit), ##__VA_ARGS__)
155
156#define __vsf_eda_crit_npb_leave(__pcrit) \
157 vsf_eda_sync_increase((__pcrit))
158
159#define __vsf_eda_init2(__eda, __priority, __feature) \
160 __vsf_eda_init((__eda), (__priority), (__feature))
161#define __vsf_eda_init1(__eda, __priority) \
162 __vsf_eda_init2((__eda), (__priority), (vsf_eda_feature_t){.value = 0})
163#define __vsf_eda_init0(__eda) \
164 __vsf_eda_init1((__eda), vsf_prio_inherit)
165// prototype: vsf_err_t vsf_eda_init(vsf_eda_t *eda, vsf_prio_t prio = vsf_prio_inherit, vsf_eda_feature feature = 0);
166#define vsf_eda_init(__eda, ...) \
167 __PLOOC_EVAL(__vsf_eda_init, __VA_ARGS__)((__eda), ##__VA_ARGS__)
168
169#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
170# define vsf_teda_init(__teda, ...) vsf_eda_init(&(__teda)->use_as__vsf_eda_t, ##__VA_ARGS__)
171#endif
172
173#define vsf_eda_return(...) __vsf_eda_return((uintptr_t)(0, ##__VA_ARGS__))
174
175#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
176# define vsf_systimer_get_ms() vsf_systimer_tick_to_ms(vsf_systimer_get_tick())
177# define vsf_systimer_get_us() vsf_systimer_tick_to_us(vsf_systimer_get_tick())
178#endif
179
180#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
181# define vsf_eda_call_eda(__evthandler, ...) \
182 __vsf_eda_call_eda((uintptr_t)__evthandler, NULL, (0, ##__VA_ARGS))
183# define vsf_eda_call_param_eda(__param_evthandler, __param, ...) \
184 __vsf_eda_call_eda( (uintptr_t)__param_evthandler, \
185 (uintptr_t)__param, \
186 (0, ##__VA_ARGS__))
187
188# define vsf_eda_get_local(...) \
189 __vsf_eda_get_local((vsf_eda_t *)(vsf_eda_get_cur(), ##__VA_ARGS__))
190
191# define __vsf_peda_local(__name) peda_local_##__name
192# define vsf_peda_local(__name) __vsf_peda_local(__name)
193
194# define __vsf_peda_arg(__name) peda_arg_##__name
195# define vsf_peda_arg(__name) __vsf_peda_arg(__name)
196
197# define __vsf_peda_func(__name) vsf_peda_func_##__name
198# define vsf_peda_func(__name) __vsf_peda_func(__name)
199
200
201# define __vsf_peda_param(__name) peda_cb_##__name
202# define vsf_peda_param(__name) __vsf_peda_param(__name)
203
204
205# define __declare_vsf_peda_ctx(__name) \
206 typedef struct vsf_peda_param(__name) vsf_peda_param(__name); \
207 typedef struct vsf_peda_arg(__name) vsf_peda_arg(__name); \
208 typedef struct vsf_peda_local(__name) vsf_peda_local(__name);
209# define declare_vsf_peda_ctx(__name) __declare_vsf_peda_ctx(__name)
210
211# define dcl_vsf_peda_ctx(__name) \
212 declare_vsf_peda_ctx(__name)
213
214# define __declare_vsf_peda(__name) \
215 typedef struct __name __name; \
216 __declare_vsf_peda_ctx(__name)
217# define declare_vsf_peda(__name) __declare_vsf_peda(__name)
218
219# define dcl_vsf_peda(__name) \
220 declare_vsf_peda(__name)
221
222# define declare_vsf_peda_methods1(__decoration, __name) \
223 declare_vsf_peda_ctx(__name) \
224 __decoration \
225 void vsf_peda_func(__name)( \
226 struct vsf_peda_local(__name) *vsf_pthis,\
227 vsf_evt_t evt);
228
229# define declare_vsf_peda_methods2(__decoration, __name, __func1) \
230 declare_vsf_peda_ctx(__name) \
231 __decoration \
232 void vsf_peda_func(__name)( \
233 struct vsf_peda_local(__name) *vsf_pthis,\
234 vsf_evt_t evt); \
235 __decoration \
236 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
237 vsf_evt_t evt);
238
239# define declare_vsf_peda_methods3(__decoration, __name, __func1, __func2) \
240 declare_vsf_peda_ctx(__name) \
241 __decoration \
242 void vsf_peda_func(__name)( \
243 struct vsf_peda_local(__name) *vsf_pthis,\
244 vsf_evt_t evt); \
245 __decoration \
246 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
247 vsf_evt_t evt); \
248 __decoration \
249 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
250 vsf_evt_t evt);
251
252# define declare_vsf_peda_methods4(__name, __func1, __func2, __func3) \
253 declare_vsf_peda_ctx(__name) \
254 __decoration \
255 void vsf_peda_func(__name)( \
256 struct vsf_peda_local(__name) *vsf_pthis,\
257 vsf_evt_t evt); \
258 __decoration \
259 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
260 vsf_evt_t evt); \
261 __decoration \
262 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
263 vsf_evt_t evt); \
264 __decoration \
265 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
266 vsf_evt_t evt);
267
268# define declare_vsf_peda_methods5( __decoration, __name, __func1, __func2, \
269 __func3, __func4) \
270 declare_vsf_peda_ctx(__name) \
271 __decoration \
272 void vsf_peda_func(__name)( \
273 struct vsf_peda_local(__name) *vsf_pthis,\
274 vsf_evt_t evt); \
275 __decoration \
276 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
277 vsf_evt_t evt); \
278 __decoration \
279 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
280 vsf_evt_t evt); \
281 __decoration \
282 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
283 vsf_evt_t evt); \
284 __decoration \
285 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
286 vsf_evt_t evt);
287
288
289# define declare_vsf_peda_methods6( __decoration, __name, __func1, __func2, \
290 __func3, __func4, __func5) \
291 declare_vsf_peda_ctx(__name) \
292 __decoration \
293 void vsf_peda_func(__name)( \
294 struct vsf_peda_local(__name) *vsf_pthis,\
295 vsf_evt_t evt); \
296 __decoration \
297 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
298 vsf_evt_t evt); \
299 __decoration \
300 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
301 vsf_evt_t evt); \
302 __decoration \
303 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
304 vsf_evt_t evt); \
305 __decoration \
306 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
307 vsf_evt_t evt); \
308 __decoration \
309 void __func5( struct vsf_peda_local(__name) *vsf_pthis,\
310 vsf_evt_t evt);
311
312# define declare_vsf_peda_methods7( __decoration, __name, __func1, __func2, \
313 __func3, __func4, __func5, __func6) \
314 declare_vsf_peda_ctx(__name) \
315 __decoration \
316 void vsf_peda_func(__name)( \
317 struct vsf_peda_local(__name) *vsf_pthis,\
318 vsf_evt_t evt); \
319 __decoration \
320 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
321 vsf_evt_t evt); \
322 __decoration \
323 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
324 vsf_evt_t evt); \
325 __decoration \
326 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
327 vsf_evt_t evt); \
328 __decoration \
329 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
330 vsf_evt_t evt); \
331 __decoration \
332 void __func5( struct vsf_peda_local(__name) *vsf_pthis,\
333 vsf_evt_t evt); \
334 __decoration \
335 void __func6( struct vsf_peda_local(__name) *vsf_pthis,\
336 vsf_evt_t evt);
337
338# define declare_vsf_peda_methods8( __decoration, __name, __func1, __func2, \
339 __func3, __func4, __func5, __func6, \
340 __func7) \
341 declare_vsf_peda_ctx(__name) \
342 __decoration \
343 void vsf_peda_func(__name)( \
344 struct vsf_peda_local(__name) *vsf_pthis,\
345 vsf_evt_t evt); \
346 __decoration \
347 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
348 vsf_evt_t evt); \
349 __decoration \
350 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
351 vsf_evt_t evt); \
352 __decoration \
353 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
354 vsf_evt_t evt); \
355 __decoration \
356 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
357 vsf_evt_t evt); \
358 __decoration \
359 void __func5( struct vsf_peda_local(__name) *vsf_pthis,\
360 vsf_evt_t evt); \
361 __decoration \
362 void __func6( struct vsf_peda_local(__name) *vsf_pthis,\
363 vsf_evt_t evt); \
364 __decoration \
365 void __func7( struct vsf_peda_local(__name) *vsf_pthis,\
366 vsf_evt_t evt);
367
368#define declare_vsf_peda_methods(__decoration, ...) \
369 __PLOOC_EVAL(declare_vsf_peda_methods, __VA_ARGS__) \
370 (__decoration, __VA_ARGS__)
371
372#define dcl_vsf_peda_methods(__decoration, ...) \
373 declare_vsf_peda_methods(__decoration, __VA_ARGS__)
374
375# if __IS_COMPILER_IAR__
376# define __def_vsf_peda_ctx4(__name, __param, __arg, __local) \
377 struct vsf_peda_param(__name) { \
378 __param \
379 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
380 }; \
381 struct vsf_peda_arg(__name) { \
382 __arg \
383 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
384 }; \
385 struct vsf_peda_local(__name) { \
386 implement(vsf_peda_arg(__name)) \
387 __local \
388 };
389# else
390# define __def_vsf_peda_ctx4(__name, __param, __arg, __local) \
391 struct vsf_peda_param(__name) { \
392 __param \
393 }; \
394 struct vsf_peda_arg(__name) { \
395 __arg \
396 }; \
397 struct vsf_peda_local(__name) { \
398 implement(vsf_peda_arg(__name)) \
399 __local \
400 };
401#endif
402
403# define __def_vsf_peda4(__name, __param, __arg, __local) \
404 __def_vsf_peda_ctx4(__name, __param, __arg, __local) \
405 struct __name { \
406 implement(vsf_peda_t) \
407 implement_ex(vsf_peda_param(__name), param) \
408 };
409
410# if __IS_COMPILER_IAR__
411# define __def_vsf_peda_ctx3(__name, __param, __arg) \
412 struct vsf_peda_param(__name) { \
413 __param \
414 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
415 }; \
416 struct vsf_peda_arg(__name) { \
417 __arg \
418 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
419 }; \
420 struct vsf_peda_local(__name) { \
421 implement(vsf_peda_arg(__name)) \
422 };
423# else
424# define __def_vsf_peda_ctx3(__name, __param, __arg) \
425 struct vsf_peda_param(__name) { \
426 __param \
427 }; \
428 struct vsf_peda_arg(__name) { \
429 __arg \
430 }; \
431 struct vsf_peda_local(__name) { \
432 implement(vsf_peda_arg(__name)) \
433 };
434#endif
435
436# define __def_vsf_peda3(__name, __param, __arg) \
437 __def_vsf_peda_ctx3(__name, __param, __arg) \
438 struct __name { \
439 implement(vsf_peda_t) \
440 implement_ex(vsf_peda_param(__name), param) \
441 };
442
443
444# if __IS_COMPILER_IAR__
445# define __def_vsf_peda_ctx2(__name, __param) \
446 struct vsf_peda_param(__name) { \
447 __param \
448 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
449 }; \
450 struct vsf_peda_arg(__name) { \
451 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
452 }; \
453 struct vsf_peda_local(__name) { \
454 implement(vsf_peda_arg(__name)) \
455 };
456# else
457# define __def_vsf_peda_ctx2(__name, __param) \
458 struct vsf_peda_param(__name) { \
459 __param \
460 }; \
461 struct vsf_peda_arg(__name) { \
462 }; \
463 struct vsf_peda_local(__name) { \
464 implement(vsf_peda_arg(__name)) \
465 };
466#endif
467
468# define __def_vsf_peda_ctx1(__name) \
469 __def_vsf_peda_ctx2(__name, )
470
471# define __def_vsf_peda2(__name, __param) \
472 __def_vsf_peda_ctx2(__name, __param) \
473 struct __name { \
474 implement(vsf_peda_t) \
475 implement_ex(vsf_peda_param(__name), param) \
476 };
477
478# define __def_vsf_peda1(__name) \
479 __def_vsf_peda_ctx1(__name) \
480 struct __name { \
481 implement(vsf_peda_t) \
482 implement_ex(vsf_peda_param(__name), param) \
483 };
484
485# define def_vsf_peda(...) \
486 __PLOOC_EVAL(__def_vsf_peda, __VA_ARGS__) (__VA_ARGS__)
487
488# define end_def_vsf_peda(...)
489
490# define def_vsf_peda_ctx(...) \
491 __PLOOC_EVAL(__def_vsf_peda_ctx, __VA_ARGS__)(__VA_ARGS__)
492
493# define end_def_vsf_peda_ctx(...)
494
495# define define_vsf_peda_ctx(__name, ...) \
496 def_vsf_peda_ctx(__name, __VA_ARGS__)
497
498# define end_define_vsf_peda_ctx(...)
499
500# define def_locals(...) ,##__VA_ARGS__
501# define end_def_locals(...)
502
503# define define_locals(...) ,##__VA_ARGS__
504# define end_define_locals(...)
505
506# define def_args(...) ,__VA_ARGS__
507# define end_def_args(...)
508
509# define define_args(...) ,__VA_ARGS__
510# define end_define_args(...)
511
512# define define_arguments(...) ,__VA_ARGS__
513# define end_define_arguments(...)
514
515# define define_parameters(...) __VA_ARGS__
516# define end_define_parameters(...)
517
518#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
519# define vsf_peda_start vsf_teda_start
520#else
521# define vsf_peda_start vsf_eda_start
522#endif
523
524# define __init_vsf_peda(__name, __param_eda, __pri, ...) \
525 do { \
526 vsf_eda_cfg_t VSF_MACRO_SAFE_NAME(cfg) = { \
527 .fn.param_evthandler = \
528 (vsf_param_eda_evthandler_t)vsf_peda_func(__name), \
529 .priority = (__pri), \
530 .target = (uintptr_t)&((__param_eda)->param), \
531 .local_size = sizeof(vsf_peda_local(__name)), \
532 __VA_ARGS__ \
533 }; \
534 vsf_peda_start((vsf_peda_t *)(__param_eda), \
535 &VSF_MACRO_SAFE_NAME(cfg)); \
536 } while(0)
537
538# define init_vsf_peda(__name, __param_eda, __pri, ...) \
539 __init_vsf_peda(__name, (__param_eda), (__pri), __VA_ARGS__)
540
541
542# define __implement_vsf_peda2(__name, __func_name) \
543 void __func_name( struct vsf_peda_local(__name) *vsf_plocal, \
544 vsf_evt_t evt) \
545 { \
546 vsf_peda_param(__name) *vsf_pthis = \
547 *(vsf_peda_param(__name) **) \
548 ((uintptr_t)vsf_plocal - sizeof(uintptr_t)); \
549 VSF_UNUSED_PARAM(vsf_pthis); \
550 VSF_KERNEL_ASSERT(NULL != vsf_pthis || NULL != vsf_plocal);
551
552# define __implement_vsf_peda1(__name) \
553 void vsf_peda_func(__name)( struct vsf_peda_local(__name) *vsf_plocal, \
554 vsf_evt_t evt) \
555 { \
556 vsf_peda_param(__name) *vsf_pthis = \
557 *(vsf_peda_param(__name) **) \
558 ((uintptr_t)vsf_plocal - sizeof(uintptr_t)); \
559 VSF_UNUSED_PARAM(vsf_pthis); \
560 VSF_KERNEL_ASSERT(NULL != vsf_pthis || NULL != vsf_plocal);
561
562# define vsf_peda_begin()
563
564# define vsf_peda_end() \
565 }
566
567# define implement_vsf_peda(...) \
568 __PLOOC_EVAL(__implement_vsf_peda, __VA_ARGS__)(__VA_ARGS__)
569
570# define imp_vsf_peda(...) \
571 implement_vsf_peda(__VA_ARGS__)
572
573# define vsf_eda_call_peda(__name, __param) \
574 vsf_eda_call_param_eda( vsf_peda_func(__name), \
575 (__param), \
576 sizeof(vsf_peda_local(__name)))
577
578# define vsf_local (*vsf_plocal)
579
580#endif
581# define vsf_this (*vsf_pthis)
582
583// backward compatibility, do not use in new design
584#define vsf_eda_mutex_try_enter vsf_eda_mutex_enter
585#define vsf_eda_crit_try_enter vsf_eda_crit_enter
586
587/*============================ TYPES =========================================*/
588
589#ifndef VSF_KERNEL_TIMEOUT_TICK_T
590# define VSF_KERNEL_TIMEOUT_TICK_T int_fast64_t
591#endif
593
594enum {
599#if VSF_KERNEL_CFG_SUPPORT_THREAD == ENABLED && VSF_KERNEL_CFG_THREAD_SIGNAL == ENABLED
601#endif
602
610
611 // events for time
613
614 // events for sync
618
619 // events for message
622};
623
624// events for kernel task
625enum {
630};
631
632#if VSF_KERNEL_CFG_CPU_USAGE == ENABLED || VSF_KERNEL_CFG_EDA_CPU_USAGE == ENABLED
633typedef struct vsf_cpu_usage_ctx_t {
637typedef struct vsf_cpu_usage_t {
641#endif
642
653
655
656typedef void (*vsf_eda_evthandler_t)(vsf_eda_t *eda, vsf_evt_t evt);
657typedef void (*vsf_eda_on_terminate_t)(vsf_eda_t *eda);
658typedef void (*vsf_param_eda_evthandler_t)(uintptr_t target, vsf_evt_t evt);
659
660#if VSF_KERNEL_CFG_EDA_USER_BITLEN <= 8 - 3
663#elif VSF_KERNEL_CFG_EDA_USER_BITLEN <= 16 - 3
666#elif VSF_KERNEL_CFG_EDA_USER_BITLEN <= 32 - 3
669#else
670# error VSF_KERNEL_CFG_EDA_USER_BITLEN not supported yet
671#endif
672
673typedef union vsf_eda_feature_t {
674 struct {
675#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
685#endif
686#if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
688#endif
689#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
691#endif
693 };
696
697typedef union __vsf_eda_state_t {
698 struct {
699#if VSF_KERNEL_CFG_ALLOW_KERNEL_BEING_PREEMPTED == ENABLED
700# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
703# endif
705#else
706 uint8_t is_processing : 1;
707#endif
708
709#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
710 /* if is_limitted, eda can only receive 1 event */
713# ifdef __VSF_OS_CFG_EVTQ_LIST
715# endif
716#endif
717
718#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
720#endif
721 };
724
725typedef union __vsf_eda_flag_t {
726 struct {
729 };
732
733typedef union __vsf_eda_fn_t {
738
743
746 protected_member (
747 implement(vsf_slist_node_t)
750
751 union {
752 uintptr_t param;
753 uintptr_t target;
754 } ptr;
756};
757
758typedef struct vsf_eda_cfg_t {
766
770#if VSF_KERNEL_CFG_EDA_SUPPORT_ON_TERMINATE == ENABLED
771 protected_member(
772 vsf_eda_on_terminate_t on_terminate;
774#endif
775
777 protected_member(
778 union {
779 vsf_eda_evthandler_t evthandler;
780 vsf_slist_t frame_list;
781 __vsf_eda_frame_t *frame;
782 } fn;
783 uintptr_t return_value;
785#else
786 protected_member(
787 union {
788 vsf_eda_evthandler_t evthandler;
789 } fn;
790 )
791#endif
792
793 protected_member(
795 union {
796 vsf_dlist_node_t pending_node;
797 vsf_slist_node_t pending_snode;
798 };
799# endif
800
801# if VSF_KERNEL_CFG_ALLOW_KERNEL_BEING_PREEMPTED == ENABLED
802# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
803 vsf_dlist_node_t rdy_node;
804 vsf_slist_queue_t evt_list;
805 uint8_t cur_priority;
806 uint8_t new_priority;
807 uint8_t priority;
808# else
809 uint8_t evt_cnt;
810 uint8_t priority;
811# endif
812# else
813 uintptr_t evt_pending;
814# endif
815
816# if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
817 /* value holder for enum fsm_rt_t */
818 int8_t subcall_return_value;
819# endif
820# if VSF_KERNEL_OPT_AVOID_UNNECESSARY_YIELD_EVT == ENABLED
821 bool is_evt_incoming;
822# endif
823 __vsf_eda_flag_t flag;
824 )
825
827 private_member(
828 vsf_cpu_usage_t usage;
829 )
830#endif
831};
833
834#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
838 which(
839 implement(vsf_eda_t)
840 )
841 private_member(
842 vsf_dlist_node_t timer_node;
844 )
845};
847
848#if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
852 public_member(
853 void (*on_timer)(vsf_callback_timer_t *timer);
855 private_member(
856 vsf_dlist_node_t timer_node;
858 )
859};
861#endif
862#endif
863
864#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
868 // it's not good to make cur_union & max_union public
869 // but some APIs in shell will require these to be visible
870 public_member(
871 union {
872 struct {
873 uint16_t cur : 15;
874 uint16_t has_owner : 1;
875 } bits;
876 uint16_t cur_value;
877 } cur_union;
878 union {
879 struct {
880 uint16_t max : 15;
881 uint16_t manual_rst : 1;
882 } bits;
883 uint16_t max_value;
884 } max_union;
886
887 protected_member(
888 vsf_dlist_t pending_list;
890};
892
896 public_member(
897 implement(vsf_sync_t)
898 )
899 protected_member(
900 vsf_eda_t *eda_owner;
902};
904
905#ifndef __VSF_BITMAP_EVT_DEFINED__
906#define __VSF_BITMAP_EVT_DEFINED__
907
908#define VSF_BMPEVT_OR 0
909#define VSF_BMPEVT_AND 1
910
915#endif
916
920
921 public_member (
922 const vsf_bmpevt_adapter_op_t *op;
923 const uint32_t mask;
925 private_member(
926 vsf_bmpevt_t *bmpevt_host;
927 )
928};
930
934 which(
935 implement(vsf_bmpevt_adapter_t)
936 )
937 private_member(
938 vsf_eda_t eda;
939 )
940};
942
946
947 public_member (
948 uint32_t mask;
949 uint8_t op : 1;
951
952 private_member(
953 vsf_eda_t *eda_pending;
954 )
955};
957
961
962 public_member (
963 uint32_t auto_reset;
964 vsf_bmpevt_adapter_t **adapters;
966
967 private_member(
968 vsf_dlist_t pending_list;
970 uint32_t cancelled_value;
971 )
972
973 private_member(
974 union {
975 struct {
976 uint8_t adapter_count : 5;
977 uint8_t is_cancelling : 1;
978 uint8_t is_polling : 1;
979 uint8_t is_to_repoll : 1;
980 } bits;
981 uint8_t flag;
982 } state;
984};
986
987#if VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE == ENABLED
988typedef struct vsf_eda_queue_op_t {
989 bool (*enqueue)(vsf_eda_queue_t *pthis, void *node);
990 bool (*dequeue)(vsf_eda_queue_t *pthis, void **node);
992
996
1000 union {
1001 implement(vsf_sync_t)
1002#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
1003
1004 protected_member(
1005 union {
1006 uint16_t __cur_value;
1007 };
1008 union {
1009 struct {
1010 uint16_t __max : 15;
1011 uint16_t tx_processing : 1;
1012 };
1013 uint16_t __max_value;
1014 };
1016#else
1017 protected_member(
1018 struct {
1019 uint16_t __cur_value;
1020 uint16_t __max_value;
1021 vsf_eda_t *eda_tx;
1022 };
1023 )
1024#endif
1025 };
1026
1027 public_member(
1028#if VSF_EDA_QUEUE_CFG_REGION == ENABLED
1029 vsf_protect_region_t *region;
1030#endif
1032 )
1033
1034 protected_member(
1035 vsf_eda_t *eda_rx;
1036#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
1037 uint16_t readable_cnt;
1038#endif
1039#if VSF_KERNEL_CFG_QUEUE_HAS_RX_NOTIFIED == ENABLED
1040 bool rx_notified;
1041#endif
1043};
1045#endif
1046
1047
1048
1049# if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1051# else
1052typedef vsf_eda_t vsf_peda_t;
1053# endif
1054
1055// IPC
1056typedef enum vsf_sync_reason_t {
1063
1066// internal use only
1068
1069// vsf_mutex_t support priority inherit
1070// so who claim mutex, he must free the mutex himself
1073
1075 implement(vsf_bmpevt_adapter_eda_t)
1078
1080 implement(vsf_bmpevt_adapter_eda_t)
1084#endif
1085
1093
1094typedef struct vsf_kernel_cfg_t {
1098
1099
1100/*============================ GLOBAL VARIABLES ==============================*/
1101/*============================ PROTOTYPES ====================================*/
1102
1103#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1104
1105# if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICK
1106VSF_CAL_SECTION(".text.vsf.kernel.teda")
1107extern void vsf_systimer_on_tick(void);
1108# endif
1109
1110VSF_CAL_SECTION(".text.vsf.kernel.teda")
1112
1115
1116VSF_CAL_SECTION(".text.vsf.kernel.vsf_systimer_get_elapsed")
1118
1119#endif
1120
1121#if defined(__VSF_EDA_CLASS_INHERIT__) || defined(__VSF_EDA_CLASS_IMPLEMENT)
1122VSF_CAL_SECTION(".text.vsf.kernel.eda")
1123extern vsf_err_t __vsf_eda_init(vsf_eda_t *pthis, vsf_prio_t priotiry, vsf_eda_feature_t feature);
1124
1125VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_evthandler")
1127
1128VSF_CAL_SECTION(".text.vsf.kernel.eda")
1129extern void vsf_kernel_init( const vsf_kernel_cfg_t *cfg_ptr);
1130
1131# if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1132VSF_CAL_SECTION(".text.vsf.kernel.eda")
1133vsf_err_t __vsf_eda_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force);
1134# endif
1135
1136# if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
1137
1138VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_polling_state_get")
1139extern bool vsf_eda_polling_state_get(vsf_eda_t *pthis);
1140
1142extern void vsf_eda_polling_state_set(vsf_eda_t *pthis, bool state);
1143
1144# endif
1145#endif
1146
1147VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_evthandler")
1148extern vsf_err_t vsf_eda_go_to(uintptr_t evthandler);
1149
1150VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_start")
1152
1153// if vsf_eda_get_cur return NULL, means not in task context
1154VSF_CAL_SECTION(".text.vsf.kernel.eda")
1155extern vsf_eda_t *vsf_eda_get_cur(void);
1156
1157VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_cur_evt")
1158extern vsf_evt_t vsf_eda_get_cur_evt(void);
1159
1160VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_cur_msg")
1161extern void *vsf_eda_get_cur_msg(void);
1162
1163#if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
1164VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_is_stack_owner")
1165extern bool vsf_eda_is_stack_owner(vsf_eda_t *pthis);
1166#endif
1167
1168VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_return")
1169extern bool __vsf_eda_return(uintptr_t return_value);
1170
1171
1172#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1173VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_return_value")
1175#endif
1176
1177VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_yield")
1178extern void __vsf_eda_yield(void);
1179
1180#if VSF_KERNEL_CFG_EDA_CPU_USAGE == ENABLED
1181// user should provide vsf_cpu_usage_ctx_t memory, and maintain this memory until stop
1182// the ticks used returned is actually including ticks from all higher priority tasks and interrupt
1183extern void vsf_eda_cpu_usage_start(vsf_eda_t *pthis, vsf_cpu_usage_ctx_t *ctx);
1184extern void vsf_eda_cpu_usage_stop(vsf_eda_t *pthis);
1185#endif
1186
1187#if defined(__VSF_EDA_CLASS_INHERIT__) || defined(__VSF_EDA_CLASS_IMPLEMENT)
1188/* vsf_eda_fini() enables you to kill other eda tasks.
1189 We highly recommend that DO NOT use this api until you 100% sure.
1190 please make sure that the resources are properly freed when you trying to kill
1191 an eda other than your own. We highly recommend that please send a semaphore to
1192 the target eda to ask it killing itself after properly freeing all the resources.
1193 */
1194VSF_CAL_SECTION(".text.vsf.kernel.eda")
1195extern vsf_err_t vsf_eda_fini(vsf_eda_t *pthis);
1196
1197VSF_CAL_SECTION(".text.vsf.kernel.eda")
1198extern void __vsf_dispatch_evt(vsf_eda_t *pthis, vsf_evt_t evt);
1199
1200VSF_CAL_SECTION(".text.vsf.kernel.eda")
1202
1203# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
1204VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_get_cur_priority")
1206
1207VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_set_priority")
1209# endif
1210
1211#endif
1212
1213VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_user_value")
1215
1216VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_user_value")
1217extern uint8_t vsf_eda_get_user_value(void);
1218
1219#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1220VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_call_eda")
1222 uintptr_t param,
1223 size_t local_size);
1224
1225VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_call_eda")
1226extern
1228 uintptr_t param,
1229 size_t local_size);
1230
1231VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_go_to_ex")
1232extern vsf_err_t __vsf_eda_go_to_ex(uintptr_t evthandler, uintptr_t param);
1233
1234VSF_CAL_SECTION(".text.vsf.kernel.eda_nesting")
1236 uintptr_t func,
1237 uintptr_t param,
1239 bool is_sub_call);
1240
1241VSF_CAL_SECTION(".text.vsf.kernel.eda_nesting")
1243 uintptr_t param,
1245 bool is_sub_call);
1246
1247VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_get_local")
1249
1250VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_target_set")
1252
1253VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_target_get")
1254extern uintptr_t vsf_eda_target_get(void);
1255
1256#endif // VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL
1257
1258#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1259
1260VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_start")
1262
1263VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer")
1265
1266VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_due_ex")
1268
1269VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer_ex")
1271
1272static inline vsf_err_t vsf_teda_set_timer_ms(uint_fast32_t ms)
1273{
1275}
1276
1277static inline vsf_err_t vsf_teda_set_timer_us(uint_fast32_t us)
1278{
1280}
1281
1282VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_cancel_timer")
1284
1285VSF_CAL_SECTION(".text.vsf.kernel.__vsf_teda_cancel_timer")
1287
1288# if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
1289VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_init")
1291
1292VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add")
1294
1297
1298# if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
1299VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add_isr")
1301
1304# endif
1305
1306static inline vsf_err_t vsf_callback_timer_add_ms(vsf_callback_timer_t *timer, uint_fast32_t ms)
1307{
1309}
1310
1311static inline vsf_err_t vsf_callback_timer_add_us(vsf_callback_timer_t *timer, uint_fast32_t us)
1312{
1314}
1315# endif
1316#endif
1317
1318VSF_CAL_SECTION(".text.vsf.kernel.vsf_irq_enter")
1319extern uintptr_t vsf_irq_enter(void);
1320
1321VSF_CAL_SECTION(".text.vsf.kernel.vsf_irq_leave")
1322extern void vsf_irq_leave(uintptr_t ctx);
1323
1324VSF_CAL_SECTION(".text.vsf.kernel.eda")
1325extern vsf_err_t vsf_eda_post_evt(vsf_eda_t *pthis, vsf_evt_t evt);
1326
1327VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_post_msg")
1328extern vsf_err_t vsf_eda_post_msg(vsf_eda_t *pthis, void *msg);
1329#if VSF_KERNEL_CFG_SUPPORT_EVT_MESSAGE == ENABLED
1330VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_post_evt_msg")
1331extern vsf_err_t vsf_eda_post_evt_msg(vsf_eda_t *pthis, vsf_evt_t evt, void *msg);
1332#endif
1333
1334#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1335VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1337 uint_fast16_t max_value);
1338
1339#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
1340VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1342#endif
1343
1344VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1346VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1348
1349VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1351VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1353
1354VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1356
1357VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1359
1360VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1362
1363VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_sync_cancel")
1365
1366VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_sync_get_reason")
1368
1369#if VSF_KERNEL_CFG_SUPPORT_BITMAP_EVENT == ENABLED
1370VSF_CAL_SECTION(".data.vsf.kernel.vsf_eda_bmpevt_adapter_sync_op")
1372
1375
1376VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_init")
1378
1379VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_set")
1381
1382VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_reset")
1384
1385VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_cancel")
1387
1388VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_pend")
1390
1391VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_poll")
1393#endif
1394
1395#if VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE == ENABLED
1396VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_init")
1398
1399VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send")
1401
1402VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send_ex")
1404
1407
1408VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv")
1410
1411VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv_ex")
1413
1416
1417VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_get_cnt")
1419
1420VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_cancel")
1422
1423# if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
1424VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send_isr")
1426
1427VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv_isr")
1429# endif
1430
1431#endif // VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE
1432
1433
1434#endif // VSF_KERNEL_CFG_SUPPORT_SYNC
1435
1436#ifdef __cplusplus
1437}
1438#endif
1439
1440#undef __VSF_EDA_CLASS_INHERIT__
1441#undef __VSF_EDA_CLASS_IMPLEMENT
1442
1443/*============================ INCLUDES ======================================*/
1444
1445#if VSF_KERNEL_CFG_TRACE == ENABLED
1446# ifdef VSF_KERNEL_CFG_TRACE_HEADER
1447# include VSF_KERNEL_CFG_TRACE_HEADER
1448# endif
1449#endif
1450
1451#endif
1452#endif // __VSF_EDA_H__
#define VSF_CAL_SECTION(__SEC_STR)
Definition __compiler.h:186
#define ENABLED
Definition __type.h:28
vsf_err_t
Definition __type.h:42
bool
Definition type.h:60
Definition vsf_eda.h:745
Definition vsf_eda.h:933
Definition vsf_eda.h:919
Definition vsf_eda.h:945
Definition vsf_eda.h:960
Definition vsf_eda.h:851
Definition vsf_eda.h:999
Definition vsf_eda.h:769
Definition vsf_eda.h:895
Definition vsf_eda.h:867
Definition vsf_eda.h:837
vsf_arch_prio_t
Definition cortex_a_generic.h:88
uint64_t vsf_systimer_tick_t
Definition cortex_a_generic.h:73
struct ieee80211_ext_chansw_ie data
Definition ieee80211.h:80
__le16 timeout
Definition ieee80211.h:94
vsf_systimer_tick_t vsf_systimer_ms_to_tick(uint_fast32_t time_ms)
Definition linux_generic.c:440
vsf_systimer_tick_t vsf_systimer_us_to_tick(uint_fast32_t time_us)
Definition linux_generic.c:435
#define max(x, y)
Definition minmax.h:12
#define vsf_dcl_class
Definition ooc_class.h:46
#define vsf_class(__name)
Definition ooc_class.h:48
uint32_t uintptr_t
Definition stdint.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned char uint_fast8_t
Definition stdint.h:23
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
short int16_t
Definition stdint.h:6
unsigned long long uint64_t
Definition stdint.h:11
unsigned short uint_fast16_t
Definition stdint.h:25
unsigned char uint8_t
Definition stdint.h:5
signed char int8_t
Definition stdint.h:4
Definition vsf_eda.h:739
uint16_t local_size
Definition vsf_eda.h:741
vsf_eda_feature_t feature
Definition vsf_eda.h:740
Definition vsf_eda.h:1079
Definition vsf_eda.h:911
vsf_err_t(* reset)(vsf_bmpevt_adapter_t *pthis)
Definition vsf_eda.h:913
vsf_err_t(* init)(vsf_bmpevt_adapter_t *pthis)
Definition vsf_eda.h:912
Definition vsf_eda.h:1074
vsf_bmpevt_adapter_eda_t vsf_sync_t * sync
Definition vsf_eda.h:1076
Definition vsf_eda.h:633
vsf_systimer_tick_t duration
Definition vsf_eda.h:635
vsf_systimer_tick_t ticks
Definition vsf_eda.h:634
Definition vsf_eda.h:637
vsf_systimer_tick_t ticks
Definition vsf_eda.h:638
vsf_cpu_usage_ctx_t * ctx
Definition vsf_eda.h:639
Definition vsf_list.h:888
Definition vsf_list.h:883
Definition vsf_eda.h:758
uint16_t local_size
Definition vsf_eda.h:763
vsf_eda_on_terminate_t on_terminate
Definition vsf_eda.h:760
uintptr_t target
Definition vsf_eda.h:764
vsf_prio_t priority
Definition vsf_eda.h:761
__vsf_eda_fn_t fn
Definition vsf_eda.h:759
vsf_eda_feature_t feature
Definition vsf_eda.h:762
Definition vsf_eda.h:988
bool(* enqueue)(vsf_eda_queue_t *pthis, void *node)
Definition vsf_eda.h:989
bool(* dequeue)(vsf_eda_queue_t *pthis, void **node)
Definition vsf_eda.h:990
Definition vsf_eda.h:1094
vsf_arch_prio_t systimer_arch_prio
Definition vsf_eda.h:1096
vsf_prio_t highest_prio
Definition vsf_eda.h:1095
Definition vsf_arch_abstraction.h:54
Definition vsf_list.h:876
Definition vsf_list.h:896
Definition vsf_list.h:872
Definition vsf_eda.h:725
__vsf_eda_state_t state
Definition vsf_eda.h:727
vsf_eda_feature_t feature
Definition vsf_eda.h:728
__vsf_eda_flag_word value
Definition vsf_eda.h:730
Definition vsf_eda.h:733
vsf_param_eda_evthandler_t param_evthandler
Definition vsf_eda.h:736
vsf_eda_evthandler_t evthandler
Definition vsf_eda.h:735
uintptr_t func
Definition vsf_eda.h:734
Definition vsf_eda.h:697
uint8_t is_to_set_due
Definition vsf_eda.h:714
uint8_t is_to_exit
Definition vsf_eda.h:704
uint8_t is_limitted
Definition vsf_eda.h:711
uint8_t is_timed
Definition vsf_eda.h:719
uint8_t value
Definition vsf_eda.h:722
uint8_t is_ready
Definition vsf_eda.h:701
uint8_t is_new_prio
Definition vsf_eda.h:702
uint8_t is_sync_got
Definition vsf_eda.h:712
Definition vsf_eda.h:673
__vsf_eda_feature_word is_subcall_has_return_value
Definition vsf_eda.h:690
__vsf_eda_feature_word is_stack_owner
Definition vsf_eda.h:687
__vsf_eda_feature_word user_bits
Definition vsf_eda.h:692
__vsf_eda_feature_word is_use_frame
Definition vsf_eda.h:684
__vsf_eda_feature_word value
Definition vsf_eda.h:694
vk_av_control_value_t value
Definition vsf_audio.h:171
int16_t vsf_evt_t
Definition vsf_eda.h:654
vsf_mutex_t vsf_crit_t
Definition vsf_eda.h:1072
uintptr_t vsf_eda_get_return_value(void)
Definition vsf_eda.c:475
vsf_err_t vsf_eda_sync_init(vsf_sync_t *pthis, uint_fast16_t cur_value, uint_fast16_t max_value)
vsf_err_t vsf_eda_set_evthandler(vsf_eda_t *pthis, vsf_eda_evthandler_t evthandler)
Definition vsf_eda.c:742
void vsf_systimer_on_tick(void)
vsf_sync_reason_t vsf_eda_sync_get_reason(vsf_sync_t *pthis, vsf_evt_t evt)
vsf_sync_owner_t vsf_mutex_t
Definition vsf_eda.h:1071
vsf_err_t vsf_eda_bmpevt_reset(vsf_bmpevt_t *pthis, uint_fast32_t mask)
void __vsf_eda_yield(void)
Definition vsf_eda.c:539
vsf_err_t vsf_teda_cancel_timer(void)
vsf_err_t vsf_callback_timer_add_isr(vsf_callback_timer_t *timer, vsf_systimer_tick_t tick)
void(* vsf_eda_on_terminate_t)(vsf_eda_t *eda)
Definition vsf_eda.h:657
uint8_t vsf_eda_get_user_value(void)
Definition vsf_eda.c:556
vsf_err_t vsf_eda_queue_init(vsf_eda_queue_t *pthis, uint_fast16_t max)
vsf_err_t vsf_callback_timer_remove_isr(vsf_callback_timer_t *timer)
vsf_err_t vsf_teda_set_timer(vsf_systimer_tick_t tick)
vsf_err_t vsf_eda_post_evt(vsf_eda_t *pthis, vsf_evt_t evt)
Definition vsf_eda.c:929
vsf_err_t vsf_eda_bmpevt_cancel(vsf_bmpevt_t *pthis, uint_fast32_t mask)
vsf_sync_t vsf_trig_t
Definition vsf_eda.h:1065
vsf_teda_t vsf_peda_t
Definition vsf_eda.h:1050
#define VSF_KERNEL_TIMEOUT_TICK_T
Definition vsf_eda.h:590
vsf_err_t vsf_eda_sync_increase(vsf_sync_t *pthis)
vsf_err_t vsf_eda_queue_recv_isr(vsf_eda_queue_t *pthis, void **node)
void __vsf_eda_on_terminate(vsf_eda_t *pthis)
Definition vsf_eda.c:149
void vsf_eda_queue_cancel(vsf_eda_queue_t *pthis)
vsf_err_t vsf_eda_bmpevt_set(vsf_bmpevt_t *pthis, uint_fast32_t mask)
void vsf_eda_cpu_usage_start(vsf_eda_t *pthis, vsf_cpu_usage_ctx_t *ctx)
Definition vsf_eda.c:970
vsf_err_t __vsf_eda_call_eda_ex_prepare(uintptr_t func, uintptr_t param, __vsf_eda_frame_state_t state, bool is_sub_call)
Definition vsf_eda.c:633
vsf_kernel_error_t
Definition vsf_eda.h:1086
@ VSF_KERNEL_ERR_INVALID_CONTEXT
Definition vsf_eda.h:1088
@ VSF_KERNEL_ERR_NONE
Definition vsf_eda.h:1087
@ VSF_KERNEL_ERR_SHOULD_NOT_USE_PRIO_INHERIT_IN_IDLE_OR_ISR
Definition vsf_eda.h:1091
@ VSF_KERNEL_ERR_EDA_DOES_NOT_SUPPORT_TIMER
Definition vsf_eda.h:1090
@ VSF_KERNEL_ERR_INVALID_USAGE
Definition vsf_eda.h:1089
vsf_err_t vsf_eda_go_to(uintptr_t evthandler)
Definition vsf_eda.c:759
void(* vsf_eda_evthandler_t)(vsf_eda_t *eda, vsf_evt_t evt)
Definition vsf_eda.h:656
vsf_sync_t __vsf_crit_npb_t
Definition vsf_eda.h:1067
vsf_err_t __vsf_eda_init(vsf_eda_t *pthis, vsf_prio_t priotiry, vsf_eda_feature_t feature)
Definition vsf_eda.c:816
const vsf_bmpevt_adapter_op_t vsf_eda_bmpevt_adapter_bmpevt_op
vsf_err_t vsf_eda_bmpevt_init(vsf_bmpevt_t *pthis, uint_fast8_t adapter_count)
void vsf_callback_timer_init(vsf_callback_timer_t *timer)
void vsf_eda_cpu_usage_stop(vsf_eda_t *pthis)
Definition vsf_eda.c:984
vsf_err_t vsf_eda_sync_decrease(vsf_sync_t *pthis, vsf_timeout_tick_t timeout)
vsf_err_t vsf_eda_post_evt_msg(vsf_eda_t *pthis, vsf_evt_t evt, void *msg)
Definition vsf_eda.c:963
uintptr_t vsf_eda_target_get(void)
Definition vsf_eda.c:615
vsf_systimer_tick_t vsf_systimer_get_elapsed(vsf_systimer_tick_t from_time)
vsf_systimer_tick_t vsf_systimer_get_tick(void)
vsf_err_t vsf_eda_start(vsf_eda_t *pthis, vsf_eda_cfg_t *cfg)
Definition vsf_eda.c:832
@ VSF_KERNEL_EVT_QUEUE_SEND_NOTIFY
Definition vsf_eda.h:628
@ VSF_KERNEL_EVT_CALLBACK_TIMER
Definition vsf_eda.h:626
@ VSF_KERNEL_EVT_QUEUE_RECV_NOTIFY
Definition vsf_eda.h:629
@ VSF_KERNEL_EVT_CALLBACK_TIMER_ADD
Definition vsf_eda.h:627
uintptr_t __vsf_eda_get_local(vsf_eda_t *pthis)
Definition vsf_eda.c:589
vsf_err_t vsf_eda_queue_recv_ex(vsf_eda_queue_t *pthis, void **node, vsf_timeout_tick_t timeout, vsf_eda_t *eda)
vsf_err_t vsf_eda_bmpevt_pend(vsf_bmpevt_t *pthis, vsf_bmpevt_pender_t *pender, vsf_timeout_tick_t timeout)
VSF_KERNEL_TIMEOUT_TICK_T vsf_timeout_tick_t
Definition vsf_eda.h:592
vsf_err_t vsf_teda_set_timer_ex(vsf_teda_t *pthis, vsf_systimer_tick_t tick)
vsf_err_t vsf_callback_timer_add(vsf_callback_timer_t *timer, vsf_systimer_tick_t tick)
vsf_err_t __vsf_eda_set_priority(vsf_eda_t *pthis, vsf_prio_t prio)
Definition vsf_evtq_list.c:84
vsf_sync_reason_t vsf_eda_bmpevt_poll(vsf_bmpevt_t *pthis, vsf_bmpevt_pender_t *pender, vsf_evt_t evt)
vsf_err_t vsf_teda_start(vsf_teda_t *pthis, vsf_eda_cfg_t *cfg)
uint_fast16_t vsf_eda_queue_get_cnt(vsf_eda_queue_t *pthis)
void vsf_eda_set_user_value(uint8_t value)
Definition vsf_eda.c:547
vsf_err_t vsf_eda_queue_recv(vsf_eda_queue_t *pthis, void **node, vsf_timeout_tick_t timeout)
void * vsf_eda_get_cur_msg(void)
Definition vsf_eda.c:466
uint16_t __vsf_eda_flag_word
Definition vsf_eda.h:662
vsf_prio_t __vsf_eda_get_cur_priority(vsf_eda_t *pthis)
Definition vsf_evtq_list.c:77
vsf_err_t vsf_teda_set_due_ex(vsf_teda_t *this_ptr, vsf_systimer_tick_t due)
uint8_t __vsf_eda_feature_word
Definition vsf_eda.h:661
vsf_eda_t * vsf_eda_get_cur(void)
Definition vsf_eda.c:416
void __vsf_dispatch_evt(vsf_eda_t *pthis, vsf_evt_t evt)
Definition vsf_eda.c:224
vsf_err_t __vsf_eda_go_to_ex(uintptr_t evthandler, uintptr_t param)
Definition vsf_eda.c:720
vsf_err_t __vsf_eda_sync_decrease_ex(vsf_sync_t *pthis, vsf_timeout_tick_t timeout, vsf_eda_t *eda, bool manual)
@ VSF_EVT_NONE
compatible with fsm_rt_cpl
Definition vsf_eda.h:597
@ VSF_EVT_SYNC_CANCEL
Definition vsf_eda.h:616
@ VSF_EVT_SYNC
Definition vsf_eda.h:615
@ VSF_EVT_SYNC_POLL
Definition vsf_eda.h:617
@ VSF_EVT_SYSTEM
Definition vsf_eda.h:603
@ VSF_EVT_DUMMY
Definition vsf_eda.h:604
@ VSF_EVT_SIGNAL
Definition vsf_eda.h:600
@ VSF_EVT_EXIT
Definition vsf_eda.h:608
@ VSF_EVT_YIELD
compatible with fsm_rt_on_going
Definition vsf_eda.h:598
@ VSF_EVT_INVALID
compatible with fsm_rt_err
Definition vsf_eda.h:596
@ VSF_EVT_INIT
Definition vsf_eda.h:605
@ VSF_EVT_ENTER
Definition vsf_eda.h:607
@ VSF_EVT_FINI
Definition vsf_eda.h:606
@ VSF_EVT_MESSAGE
Definition vsf_eda.h:620
@ VSF_EVT_RETURN
Definition vsf_eda.h:609
@ VSF_EVT_TIMER
Definition vsf_eda.h:612
@ VSF_EVT_USER
Definition vsf_eda.h:621
vsf_systimer_tick_t vsf_systimer_get_duration(vsf_systimer_tick_t from_time, vsf_systimer_tick_t to_time)
void vsf_eda_polling_state_set(vsf_eda_t *pthis, bool state)
Definition vsf_eda.c:436
vsf_err_t vsf_eda_target_set(uintptr_t param)
Definition vsf_eda.c:601
void vsf_eda_sync_force_reset(vsf_sync_t *pthis)
vsf_err_t __vsf_eda_call_eda_ex(uintptr_t func, uintptr_t param, __vsf_eda_frame_state_t state, bool is_sub_call)
Definition vsf_eda.c:693
vsf_sync_t vsf_sem_t
Definition vsf_eda.h:1064
vsf_sync_reason_t vsf_eda_queue_send_get_reason(vsf_eda_queue_t *pthis, vsf_evt_t evt, void *node)
#define VSF_KERNEL_CFG_EDA_USER_BITLEN
Definition vsf_eda.h:58
uintptr_t vsf_irq_enter(void)
Definition vsf_eda.c:129
vsf_err_t vsf_eda_queue_send_isr(vsf_eda_queue_t *pthis, void *node)
vsf_evt_t vsf_eda_get_cur_evt(void)
Definition vsf_eda.c:458
bool vsf_eda_is_stack_owner(vsf_eda_t *pthis)
Definition vsf_eda.c:450
const vsf_bmpevt_adapter_op_t vsf_eda_bmpevt_adapter_sync_op
vsf_err_t __vsf_eda_sync_increase_ex(vsf_sync_t *pthis, vsf_eda_t *eda, bool manual)
vsf_err_t __vsf_eda_call_eda_prepare(uintptr_t evthandler, uintptr_t param, size_t local_size)
Definition vsf_eda.c:682
vsf_err_t __vsf_eda_call_eda(uintptr_t evthandler, uintptr_t param, size_t local_size)
Definition vsf_eda.c:727
vsf_err_t vsf_eda_post_msg(vsf_eda_t *pthis, void *msg)
Definition vsf_eda.c:955
vsf_err_t vsf_eda_queue_send_ex(vsf_eda_queue_t *pthis, void *node, vsf_timeout_tick_t timeout, vsf_eda_t *eda)
vsf_err_t __vsf_eda_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force)
Definition vsf_eda.c:947
void vsf_irq_leave(uintptr_t ctx)
Definition vsf_eda.c:141
vsf_err_t vsf_eda_sync_increase_isr(vsf_sync_t *pthis)
void vsf_kernel_init(const vsf_kernel_cfg_t *cfg_ptr)
Definition vsf_eda.c:162
vsf_sync_reason_t vsf_eda_queue_recv_get_reason(vsf_eda_queue_t *pthis, vsf_evt_t evt, void **node)
bool vsf_eda_polling_state_get(vsf_eda_t *pthis)
Definition vsf_eda.c:429
vsf_err_t vsf_eda_sync_decrease_ex(vsf_sync_t *pthis, vsf_timeout_tick_t timeout, vsf_eda_t *eda)
void(* vsf_param_eda_evthandler_t)(uintptr_t target, vsf_evt_t evt)
Definition vsf_eda.h:658
bool __vsf_eda_return(uintptr_t return_value)
Definition vsf_eda.c:484
vsf_err_t __vsf_teda_cancel_timer(vsf_teda_t *pthis)
vsf_sync_reason_t
Definition vsf_eda.h:1056
@ VSF_SYNC_GET
Definition vsf_eda.h:1060
@ VSF_SYNC_FAIL
Definition vsf_eda.h:1057
@ VSF_SYNC_CANCEL
Definition vsf_eda.h:1061
@ VSF_SYNC_TIMEOUT
Definition vsf_eda.h:1058
@ VSF_SYNC_PENDING
Definition vsf_eda.h:1059
vsf_err_t vsf_eda_queue_send(vsf_eda_queue_t *pthis, void *node, vsf_timeout_tick_t timeout)
vsf_err_t vsf_callback_timer_remove(vsf_callback_timer_t *timer)
vsf_err_t vsf_eda_sync_increase_ex(vsf_sync_t *pthis, vsf_eda_t *eda)
void vsf_eda_sync_cancel(vsf_sync_t *pthis)
vsf_err_t vsf_eda_fini(vsf_eda_t *pthis)
Definition vsf_eda.c:897
#define VSF_KERNEL_CFG_SUPPORT_SYNC
Definition vsf_kernel_cfg.h:46
#define VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL
Definition vsf_kernel_cfg.h:106
#define VSF_KERNEL_CFG_EDA_CPU_USAGE
Definition vsf_kernel_cfg.h:376
vsf_prio_t
Definition vsf_kernel_common.h:37
uint8_t state
Definition vsf_msg_tree.h:247
which(union { inherit(vsf_msgt_container_t) vsf_tgui_control_t };vsf_tgui_v_container_t) implement_ex(struct
Definition vsf_tgui_control.h:566
Generated from commit: vsfteam/vsf@1c19fdc