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#endif
714
715#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
717#endif
718 };
721
722typedef union __vsf_eda_flag_t {
723 struct {
726 };
729
730typedef union __vsf_eda_fn_t {
735
740
743 protected_member (
744 implement(vsf_slist_node_t)
747
748 union {
749 uintptr_t param;
750 uintptr_t target;
751 } ptr;
753};
754
755typedef struct vsf_eda_cfg_t {
763
767#if VSF_KERNEL_CFG_EDA_SUPPORT_ON_TERMINATE == ENABLED
768 protected_member(
769 vsf_eda_on_terminate_t on_terminate;
771#endif
772
774 protected_member(
775 union {
776 vsf_eda_evthandler_t evthandler;
777 vsf_slist_t frame_list;
778 __vsf_eda_frame_t *frame;
779 } fn;
780 uintptr_t return_value;
782#else
783 protected_member(
784 union {
785 vsf_eda_evthandler_t evthandler;
786 } fn;
787 )
788#endif
789
790 protected_member(
792 union {
793 vsf_dlist_node_t pending_node;
794 vsf_slist_node_t pending_snode;
795 };
796# endif
797
798# if VSF_KERNEL_CFG_ALLOW_KERNEL_BEING_PREEMPTED == ENABLED
799# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
800 vsf_dlist_node_t rdy_node;
801 vsf_slist_queue_t evt_list;
802 uint8_t cur_priority;
803 uint8_t new_priority;
804 uint8_t priority;
805# else
806 uint8_t evt_cnt;
807 uint8_t priority;
808# endif
809# else
810 uintptr_t evt_pending;
811# endif
812
813# if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
814 /* value holder for enum fsm_rt_t */
815 int8_t subcall_return_value;
816# endif
817# if VSF_KERNEL_OPT_AVOID_UNNECESSARY_YIELD_EVT == ENABLED
818 bool is_evt_incoming;
819# endif
820 __vsf_eda_flag_t flag;
821 )
822
824 private_member(
825 vsf_cpu_usage_t usage;
826 )
827#endif
828};
830
831#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
835 which(
836 implement(vsf_eda_t)
837 )
838 private_member(
839 vsf_dlist_node_t timer_node;
841 )
842};
844
845#if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
849 public_member(
850 void (*on_timer)(vsf_callback_timer_t *timer);
852 private_member(
853 vsf_dlist_node_t timer_node;
855 )
856};
858#endif
859#endif
860
861#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
865 // it's not good to make cur_union & max_union public
866 // but some APIs in shell will require these to be visible
867 public_member(
868 union {
869 struct {
870 uint16_t cur : 15;
871 uint16_t has_owner : 1;
872 } bits;
873 uint16_t cur_value;
874 } cur_union;
875 union {
876 struct {
877 uint16_t max : 15;
878 uint16_t manual_rst : 1;
879 } bits;
880 uint16_t max_value;
881 } max_union;
883
884 protected_member(
885 vsf_dlist_t pending_list;
887};
889
893 public_member(
894 implement(vsf_sync_t)
895 )
896 protected_member(
897 vsf_eda_t *eda_owner;
899};
901
902#ifndef __VSF_BITMAP_EVT_DEFINED__
903#define __VSF_BITMAP_EVT_DEFINED__
904
905#define VSF_BMPEVT_OR 0
906#define VSF_BMPEVT_AND 1
907
912#endif
913
917
918 public_member (
919 const vsf_bmpevt_adapter_op_t *op;
920 const uint32_t mask;
922 private_member(
923 vsf_bmpevt_t *bmpevt_host;
924 )
925};
927
931 which(
932 implement(vsf_bmpevt_adapter_t)
933 )
934 private_member(
935 vsf_eda_t eda;
936 )
937};
939
943
944 public_member (
945 uint32_t mask;
946 uint8_t op : 1;
948
949 private_member(
950 vsf_eda_t *eda_pending;
951 )
952};
954
958
959 public_member (
960 uint32_t auto_reset;
961 vsf_bmpevt_adapter_t **adapters;
963
964 private_member(
965 vsf_dlist_t pending_list;
967 uint32_t cancelled_value;
968 )
969
970 private_member(
971 union {
972 struct {
973 uint8_t adapter_count : 5;
974 uint8_t is_cancelling : 1;
975 uint8_t is_polling : 1;
976 uint8_t is_to_repoll : 1;
977 } bits;
978 uint8_t flag;
979 } state;
981};
983
984#if VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE == ENABLED
985typedef struct vsf_eda_queue_op_t {
986 bool (*enqueue)(vsf_eda_queue_t *pthis, void *node);
987 bool (*dequeue)(vsf_eda_queue_t *pthis, void **node);
989
993
997 union {
998 implement(vsf_sync_t)
999#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
1000
1001 protected_member(
1002 union {
1003 uint16_t __cur_value;
1004 };
1005 union {
1006 struct {
1007 uint16_t __max : 15;
1008 uint16_t tx_processing : 1;
1009 };
1010 uint16_t __max_value;
1011 };
1013#else
1014 protected_member(
1015 struct {
1016 uint16_t __cur_value;
1017 uint16_t __max_value;
1018 vsf_eda_t *eda_tx;
1019 };
1020 )
1021#endif
1022 };
1023
1024 public_member(
1025#if VSF_EDA_QUEUE_CFG_REGION == ENABLED
1026 vsf_protect_region_t *region;
1027#endif
1029 )
1030
1031 protected_member(
1032 vsf_eda_t *eda_rx;
1033#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
1034 uint16_t readable_cnt;
1035#endif
1036#if VSF_KERNEL_CFG_QUEUE_HAS_RX_NOTIFIED == ENABLED
1037 bool rx_notified;
1038#endif
1040};
1042#endif
1043
1044
1045
1046# if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1048# else
1049typedef vsf_eda_t vsf_peda_t;
1050# endif
1051
1052// IPC
1053typedef enum vsf_sync_reason_t {
1060
1063// internal use only
1065
1066// vsf_mutex_t support priority inherit
1067// so who claim mutex, he must free the mutex himself
1070
1072 implement(vsf_bmpevt_adapter_eda_t)
1075
1077 implement(vsf_bmpevt_adapter_eda_t)
1081#endif
1082
1090
1091typedef struct vsf_kernel_cfg_t {
1095
1096
1097/*============================ GLOBAL VARIABLES ==============================*/
1098/*============================ PROTOTYPES ====================================*/
1099
1100#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1101
1102# if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICK
1103VSF_CAL_SECTION(".text.vsf.kernel.teda")
1104extern void vsf_systimer_on_tick(void);
1105# endif
1106
1107VSF_CAL_SECTION(".text.vsf.kernel.teda")
1109
1112
1113VSF_CAL_SECTION(".text.vsf.kernel.vsf_systimer_get_elapsed")
1115
1116#endif
1117
1118#if defined(__VSF_EDA_CLASS_INHERIT__) || defined(__VSF_EDA_CLASS_IMPLEMENT)
1119VSF_CAL_SECTION(".text.vsf.kernel.eda")
1120extern vsf_err_t __vsf_eda_init(vsf_eda_t *pthis, vsf_prio_t priotiry, vsf_eda_feature_t feature);
1121
1122VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_evthandler")
1124
1125VSF_CAL_SECTION(".text.vsf.kernel.eda")
1126extern void vsf_kernel_init( const vsf_kernel_cfg_t *cfg_ptr);
1127
1128# if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1129VSF_CAL_SECTION(".text.vsf.kernel.eda")
1130vsf_err_t __vsf_eda_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force);
1131# endif
1132
1133# if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
1134
1135VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_polling_state_get")
1136extern bool vsf_eda_polling_state_get(vsf_eda_t *pthis);
1137
1139extern void vsf_eda_polling_state_set(vsf_eda_t *pthis, bool state);
1140
1141# endif
1142#endif
1143
1144VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_evthandler")
1145extern vsf_err_t vsf_eda_go_to(uintptr_t evthandler);
1146
1147VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_start")
1149
1150// if vsf_eda_get_cur return NULL, means not in task context
1151VSF_CAL_SECTION(".text.vsf.kernel.eda")
1152extern vsf_eda_t *vsf_eda_get_cur(void);
1153
1154VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_cur_evt")
1155extern vsf_evt_t vsf_eda_get_cur_evt(void);
1156
1157VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_cur_msg")
1158extern void *vsf_eda_get_cur_msg(void);
1159
1160#if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
1161VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_is_stack_owner")
1162extern bool vsf_eda_is_stack_owner(vsf_eda_t *pthis);
1163#endif
1164
1165VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_return")
1166extern bool __vsf_eda_return(uintptr_t return_value);
1167
1168
1169#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1170VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_return_value")
1172#endif
1173
1174VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_yield")
1175extern void __vsf_eda_yield(void);
1176
1177#if VSF_KERNEL_CFG_EDA_CPU_USAGE == ENABLED
1178// user should provide vsf_cpu_usage_ctx_t memory, and maintain this memory until stop
1179// the ticks used returned is actually including ticks from all higher priority tasks and interrupt
1180extern void vsf_eda_cpu_usage_start(vsf_eda_t *pthis, vsf_cpu_usage_ctx_t *ctx);
1181extern void vsf_eda_cpu_usage_stop(vsf_eda_t *pthis);
1182#endif
1183
1184#if defined(__VSF_EDA_CLASS_INHERIT__) || defined(__VSF_EDA_CLASS_IMPLEMENT)
1185/* vsf_eda_fini() enables you to kill other eda tasks.
1186 We highly recommend that DO NOT use this api until you 100% sure.
1187 please make sure that the resources are properly freed when you trying to kill
1188 an eda other than your own. We highly recommend that please send a semaphore to
1189 the target eda to ask it killing itself after properly freeing all the resources.
1190 */
1191VSF_CAL_SECTION(".text.vsf.kernel.eda")
1192extern vsf_err_t vsf_eda_fini(vsf_eda_t *pthis);
1193
1194VSF_CAL_SECTION(".text.vsf.kernel.eda")
1195extern void __vsf_dispatch_evt(vsf_eda_t *pthis, vsf_evt_t evt);
1196
1197VSF_CAL_SECTION(".text.vsf.kernel.eda")
1199
1200# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
1201VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_get_cur_priority")
1203
1204VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_set_priority")
1206# endif
1207
1208#endif
1209
1210VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_user_value")
1212
1213VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_user_value")
1214extern uint8_t vsf_eda_get_user_value(void);
1215
1216#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1217VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_call_eda")
1219 uintptr_t param,
1220 size_t local_size);
1221
1222VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_call_eda")
1223extern
1225 uintptr_t param,
1226 size_t local_size);
1227
1228VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_go_to_ex")
1229extern vsf_err_t __vsf_eda_go_to_ex(uintptr_t evthandler, uintptr_t param);
1230
1231VSF_CAL_SECTION(".text.vsf.kernel.eda_nesting")
1233 uintptr_t func,
1234 uintptr_t param,
1236 bool is_sub_call);
1237
1238VSF_CAL_SECTION(".text.vsf.kernel.eda_nesting")
1240 uintptr_t param,
1242 bool is_sub_call);
1243
1244VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_get_local")
1246
1247VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_target_set")
1249
1250VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_target_get")
1251extern uintptr_t vsf_eda_target_get(void);
1252
1253#endif // VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL
1254
1255#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1256
1257VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_start")
1259
1260VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer")
1262
1263VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer_ex")
1265
1266static inline vsf_err_t vsf_teda_set_timer_ms(uint_fast32_t ms)
1267{
1269}
1270
1271static inline vsf_err_t vsf_teda_set_timer_us(uint_fast32_t us)
1272{
1274}
1275
1276VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_cancel_timer")
1278
1279VSF_CAL_SECTION(".text.vsf.kernel.__vsf_teda_cancel_timer")
1281
1282# if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
1283VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_init")
1285
1286VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add")
1288
1291
1292# if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
1293VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add_isr")
1295
1298# endif
1299
1300static inline vsf_err_t vsf_callback_timer_add_ms(vsf_callback_timer_t *timer, uint_fast32_t ms)
1301{
1303}
1304
1305static inline vsf_err_t vsf_callback_timer_add_us(vsf_callback_timer_t *timer, uint_fast32_t us)
1306{
1308}
1309# endif
1310#endif
1311
1312VSF_CAL_SECTION(".text.vsf.kernel.vsf_irq_enter")
1313extern uintptr_t vsf_irq_enter(void);
1314
1315VSF_CAL_SECTION(".text.vsf.kernel.vsf_irq_leave")
1316extern void vsf_irq_leave(uintptr_t ctx);
1317
1318VSF_CAL_SECTION(".text.vsf.kernel.eda")
1319extern vsf_err_t vsf_eda_post_evt(vsf_eda_t *pthis, vsf_evt_t evt);
1320
1321VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_post_msg")
1322extern vsf_err_t vsf_eda_post_msg(vsf_eda_t *pthis, void *msg);
1323#if VSF_KERNEL_CFG_SUPPORT_EVT_MESSAGE == ENABLED
1324VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_post_evt_msg")
1325extern vsf_err_t vsf_eda_post_evt_msg(vsf_eda_t *pthis, vsf_evt_t evt, void *msg);
1326#endif
1327
1328#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1329VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1331 uint_fast16_t max_value);
1332
1333#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
1334VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1336#endif
1337
1338VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1340VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1342
1343VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1345VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1347
1348VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
1350
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_eda_sync_cancel")
1359
1360VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_sync_get_reason")
1362
1363#if VSF_KERNEL_CFG_SUPPORT_BITMAP_EVENT == ENABLED
1364VSF_CAL_SECTION(".data.vsf.kernel.vsf_eda_bmpevt_adapter_sync_op")
1366
1369
1370VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_init")
1372
1373VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_set")
1375
1376VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_reset")
1378
1379VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_cancel")
1381
1382VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_pend")
1384
1385VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_poll")
1387#endif
1388
1389#if VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE == ENABLED
1390VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_init")
1392
1393VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send")
1395
1396VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send_ex")
1398
1401
1402VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv")
1404
1405VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv_ex")
1407
1410
1411VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_get_cnt")
1413
1414VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_cancel")
1416
1417# if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
1418VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send_isr")
1420
1421VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv_isr")
1423# endif
1424
1425#endif // VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE
1426
1427
1428#endif // VSF_KERNEL_CFG_SUPPORT_SYNC
1429
1430#ifdef __cplusplus
1431}
1432#endif
1433
1434#undef __VSF_EDA_CLASS_INHERIT__
1435#undef __VSF_EDA_CLASS_IMPLEMENT
1436
1437/*============================ INCLUDES ======================================*/
1438
1439#if VSF_KERNEL_CFG_TRACE == ENABLED
1440# ifdef VSF_KERNEL_CFG_TRACE_HEADER
1441# include VSF_KERNEL_CFG_TRACE_HEADER
1442# endif
1443#endif
1444
1445#endif
1446#endif // __VSF_EDA_H__
#define VSF_CAL_SECTION(__SEC)
Definition __compiler.h:181
#define ENABLED
Definition __type.h:28
vsf_err_t
Definition __type.h:42
bool
Definition type.h:60
Definition vsf_eda.h:742
Definition vsf_eda.h:930
Definition vsf_eda.h:916
Definition vsf_eda.h:942
Definition vsf_eda.h:957
Definition vsf_eda.h:848
Definition vsf_eda.h:996
Definition vsf_eda.h:766
Definition vsf_eda.h:892
Definition vsf_eda.h:864
Definition vsf_eda.h:834
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:736
uint16_t local_size
Definition vsf_eda.h:738
vsf_eda_feature_t feature
Definition vsf_eda.h:737
Definition vsf_eda.h:1076
Definition vsf_eda.h:908
vsf_err_t(* reset)(vsf_bmpevt_adapter_t *pthis)
Definition vsf_eda.h:910
vsf_err_t(* init)(vsf_bmpevt_adapter_t *pthis)
Definition vsf_eda.h:909
Definition vsf_eda.h:1071
vsf_bmpevt_adapter_eda_t vsf_sync_t * sync
Definition vsf_eda.h:1073
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:755
uint16_t local_size
Definition vsf_eda.h:760
vsf_eda_on_terminate_t on_terminate
Definition vsf_eda.h:757
uintptr_t target
Definition vsf_eda.h:761
vsf_prio_t priority
Definition vsf_eda.h:758
__vsf_eda_fn_t fn
Definition vsf_eda.h:756
vsf_eda_feature_t feature
Definition vsf_eda.h:759
Definition vsf_eda.h:985
bool(* enqueue)(vsf_eda_queue_t *pthis, void *node)
Definition vsf_eda.h:986
bool(* dequeue)(vsf_eda_queue_t *pthis, void **node)
Definition vsf_eda.h:987
Definition vsf_eda.h:1091
vsf_arch_prio_t systimer_arch_prio
Definition vsf_eda.h:1093
vsf_prio_t highest_prio
Definition vsf_eda.h:1092
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:722
__vsf_eda_state_t state
Definition vsf_eda.h:724
vsf_eda_feature_t feature
Definition vsf_eda.h:725
__vsf_eda_flag_word value
Definition vsf_eda.h:727
Definition vsf_eda.h:730
vsf_param_eda_evthandler_t param_evthandler
Definition vsf_eda.h:733
vsf_eda_evthandler_t evthandler
Definition vsf_eda.h:732
uintptr_t func
Definition vsf_eda.h:731
Definition vsf_eda.h:697
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:716
uint8_t value
Definition vsf_eda.h:719
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
vsf_err_t vsf_eda_set_evthandler(vsf_eda_t *pthis, vsf_eda_evthandler_t evthandler)
Definition vsf_eda.c:736
void __vsf_eda_on_terminate(vsf_eda_t *pthis)
Definition vsf_eda.c:143
void __vsf_dispatch_evt(vsf_eda_t *pthis, vsf_evt_t evt)
Definition vsf_eda.c:218
void vsf_eda_polling_state_set(vsf_eda_t *pthis, bool state)
Definition vsf_eda.c:430
vsf_err_t __vsf_eda_init(vsf_eda_t *pthis, vsf_prio_t priority, vsf_eda_feature_t feature)
Definition vsf_eda.c:810
vsf_err_t __vsf_eda_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force)
Definition vsf_eda.c:941
void vsf_kernel_init(const vsf_kernel_cfg_t *cfg_ptr)
Definition vsf_eda.c:156
bool vsf_eda_polling_state_get(vsf_eda_t *pthis)
Definition vsf_eda.c:423
vsf_err_t vsf_eda_fini(vsf_eda_t *pthis)
Definition vsf_eda.c:891
int16_t vsf_evt_t
Definition vsf_eda.h:654
vsf_mutex_t vsf_crit_t
Definition vsf_eda.h:1069
uintptr_t vsf_eda_get_return_value(void)
Definition vsf_eda.c:469
vsf_err_t vsf_eda_sync_init(vsf_sync_t *pthis, uint_fast16_t cur_value, uint_fast16_t max_value)
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:1068
vsf_err_t vsf_eda_bmpevt_reset(vsf_bmpevt_t *pthis, uint_fast32_t mask)
void __vsf_eda_yield(void)
Definition vsf_eda.c:533
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:550
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:923
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:1062
vsf_teda_t vsf_peda_t
Definition vsf_eda.h:1047
#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_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:964
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:627
vsf_kernel_error_t
Definition vsf_eda.h:1083
@ VSF_KERNEL_ERR_INVALID_CONTEXT
Definition vsf_eda.h:1085
@ VSF_KERNEL_ERR_NONE
Definition vsf_eda.h:1084
@ VSF_KERNEL_ERR_SHOULD_NOT_USE_PRIO_INHERIT_IN_IDLE_OR_ISR
Definition vsf_eda.h:1088
@ VSF_KERNEL_ERR_EDA_DOES_NOT_SUPPORT_TIMER
Definition vsf_eda.h:1087
@ VSF_KERNEL_ERR_INVALID_USAGE
Definition vsf_eda.h:1086
@ 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_err_t vsf_eda_go_to(uintptr_t evthandler)
Definition vsf_eda.c:753
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:1064
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:978
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:957
uintptr_t vsf_eda_target_get(void)
Definition vsf_eda.c:609
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:826
uintptr_t __vsf_eda_get_local(vsf_eda_t *pthis)
Definition vsf_eda.c:583
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_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:541
@ 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
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:460
uint16_t __vsf_eda_flag_word
Definition vsf_eda.h:662
uint8_t __vsf_eda_feature_word
Definition vsf_eda.h:661
vsf_eda_t * vsf_eda_get_cur(void)
Definition vsf_eda.c:410
vsf_err_t __vsf_eda_go_to_ex(uintptr_t evthandler, uintptr_t param)
Definition vsf_eda.c:714
vsf_err_t __vsf_eda_sync_decrease_ex(vsf_sync_t *pthis, vsf_timeout_tick_t timeout, vsf_eda_t *eda, bool manual)
vsf_systimer_tick_t vsf_systimer_get_duration(vsf_systimer_tick_t from_time, vsf_systimer_tick_t to_time)
vsf_err_t vsf_eda_target_set(uintptr_t param)
Definition vsf_eda.c:595
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:687
vsf_sync_t vsf_sem_t
Definition vsf_eda.h:1061
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:452
bool vsf_eda_is_stack_owner(vsf_eda_t *pthis)
Definition vsf_eda.c:444
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:676
vsf_err_t __vsf_eda_call_eda(uintptr_t evthandler, uintptr_t param, size_t local_size)
Definition vsf_eda.c:721
vsf_err_t vsf_eda_post_msg(vsf_eda_t *pthis, void *msg)
Definition vsf_eda.c:949
vsf_err_t vsf_eda_queue_send_ex(vsf_eda_queue_t *pthis, void *node, vsf_timeout_tick_t timeout, vsf_eda_t *eda)
void vsf_irq_leave(uintptr_t ctx)
Definition vsf_eda.c:137
vsf_err_t vsf_eda_sync_increase_isr(vsf_sync_t *pthis)
vsf_sync_reason_t vsf_eda_queue_recv_get_reason(vsf_eda_queue_t *pthis, vsf_evt_t evt, void **node)
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:478
vsf_err_t __vsf_teda_cancel_timer(vsf_teda_t *pthis)
vsf_sync_reason_t
Definition vsf_eda.h:1053
@ VSF_SYNC_GET
Definition vsf_eda.h:1057
@ VSF_SYNC_FAIL
Definition vsf_eda.h:1054
@ VSF_SYNC_CANCEL
Definition vsf_eda.h:1058
@ VSF_SYNC_TIMEOUT
Definition vsf_eda.h:1055
@ VSF_SYNC_PENDING
Definition vsf_eda.h:1056
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_prio_t __vsf_eda_get_cur_priority(vsf_eda_t *pthis)
Definition vsf_evtq_list.c:75
vsf_err_t __vsf_eda_set_priority(vsf_eda_t *pthis, vsf_prio_t priority)
Definition vsf_evtq_list.c:82
#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:540