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
59#define VSF_SYNC_AUTO_RST 0x0000
68#define VSF_SYNC_MANUAL_RST 0x8000
77#define VSF_SYNC_HAS_OWNER 0x8000
78
85#define VSF_SYNC_MAX 0x7FFF
86
87#ifndef VSF_KERNEL_CFG_EDA_USER_BITLEN
88# define VSF_KERNEL_CFG_EDA_USER_BITLEN 5
89#endif
90
91/*============================ MACROFIED FUNCTIONS ===========================*/
92
93// SEMAPHORE
94#define __vsf_eda_sem_init2(__psem, __init_cnt, __max_cnt) \
95 vsf_eda_sync_init((__psem), (__init_cnt), (__max_cnt) | VSF_SYNC_AUTO_RST)
96#define __vsf_eda_sem_init1(__psem, __init_cnt) \
97 __vsf_eda_sem_init2((__psem), (__init_cnt), VSF_SYNC_MAX)
98#define __vsf_eda_sem_init0(__psem) \
99 __vsf_eda_sem_init1((__psem), 0)
100// 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);
117#define vsf_eda_sem_init(__psem, ...) \
118 __PLOOC_EVAL(__vsf_eda_sem_init, __VA_ARGS__)((__psem), ##__VA_ARGS__)
119
132#define vsf_eda_sem_post(__psem) vsf_eda_sync_increase((__psem))
133
134#define __vsf_eda_sem_pend1(__psem, __timeout) vsf_eda_sync_decrease((__psem), (__timeout))
135#define __vsf_eda_sem_pend0(__psem) __vsf_eda_sem_pend1((__psem), -1)
136// prototype: vsf_err_t vsf_eda_sem_pend(vsf_sem_t *sem, vsf_timeout_tick_t timeout = -1);
164#define vsf_eda_sem_pend(__psem, ...) \
165 __PLOOC_EVAL(__vsf_eda_sem_pend, __VA_ARGS__)((__psem), ##__VA_ARGS__)
166
167#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
188# define vsf_eda_sem_post_isr(__psem) vsf_eda_sync_increase_isr((__psem))
189#endif
190
191// MUTEX
209#define vsf_eda_mutex_init(__pmtx) \
210 vsf_eda_sync_init( &((__pmtx)->use_as__vsf_sync_t), \
211 1 | VSF_SYNC_HAS_OWNER, \
212 1 | VSF_SYNC_AUTO_RST)
213
214#define __vsf_eda_mutex_enter1(__pmtx, __timeout) \
215 vsf_eda_sync_decrease(&((__pmtx)->use_as__vsf_sync_t), (__timeout))
216#define __vsf_eda_mutex_enter0(__pmtx) __vsf_eda_mutex_enter1((__pmtx), -1)
217// prototype: vsf_err_t vsf_eda_mutex_enter(vsf_mutex_t *mutex, vsf_timeout_tick_t timeout = -1);
245#define vsf_eda_mutex_enter(__pmtx, ...) \
246 __PLOOC_EVAL(__vsf_eda_mutex_enter, __VA_ARGS__)((__pmtx), ##__VA_ARGS__)
247
264#define vsf_eda_mutex_leave(__pmtx) \
265 vsf_eda_sync_increase(&((__pmtx)->use_as__vsf_sync_t))
266#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
287# define vsf_eda_mutex_leave_isr(__pmtx) vsf_eda_sync_increase_isr(&(__pmtx)->use_as__vsf_sync_t)
288#endif
289
290// CRIT
307#define vsf_eda_crit_init(__pcrit) \
308 vsf_eda_mutex_init((__pcrit))
309
310#define __vsf_eda_crit_enter1(__pcrit, __timeout) \
311 vsf_eda_mutex_enter((__pcrit), (__timeout))
312#define __vsf_eda_crit_enter0(__pcrit) __vsf_eda_crit_enter1((__pcrit), -1)
313// prototype: vsf_err_t vsf_eda_crit_enter(vsf_crit_t *crit, vsf_timeout_tick_t timeout = -1);
341#define vsf_eda_crit_enter(__pcrit, ...) \
342 __PLOOC_EVAL(__vsf_eda_crit_enter, __VA_ARGS__)((__pcrit), ##__VA_ARGS__)
343
356#define vsf_eda_crit_leave(__pcrit) \
357 vsf_eda_mutex_leave((__pcrit))
358
359// EVENT
376#define vsf_eda_trig_init(__pevt, __set, __auto_rst) \
377 vsf_eda_sync_init((__pevt), (__set), \
378 1 | ((__auto_rst) ? VSF_SYNC_AUTO_RST : VSF_SYNC_MANUAL_RST))
379
380#define vsf_eda_trig_set0(__pevt) vsf_eda_sync_increase((__pevt))
381#define vsf_eda_trig_set1(__pevt, __manual) \
382 __vsf_eda_sync_increase_ex((__pevt), NULL, (__manual))
383// prototype: vsf_err_t vsf_eda_trig_set(vsf_trig_t *trig, bool manual);
384// prototype: vsf_err_t vsf_eda_trig_set(vsf_trig_t *trig);
403#define vsf_eda_trig_set(__pevt, ...) \
404 __PLOOC_EVAL(vsf_eda_trig_set, __VA_ARGS__)((__pevt), ##__VA_ARGS__)
405
418#define vsf_eda_trig_reset(__pevt) vsf_eda_sync_force_reset((__pevt))
419
420#define __vsf_eda_trig_wait1(__pevt, __timeout) \
421 vsf_eda_sync_decrease((__pevt), (__timeout))
422#define __vsf_eda_trig_wait0(__pevt) __vsf_eda_trig_wait1((__pevt), -1)
450#define vsf_eda_trig_wait(__pevt, ...) \
451 __PLOOC_EVAL(__vsf_eda_trig_wait, __VA_ARGS__)((__pevt), ##__VA_ARGS__)
452
453#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
474# define vsf_eda_trig_set_isr(__pevt) vsf_eda_sync_increase_isr((__pevt))
475#endif
476
477// CRIT without priority boost, internal use only
478// only used for edas with same priority
493#define __vsf_eda_crit_npb_init(__pcrit) \
494 vsf_eda_sync_init((__pcrit), 1, 1 | VSF_SYNC_AUTO_RST)
495
496#define __vsf_eda_crit_npb_enter1(__pcrit, __timeout) \
497 vsf_eda_sync_decrease((__pcrit), (__timeout))
498#define __vsf_eda_crit_npb_enter0(__pcrit) __vsf_eda_crit_npb_enter1((__pcrit), -1)
499// prototype: vsf_err_t __vsf_eda_crit_npb_enter(__vsf_crit_npb_t *crit_npb, vsf_timeout_tick_t timeout = -1);
523#define __vsf_eda_crit_npb_enter(__pcrit, ...) \
524 __PLOOC_EVAL(__vsf_eda_crit_npb_enter, __VA_ARGS__)((__pcrit), ##__VA_ARGS__)
525
542#define __vsf_eda_crit_npb_leave(__pcrit) \
543 vsf_eda_sync_increase((__pcrit))
544
545#define __vsf_eda_init2(__eda, __priority, __feature) \
546 __vsf_eda_init((__eda), (__priority), (__feature))
547#define __vsf_eda_init1(__eda, __priority) \
548 __vsf_eda_init2((__eda), (__priority), (vsf_eda_feature_t){.value = 0})
549#define __vsf_eda_init0(__eda) \
550 __vsf_eda_init1((__eda), vsf_prio_inherit)
551// prototype: vsf_err_t vsf_eda_init(vsf_eda_t *eda, vsf_prio_t prio = vsf_prio_inherit, vsf_eda_feature feature = 0);
573#define vsf_eda_init(__eda, ...) \
574 __PLOOC_EVAL(__vsf_eda_init, __VA_ARGS__)((__eda), ##__VA_ARGS__)
575
576#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
597# define vsf_teda_init(__teda, ...) vsf_eda_init(&(__teda)->use_as__vsf_eda_t, ##__VA_ARGS__)
598#endif
599
620#define vsf_eda_return(...) __vsf_eda_return((uintptr_t)(0, ##__VA_ARGS__))
621
622#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
637# define vsf_systimer_get_ms() vsf_systimer_tick_to_ms(vsf_systimer_get_tick())
652# define vsf_systimer_get_us() vsf_systimer_tick_to_us(vsf_systimer_get_tick())
653#endif
654
655#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
680# define vsf_eda_call_eda(__evthandler, ...) \
681 __vsf_eda_call_eda((uintptr_t)__evthandler, NULL, (0, ##__VA_ARGS))
704# define vsf_eda_call_param_eda(__param_evthandler, __param, ...) \
705 __vsf_eda_call_eda( (uintptr_t)__param_evthandler, \
706 (uintptr_t)__param, \
707 (0, ##__VA_ARGS__))
708
726# define vsf_eda_get_local(...) \
727 __vsf_eda_get_local((vsf_eda_t *)(vsf_eda_get_cur(), ##__VA_ARGS__))
728
729# define __vsf_peda_local(__name) peda_local_##__name
738# define vsf_peda_local(__name) __vsf_peda_local(__name)
739
740# define __vsf_peda_arg(__name) peda_arg_##__name
749# define vsf_peda_arg(__name) __vsf_peda_arg(__name)
750
751# define __vsf_peda_func(__name) vsf_peda_func_##__name
760# define vsf_peda_func(__name) __vsf_peda_func(__name)
761
762
763# define __vsf_peda_param(__name) peda_cb_##__name
772# define vsf_peda_param(__name) __vsf_peda_param(__name)
773
774
775# define __declare_vsf_peda_ctx(__name) \
776 typedef struct vsf_peda_param(__name) vsf_peda_param(__name); \
777 typedef struct vsf_peda_arg(__name) vsf_peda_arg(__name); \
778 typedef struct vsf_peda_local(__name) vsf_peda_local(__name);
787# define declare_vsf_peda_ctx(__name) __declare_vsf_peda_ctx(__name)
788
797# define dcl_vsf_peda_ctx(__name) \
798 declare_vsf_peda_ctx(__name)
799
800# define __declare_vsf_peda(__name) \
801 typedef struct __name __name; \
802 __declare_vsf_peda_ctx(__name)
811# define declare_vsf_peda(__name) __declare_vsf_peda(__name)
812
821# define dcl_vsf_peda(__name) \
822 declare_vsf_peda(__name)
823
824# define declare_vsf_peda_methods1(__decoration, __name) \
825 declare_vsf_peda_ctx(__name) \
826 __decoration \
827 void vsf_peda_func(__name)( \
828 struct vsf_peda_local(__name) *vsf_pthis,\
829 vsf_evt_t evt);
830
831# define declare_vsf_peda_methods2(__decoration, __name, __func1) \
832 declare_vsf_peda_ctx(__name) \
833 __decoration \
834 void vsf_peda_func(__name)( \
835 struct vsf_peda_local(__name) *vsf_pthis,\
836 vsf_evt_t evt); \
837 __decoration \
838 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
839 vsf_evt_t evt);
840
841# define declare_vsf_peda_methods3(__decoration, __name, __func1, __func2) \
842 declare_vsf_peda_ctx(__name) \
843 __decoration \
844 void vsf_peda_func(__name)( \
845 struct vsf_peda_local(__name) *vsf_pthis,\
846 vsf_evt_t evt); \
847 __decoration \
848 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
849 vsf_evt_t evt); \
850 __decoration \
851 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
852 vsf_evt_t evt);
853
854# define declare_vsf_peda_methods4(__name, __func1, __func2, __func3) \
855 declare_vsf_peda_ctx(__name) \
856 __decoration \
857 void vsf_peda_func(__name)( \
858 struct vsf_peda_local(__name) *vsf_pthis,\
859 vsf_evt_t evt); \
860 __decoration \
861 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
862 vsf_evt_t evt); \
863 __decoration \
864 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
865 vsf_evt_t evt); \
866 __decoration \
867 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
868 vsf_evt_t evt);
869
870# define declare_vsf_peda_methods5( __decoration, __name, __func1, __func2, \
871 __func3, __func4) \
872 declare_vsf_peda_ctx(__name) \
873 __decoration \
874 void vsf_peda_func(__name)( \
875 struct vsf_peda_local(__name) *vsf_pthis,\
876 vsf_evt_t evt); \
877 __decoration \
878 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
879 vsf_evt_t evt); \
880 __decoration \
881 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
882 vsf_evt_t evt); \
883 __decoration \
884 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
885 vsf_evt_t evt); \
886 __decoration \
887 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
888 vsf_evt_t evt);
889
890
891# define declare_vsf_peda_methods6( __decoration, __name, __func1, __func2, \
892 __func3, __func4, __func5) \
893 declare_vsf_peda_ctx(__name) \
894 __decoration \
895 void vsf_peda_func(__name)( \
896 struct vsf_peda_local(__name) *vsf_pthis,\
897 vsf_evt_t evt); \
898 __decoration \
899 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
900 vsf_evt_t evt); \
901 __decoration \
902 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
903 vsf_evt_t evt); \
904 __decoration \
905 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
906 vsf_evt_t evt); \
907 __decoration \
908 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
909 vsf_evt_t evt); \
910 __decoration \
911 void __func5( struct vsf_peda_local(__name) *vsf_pthis,\
912 vsf_evt_t evt);
913
914# define declare_vsf_peda_methods7( __decoration, __name, __func1, __func2, \
915 __func3, __func4, __func5, __func6) \
916 declare_vsf_peda_ctx(__name) \
917 __decoration \
918 void vsf_peda_func(__name)( \
919 struct vsf_peda_local(__name) *vsf_pthis,\
920 vsf_evt_t evt); \
921 __decoration \
922 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
923 vsf_evt_t evt); \
924 __decoration \
925 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
926 vsf_evt_t evt); \
927 __decoration \
928 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
929 vsf_evt_t evt); \
930 __decoration \
931 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
932 vsf_evt_t evt); \
933 __decoration \
934 void __func5( struct vsf_peda_local(__name) *vsf_pthis,\
935 vsf_evt_t evt); \
936 __decoration \
937 void __func6( struct vsf_peda_local(__name) *vsf_pthis,\
938 vsf_evt_t evt);
939
940# define declare_vsf_peda_methods8( __decoration, __name, __func1, __func2, \
941 __func3, __func4, __func5, __func6, \
942 __func7) \
943 declare_vsf_peda_ctx(__name) \
944 __decoration \
945 void vsf_peda_func(__name)( \
946 struct vsf_peda_local(__name) *vsf_pthis,\
947 vsf_evt_t evt); \
948 __decoration \
949 void __func1( struct vsf_peda_local(__name) *vsf_pthis,\
950 vsf_evt_t evt); \
951 __decoration \
952 void __func2( struct vsf_peda_local(__name) *vsf_pthis,\
953 vsf_evt_t evt); \
954 __decoration \
955 void __func3( struct vsf_peda_local(__name) *vsf_pthis,\
956 vsf_evt_t evt); \
957 __decoration \
958 void __func4( struct vsf_peda_local(__name) *vsf_pthis,\
959 vsf_evt_t evt); \
960 __decoration \
961 void __func5( struct vsf_peda_local(__name) *vsf_pthis,\
962 vsf_evt_t evt); \
963 __decoration \
964 void __func6( struct vsf_peda_local(__name) *vsf_pthis,\
965 vsf_evt_t evt); \
966 __decoration \
967 void __func7( struct vsf_peda_local(__name) *vsf_pthis,\
968 vsf_evt_t evt);
969
986#define declare_vsf_peda_methods(__decoration, ...) \
987 __PLOOC_EVAL(declare_vsf_peda_methods, __VA_ARGS__) \
988 (__decoration, __VA_ARGS__)
989
1000#define dcl_vsf_peda_methods(__decoration, ...) \
1001 declare_vsf_peda_methods(__decoration, __VA_ARGS__)
1002
1003# if __IS_COMPILER_IAR__
1004# define __def_vsf_peda_ctx4(__name, __param, __arg, __local) \
1005 struct vsf_peda_param(__name) { \
1006 __param \
1007 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
1008 }; \
1009 struct vsf_peda_arg(__name) { \
1010 __arg \
1011 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
1012 }; \
1013 struct vsf_peda_local(__name) { \
1014 implement(vsf_peda_arg(__name)) \
1015 __local \
1016 };
1017# else
1018# define __def_vsf_peda_ctx4(__name, __param, __arg, __local) \
1019 struct vsf_peda_param(__name) { \
1020 __param \
1021 }; \
1022 struct vsf_peda_arg(__name) { \
1023 __arg \
1024 }; \
1025 struct vsf_peda_local(__name) { \
1026 implement(vsf_peda_arg(__name)) \
1027 __local \
1028 };
1029#endif
1030
1031# define __def_vsf_peda4(__name, __param, __arg, __local) \
1032 __def_vsf_peda_ctx4(__name, __param, __arg, __local) \
1033 struct __name { \
1034 implement(vsf_peda_t) \
1035 implement_ex(vsf_peda_param(__name), param) \
1036 };
1037
1038# if __IS_COMPILER_IAR__
1039# define __def_vsf_peda_ctx3(__name, __param, __arg) \
1040 struct vsf_peda_param(__name) { \
1041 __param \
1042 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
1043 }; \
1044 struct vsf_peda_arg(__name) { \
1045 __arg \
1046 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
1047 }; \
1048 struct vsf_peda_local(__name) { \
1049 implement(vsf_peda_arg(__name)) \
1050 };
1051# else
1052# define __def_vsf_peda_ctx3(__name, __param, __arg) \
1053 struct vsf_peda_param(__name) { \
1054 __param \
1055 }; \
1056 struct vsf_peda_arg(__name) { \
1057 __arg \
1058 }; \
1059 struct vsf_peda_local(__name) { \
1060 implement(vsf_peda_arg(__name)) \
1061 };
1062#endif
1063
1064# define __def_vsf_peda3(__name, __param, __arg) \
1065 __def_vsf_peda_ctx3(__name, __param, __arg) \
1066 struct __name { \
1067 implement(vsf_peda_t) \
1068 implement_ex(vsf_peda_param(__name), param) \
1069 };
1070
1071
1072# if __IS_COMPILER_IAR__
1073# define __def_vsf_peda_ctx2(__name, __param) \
1074 struct vsf_peda_param(__name) { \
1075 __param \
1076 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
1077 }; \
1078 struct vsf_peda_arg(__name) { \
1079 uint8_t VSF_MCONNECT4(_,__LINE__,__COUNTER__,_canary); \
1080 }; \
1081 struct vsf_peda_local(__name) { \
1082 implement(vsf_peda_arg(__name)) \
1083 };
1084# else
1085# define __def_vsf_peda_ctx2(__name, __param) \
1086 struct vsf_peda_param(__name) { \
1087 __param \
1088 }; \
1089 struct vsf_peda_arg(__name) { \
1090 }; \
1091 struct vsf_peda_local(__name) { \
1092 implement(vsf_peda_arg(__name)) \
1093 };
1094#endif
1095
1096# define __def_vsf_peda_ctx1(__name) \
1097 __def_vsf_peda_ctx2(__name, )
1098
1099# define __def_vsf_peda2(__name, __param) \
1100 __def_vsf_peda_ctx2(__name, __param) \
1101 struct __name { \
1102 implement(vsf_peda_t) \
1103 implement_ex(vsf_peda_param(__name), param) \
1104 };
1105
1106# define __def_vsf_peda1(__name) \
1107 __def_vsf_peda_ctx1(__name) \
1108 struct __name { \
1109 implement(vsf_peda_t) \
1110 implement_ex(vsf_peda_param(__name), param) \
1111 };
1112
1129# define def_vsf_peda(...) \
1130 __PLOOC_EVAL(__def_vsf_peda, __VA_ARGS__) (__VA_ARGS__)
1131
1138# define end_def_vsf_peda(...)
1139
1155# define def_vsf_peda_ctx(...) \
1156 __PLOOC_EVAL(__def_vsf_peda_ctx, __VA_ARGS__)(__VA_ARGS__)
1157
1164# define end_def_vsf_peda_ctx(...)
1165
1175# define define_vsf_peda_ctx(__name, ...) \
1176 def_vsf_peda_ctx(__name, __VA_ARGS__)
1177
1184# define end_define_vsf_peda_ctx(...)
1185
1192# define def_locals(...) ,##__VA_ARGS__
1199# define end_def_locals(...)
1200
1207# define define_locals(...) ,##__VA_ARGS__
1214# define end_define_locals(...)
1215
1222# define def_args(...) ,__VA_ARGS__
1229# define end_def_args(...)
1230
1237# define define_args(...) ,__VA_ARGS__
1244# define end_define_args(...)
1245
1252# define define_arguments(...) ,__VA_ARGS__
1259# define end_define_arguments(...)
1260
1267# define define_parameters(...) __VA_ARGS__
1274# define end_define_parameters(...)
1275
1290#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1291# define vsf_peda_start vsf_teda_start
1292#else
1293# define vsf_peda_start vsf_eda_start
1294#endif
1295
1296# define __init_vsf_peda(__name, __param_eda, __pri, ...) \
1297 do { \
1298 vsf_eda_cfg_t VSF_MACRO_SAFE_NAME(cfg) = { \
1299 .fn.param_evthandler = \
1300 (vsf_param_eda_evthandler_t)vsf_peda_func(__name), \
1301 .priority = (__pri), \
1302 .target = (uintptr_t)&((__param_eda)->param), \
1303 .local_size = sizeof(vsf_peda_local(__name)), \
1304 __VA_ARGS__ \
1305 }; \
1306 vsf_peda_start((vsf_peda_t *)(__param_eda), \
1307 &VSF_MACRO_SAFE_NAME(cfg)); \
1308 } while(0)
1309
1332# define init_vsf_peda(__name, __param_eda, __pri, ...) \
1333 __init_vsf_peda(__name, (__param_eda), (__pri), __VA_ARGS__)
1334
1335
1336# define __implement_vsf_peda2(__name, __func_name) \
1337 void __func_name( struct vsf_peda_local(__name) *vsf_plocal, \
1338 vsf_evt_t evt) \
1339 { \
1340 vsf_peda_param(__name) *vsf_pthis = \
1341 *(vsf_peda_param(__name) **) \
1342 ((uintptr_t)vsf_plocal - sizeof(uintptr_t)); \
1343 VSF_UNUSED_PARAM(vsf_pthis); \
1344 VSF_KERNEL_ASSERT(NULL != vsf_pthis || NULL != vsf_plocal);
1345
1346# define __implement_vsf_peda1(__name) \
1347 void vsf_peda_func(__name)( struct vsf_peda_local(__name) *vsf_plocal, \
1348 vsf_evt_t evt) \
1349 { \
1350 vsf_peda_param(__name) *vsf_pthis = \
1351 *(vsf_peda_param(__name) **) \
1352 ((uintptr_t)vsf_plocal - sizeof(uintptr_t)); \
1353 VSF_UNUSED_PARAM(vsf_pthis); \
1354 VSF_KERNEL_ASSERT(NULL != vsf_pthis || NULL != vsf_plocal);
1355
1364# define vsf_peda_begin()
1365
1374# define vsf_peda_end() \
1375 }
1376
1393# define implement_vsf_peda(...) \
1394 __PLOOC_EVAL(__implement_vsf_peda, __VA_ARGS__)(__VA_ARGS__)
1395
1405# define imp_vsf_peda(...) \
1406 implement_vsf_peda(__VA_ARGS__)
1407
1430# define vsf_eda_call_peda(__name, __param) \
1431 vsf_eda_call_param_eda( vsf_peda_func(__name), \
1432 (__param), \
1433 sizeof(vsf_peda_local(__name)))
1434
1441# define vsf_local (*vsf_plocal)
1442
1443#endif
1450# define vsf_this (*vsf_pthis)
1451
1452// backward compatibility, do not use in new design
1461#define vsf_eda_mutex_try_enter vsf_eda_mutex_enter
1470#define vsf_eda_crit_try_enter vsf_eda_crit_enter
1471
1472/*============================ TYPES =========================================*/
1473
1481#ifndef VSF_KERNEL_TIMEOUT_TICK_T
1482# define VSF_KERNEL_TIMEOUT_TICK_T int_fast64_t
1483#endif
1492
1500enum {
1518#if VSF_KERNEL_CFG_SUPPORT_THREAD == ENABLED && VSF_KERNEL_CFG_THREAD_SIGNAL == ENABLED
1524#endif
1525
1563
1564 // events for time
1570
1571 // events for sync
1589
1590 // events for message
1603};
1604
1605// events for kernel task
1606enum {
1611};
1612
1613#if VSF_KERNEL_CFG_CPU_USAGE == ENABLED || VSF_KERNEL_CFG_EDA_CPU_USAGE == ENABLED
1639#endif
1640
1651
1652
1659
1666typedef void (*vsf_eda_evthandler_t)(vsf_eda_t *eda, vsf_evt_t evt);
1673typedef void (*vsf_eda_on_terminate_t)(vsf_eda_t *eda);
1682
1683#if VSF_KERNEL_CFG_EDA_USER_BITLEN <= 8 - 3
1686#elif VSF_KERNEL_CFG_EDA_USER_BITLEN <= 16 - 3
1689#elif VSF_KERNEL_CFG_EDA_USER_BITLEN <= 32 - 3
1692#else
1693# error VSF_KERNEL_CFG_EDA_USER_BITLEN not supported yet
1694#endif
1695
1702typedef union vsf_eda_feature_t {
1703 struct {
1704#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
1716#endif
1717#if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
1721#endif
1722#if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
1726#endif
1731 };
1736
1737typedef union __vsf_eda_state_t {
1738 struct {
1739#if VSF_KERNEL_CFG_ALLOW_KERNEL_BEING_PREEMPTED == ENABLED
1740# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
1742# endif
1744#else
1745 uint8_t is_processing : 1;
1746#endif
1747
1748#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1749 /* if is_limitted, eda can only receive 1 event */
1752# if (VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED) && defined(__VSF_OS_CFG_EVTQ_LIST)
1754# endif
1755#endif
1756
1757#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1759#endif
1760 };
1763
1771
1777
1782
1785 protected_member (
1786 implement(vsf_slist_node_t)
1787 __vsf_eda_fn_t fn;
1789
1790 union {
1791 uintptr_t param;
1792 uintptr_t target;
1793 } ptr;
1795};
1796
1827
1830
1839#if VSF_KERNEL_CFG_EDA_SUPPORT_ON_TERMINATE == ENABLED
1840 protected_member(
1841 vsf_eda_on_terminate_t on_terminate;
1843#endif
1844
1846 protected_member(
1847 union {
1848 vsf_eda_evthandler_t evthandler;
1849 vsf_slist_t frame_list;
1850 __vsf_eda_frame_t *frame;
1851 } fn;
1852 uintptr_t return_value;
1854#else
1855 protected_member(
1856 union {
1857 vsf_eda_evthandler_t evthandler;
1858 } fn;
1859 )
1860#endif
1861
1862 protected_member(
1864 union {
1865 vsf_dlist_node_t pending_node;
1866 vsf_slist_node_t pending_snode;
1867 };
1868# endif
1869
1870# if VSF_KERNEL_CFG_ALLOW_KERNEL_BEING_PREEMPTED == ENABLED
1871# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
1872 vsf_dlist_node_t rdy_node;
1873 vsf_slist_queue_t evt_list;
1874 uint8_t cur_priority;
1875 uint8_t new_priority;
1876 uint8_t priority;
1877 bool is_ready;
1878# else
1879 uint8_t evt_cnt;
1880 uint8_t priority;
1881# endif
1882# else
1883 uintptr_t evt_pending;
1884# endif
1885
1886# if VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE == ENABLED
1887 /* value holder for enum fsm_rt_t */
1888 int8_t subcall_return_value;
1889# endif
1890# if VSF_KERNEL_OPT_AVOID_UNNECESSARY_YIELD_EVT == ENABLED
1891 bool is_evt_incoming;
1892# endif
1893 __vsf_eda_flag_t flag;
1894 )
1895
1897 private_member(
1898 vsf_cpu_usage_t usage;
1899 )
1900#endif
1901};
1903
1904#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
1907
1917 public_member(
1918 implement(vsf_eda_t)
1919 )
1920 private_member(
1921 vsf_dlist_node_t timer_node;
1923 )
1924};
1926
1927#if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
1930
1938 public_member(
1944 void (*on_timer)(vsf_callback_timer_t *timer);
1946 private_member(
1947 vsf_dlist_node_t timer_node;
1949 )
1950};
1952#endif
1953#endif
1954
1955#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
1958
1965 // it's not good to make cur_union & max_union public
1966 // but some APIs in shell will require these to be visible
1967 public_member(
1973 union {
1974 struct {
1975 uint16_t cur : 15;
1976 uint16_t has_owner : 1;
1977 } bits;
1978 uint16_t cur_value;
1979 } cur_union;
1985 union {
1986 struct {
1988 uint16_t manual_rst : 1;
1989 } bits;
1990 uint16_t max_value;
1991 } max_union;
1993
1994 protected_member(
1995 vsf_dlist_t pending_list;
1997};
1999
2002
2010 public_member(
2011 implement(vsf_sync_t)
2012 )
2013 protected_member(
2014 vsf_eda_t *eda_owner;
2016};
2018
2019#ifndef __VSF_BITMAP_EVT_DEFINED__
2020#define __VSF_BITMAP_EVT_DEFINED__
2021
2029#define VSF_BMPEVT_OR 0
2037#define VSF_BMPEVT_AND 1
2038
2051#endif
2052
2055
2063
2064 public_member (
2067 const vsf_bmpevt_adapter_op_t *op;
2070 const uint32_t mask;
2072 private_member(
2073 vsf_bmpevt_t *bmpevt_host;
2074 )
2075};
2077
2080
2087 public_member(
2088 implement(vsf_bmpevt_adapter_t)
2089 )
2090 private_member(
2091 vsf_eda_t eda;
2092 )
2093};
2095
2098
2105
2106 public_member (
2109 uint32_t mask;
2112 uint8_t op : 1;
2114
2115 private_member(
2116 vsf_eda_t *eda_pending;
2117 )
2118};
2120
2123
2130
2131 public_member (
2134 uint32_t auto_reset;
2137 vsf_bmpevt_adapter_t **adapters;
2139
2140 private_member(
2141 vsf_dlist_t pending_list;
2143 uint32_t cancelled_value;
2144 )
2145
2146 private_member(
2147 union {
2148 struct {
2149 uint8_t adapter_count : 5;
2150 uint8_t is_cancelling : 1;
2151 uint8_t is_polling : 1;
2152 uint8_t is_to_repoll : 1;
2153 } bits;
2154 uint8_t flag;
2155 } state;
2157};
2159
2160#if VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE == ENABLED
2168typedef struct vsf_eda_queue_op_t {
2169 bool (*enqueue)(vsf_eda_queue_t *pthis, void *node);
2170 bool (*dequeue)(vsf_eda_queue_t *pthis, void **node);
2172
2182
2185
2194 union {
2195 implement(vsf_sync_t)
2196#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
2197
2198 protected_member(
2199 union {
2200 uint16_t __cur_value;
2201 };
2202 union {
2203 struct {
2204 uint16_t __max : 15;
2205 uint16_t tx_processing : 1;
2206 };
2207 uint16_t __max_value;
2208 };
2210#else
2211 protected_member(
2212 struct {
2213 uint16_t __cur_value;
2214 uint16_t __max_value;
2215 vsf_eda_t *eda_tx;
2216 };
2217 )
2218#endif
2219 };
2220
2221 public_member(
2222#if VSF_EDA_QUEUE_CFG_REGION == ENABLED
2225 vsf_protect_region_t *region;
2226#endif
2231 )
2232
2233 protected_member(
2234 vsf_eda_t *eda_rx;
2235#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
2236 uint16_t readable_cnt;
2237#endif
2238#if VSF_KERNEL_CFG_QUEUE_HAS_RX_NOTIFIED == ENABLED
2239 bool rx_notified;
2240#endif
2242};
2244#endif
2245
2246
2247
2248# if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
2250# else
2251typedef vsf_eda_t vsf_peda_t;
2252# endif
2253
2254// IPC
2289
2304// internal use only
2306
2314// vsf_mutex_t support priority inherit
2315// so who claim mutex, he must free the mutex himself
2324
2335
2347#endif
2348
2383
2388
2389
2390/*============================ GLOBAL VARIABLES ==============================*/
2391/*============================ PROTOTYPES ====================================*/
2392
2393#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
2394
2395# if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICK
2396VSF_CAL_SECTION(".text.vsf.kernel.teda")
2412extern void vsf_systimer_on_tick(void);
2413# endif
2414
2415VSF_CAL_SECTION(".text.vsf.kernel.teda")
2427
2444
2445VSF_CAL_SECTION(".text.vsf.kernel.vsf_systimer_get_elapsed")
2459
2460#endif
2461
2462#if defined(__VSF_EDA_CLASS_INHERIT__) || defined(__VSF_EDA_CLASS_IMPLEMENT)
2463VSF_CAL_SECTION(".text.vsf.kernel.eda")
2484extern vsf_err_t __vsf_eda_init(vsf_eda_t *pthis, vsf_prio_t priority, vsf_eda_feature_t feature);
2485
2486VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_evthandler")
2504
2505VSF_CAL_SECTION(".text.vsf.kernel.eda")
2522extern void vsf_kernel_init( const vsf_kernel_cfg_t *cfg_ptr);
2523
2524# if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
2525VSF_CAL_SECTION(".text.vsf.kernel.eda")
2544vsf_err_t __vsf_eda_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force);
2545# endif
2546
2547# if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
2548
2549VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_polling_state_get")
2564extern bool vsf_eda_polling_state_get(vsf_eda_t *pthis);
2565
2583extern void vsf_eda_polling_state_set(vsf_eda_t *pthis, bool state);
2584
2585# endif
2586#endif
2587
2588VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_evthandler")
2601extern vsf_err_t vsf_eda_go_to(uintptr_t evthandler);
2602
2603VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_start")
2621
2622// if vsf_eda_get_cur return NULL, means not in task context
2623VSF_CAL_SECTION(".text.vsf.kernel.eda")
2634extern vsf_eda_t *vsf_eda_get_cur(void);
2635
2636VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_cur_evt")
2647extern vsf_evt_t vsf_eda_get_cur_evt(void);
2648
2649VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_cur_msg")
2660extern void *vsf_eda_get_cur_msg(void);
2661
2662#if VSF_KERNEL_USE_SIMPLE_SHELL == ENABLED
2663VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_is_stack_owner")
2678extern bool vsf_eda_is_stack_owner(vsf_eda_t *pthis);
2679#endif
2680
2681VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_return")
2700extern bool __vsf_eda_return(uintptr_t return_value);
2701
2702
2703#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
2704VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_return_value")
2720#endif
2721
2722VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_yield")
2738extern void __vsf_eda_yield(void);
2739
2740#if VSF_KERNEL_CFG_EDA_CPU_USAGE == ENABLED
2741// user should provide vsf_cpu_usage_ctx_t memory, and maintain this memory until stop
2742// the ticks used returned is actually including ticks from all higher priority tasks and interrupt
2763extern void vsf_eda_cpu_usage_start(vsf_eda_t *pthis, vsf_cpu_usage_ctx_t *ctx);
2778extern void vsf_eda_cpu_usage_stop(vsf_eda_t *pthis);
2779#endif
2780
2781#if defined(__VSF_EDA_CLASS_INHERIT__) || defined(__VSF_EDA_CLASS_IMPLEMENT)
2782/* vsf_eda_fini() enables you to kill other eda tasks.
2783 We highly recommend that DO NOT use this api until you 100% sure.
2784 please make sure that the resources are properly freed when you trying to kill
2785 an eda other than your own. We highly recommend that please send a semaphore to
2786 the target eda to ask it killing itself after properly freeing all the resources.
2787 */
2788VSF_CAL_SECTION(".text.vsf.kernel.eda")
2804extern vsf_err_t vsf_eda_fini(vsf_eda_t *pthis);
2805
2806VSF_CAL_SECTION(".text.vsf.kernel.eda")
2823extern void __vsf_dispatch_evt(vsf_eda_t *pthis, vsf_evt_t evt);
2824
2825VSF_CAL_SECTION(".text.vsf.kernel.eda")
2841
2842# if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
2843VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_get_cur_priority")
2860
2861VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_set_priority")
2880# endif
2881
2882#endif
2883
2884VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_set_user_value")
2898
2899VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_get_user_value")
2910extern uint8_t vsf_eda_get_user_value(void);
2911
2912#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL == ENABLED
2913VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_call_eda")
2938 uintptr_t param,
2939 size_t local_size);
2940
2941VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_call_eda")
2968extern
2970 uintptr_t param,
2971 size_t local_size);
2972
2973VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_go_to_ex")
2994extern vsf_err_t __vsf_eda_go_to_ex(uintptr_t evthandler, uintptr_t param);
2995
2996VSF_CAL_SECTION(".text.vsf.kernel.eda_nesting")
3023 uintptr_t func,
3024 uintptr_t param,
3026 bool is_sub_call);
3027
3028VSF_CAL_SECTION(".text.vsf.kernel.eda_nesting")
3055 uintptr_t param,
3057 bool is_sub_call);
3058
3059VSF_CAL_SECTION(".text.vsf.kernel.__vsf_eda_get_local")
3079
3080VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_target_set")
3100
3101VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_target_get")
3116extern uintptr_t vsf_eda_target_get(void);
3117
3118#endif // VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL
3119
3120#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
3121
3122VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_start")
3144
3145VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer")
3167
3168VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_due_ex")
3190
3191VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer_ex")
3215
3234static inline vsf_err_t vsf_teda_set_timer_ms(uint_fast32_t ms)
3235{
3237}
3238
3257static inline vsf_err_t vsf_teda_set_timer_us(uint_fast32_t us)
3258{
3260}
3261
3262VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_cancel_timer")
3278
3279VSF_CAL_SECTION(".text.vsf.kernel.__vsf_teda_cancel_timer")
3298
3299# if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
3300VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_init")
3322
3343
3344VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add")
3364
3383
3384# if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
3385VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add_due_isr")
3413
3442
3464# endif
3465
3484static inline vsf_err_t vsf_callback_timer_add_ms(vsf_callback_timer_t *timer, uint_fast32_t ms)
3485{
3487}
3488
3507static inline vsf_err_t vsf_callback_timer_add_us(vsf_callback_timer_t *timer, uint_fast32_t us)
3508{
3510}
3511# endif
3512#endif
3513
3514VSF_CAL_SECTION(".text.vsf.kernel.vsf_irq_enter")
3523extern uintptr_t vsf_irq_enter(void);
3524
3525VSF_CAL_SECTION(".text.vsf.kernel.vsf_irq_leave")
3536extern void vsf_irq_leave(uintptr_t ctx);
3537
3538VSF_CAL_SECTION(".text.vsf.kernel.eda")
3553extern vsf_err_t vsf_eda_post_evt(vsf_eda_t *pthis, vsf_evt_t evt);
3554
3555VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_post_msg")
3572extern vsf_err_t vsf_eda_post_msg(vsf_eda_t *pthis, void *msg);
3573#if VSF_KERNEL_CFG_SUPPORT_EVT_MESSAGE == ENABLED
3574VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_post_evt_msg")
3597extern vsf_err_t vsf_eda_post_evt_msg(vsf_eda_t *pthis, vsf_evt_t evt, void *msg);
3598#endif
3599
3600#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
3601VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3625 uint_fast16_t max_value);
3626
3627#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
3628VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3650#endif
3651
3652VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3671VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3688
3689VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3712VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3740
3741VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3755
3756VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3785
3786VSF_CAL_SECTION(".text.vsf.kernel.vsf_sync")
3808
3809VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_sync_cancel")
3825
3826VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_sync_get_reason")
3846
3847#if VSF_KERNEL_CFG_SUPPORT_BITMAP_EVENT == ENABLED
3848VSF_CAL_SECTION(".data.vsf.kernel.vsf_eda_bmpevt_adapter_sync_op")
3861
3876
3877VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_init")
3897
3898VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_set")
3920
3921VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_reset")
3942
3943VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_cancel")
3965
3966VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_pend")
4001
4002VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_bmpevt_poll")
4030#endif
4031
4032#if VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE == ENABLED
4033VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_init")
4058
4059VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send")
4092
4093VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send_ex")
4121
4147
4148VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv")
4181
4182VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv_ex")
4210
4236
4237VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_get_cnt")
4255
4256VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_cancel")
4276
4277# if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
4278VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_send_isr")
4305
4306VSF_CAL_SECTION(".text.vsf.kernel.vsf_eda_queue_recv_isr")
4333# endif
4334
4335#endif // VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE
4336
4337
4338#endif // VSF_KERNEL_CFG_SUPPORT_SYNC
4339
4340#ifdef __cplusplus
4341}
4342#endif
4343
4344#undef __VSF_EDA_CLASS_INHERIT__
4345#undef __VSF_EDA_CLASS_IMPLEMENT
4346
4347/*============================ INCLUDES ======================================*/
4348
4349#if VSF_KERNEL_CFG_TRACE == ENABLED
4350# ifdef VSF_KERNEL_CFG_TRACE_HEADER
4351# include VSF_KERNEL_CFG_TRACE_HEADER
4352# endif
4353#endif
4354
4355#endif
4356#endif // __VSF_EDA_H__
#define VSF_CAL_SECTION(__SEC_STR)
Definition __compiler.h:189
#define ENABLED
Definition __type.h:28
vsf_err_t
Definition __type.h:42
bool
Definition type.h:60
Definition vsf_eda.h:1784
bmpevt adapter with an internal eda
Definition vsf_eda.h:2086
Adapter mapping an IPC object (e.g. a semaphore) onto bitmap-event bits, so one task can wait on mult...
Definition vsf_eda.h:2062
Wait condition of a bitmap-event wait.
Definition vsf_eda.h:2104
Bitmap-event group.
Definition vsf_eda.h:2129
Task-independent timer; when it expires the kernel task invokes the user callback.
Definition vsf_eda.h:1937
OS-aware queue; send pends while full, recv pends while empty; backend ops are supplied by the user (...
Definition vsf_eda.h:2193
The event-driven task (TCB); every VSF task is an eda at the bottom. Tasks share stacks and only occu...
Definition vsf_eda.h:1838
Sync object with an owner (mutex base); supports priority inheritance; the owner must leave it itself...
Definition vsf_eda.h:2009
Base sync IPC object; sem/mutex/trig/crit are built on it.
Definition vsf_eda.h:1964
eda with timer support (can use vsf_teda_set_timer() etc.); derived classes (task/pt/thread) inherit ...
Definition vsf_eda.h:1916
uint64_t vsf_systimer_tick_t
Definition cortex_a_generic.h:70
vsf_arch_prio_t
Definition cortex_a_generic.h:85
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:50
#define vsf_class(__name)
Definition ooc_class.h:52
uint32_t uintptr_t
Definition stdint.h:38
short int16_t
Definition stdint.h:6
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
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:1778
uint16_t local_size
Definition vsf_eda.h:1780
vsf_eda_feature_t feature
Definition vsf_eda.h:1779
Adapter mapping a nested vsf_bmpevt_t onto bitmap-event bits.
Definition vsf_eda.h:2342
Adapter init/reset operations, mapping an IPC object (e.g. a semaphore) onto bitmap-event bits so one...
Definition vsf_eda.h:2047
vsf_err_t(* reset)(vsf_bmpevt_adapter_t *pthis)
Definition vsf_eda.h:2049
vsf_err_t(* init)(vsf_bmpevt_adapter_t *pthis)
Definition vsf_eda.h:2048
Adapter mapping a vsf_sync_t onto bitmap-event bits.
Definition vsf_eda.h:2331
vsf_bmpevt_adapter_eda_t vsf_sync_t * sync
Definition vsf_eda.h:2333
Context for per-task CPU usage sampling; the user provides the ctx storage and must keep it valid unt...
Definition vsf_eda.h:1624
vsf_systimer_tick_t duration
Definition vsf_eda.h:1626
vsf_systimer_tick_t ticks
Definition vsf_eda.h:1625
Per-task CPU usage sampling data; points to the user-provided sampling context vsf_cpu_usage_ctx_t.
Definition vsf_eda.h:1635
vsf_systimer_tick_t ticks
Definition vsf_eda.h:1636
vsf_cpu_usage_ctx_t * ctx
Definition vsf_eda.h:1637
Definition vsf_list.h:888
Definition vsf_list.h:883
Configuration for starting an eda/teda task (vsf_eda_start(), vsf_teda_start(), init_vsf_peda(),...
Definition vsf_eda.h:1804
uint16_t local_size
Definition vsf_eda.h:1821
vsf_eda_on_terminate_t on_terminate
Definition vsf_eda.h:1811
uintptr_t target
Definition vsf_eda.h:1825
vsf_prio_t priority
Definition vsf_eda.h:1815
__vsf_eda_fn_t fn
Definition vsf_eda.h:1807
vsf_eda_feature_t feature
Definition vsf_eda.h:1818
User-provided queue backend operations for vsf_eda_queue_t; enqueue/dequeue return bool success,...
Definition vsf_eda.h:2168
bool(* enqueue)(vsf_eda_queue_t *pthis, void *node)
Definition vsf_eda.h:2169
bool(* dequeue)(vsf_eda_queue_t *pthis, void **node)
Definition vsf_eda.h:2170
Definition vsf_eda.h:2384
vsf_arch_prio_t systimer_arch_prio
Definition vsf_eda.h:2386
vsf_prio_t highest_prio
Definition vsf_eda.h:2385
Definition vsf_arch_abstraction.h:61
Definition vsf_list.h:876
Definition vsf_list.h:896
Definition vsf_list.h:872
Definition vsf_eda.h:1764
__vsf_eda_state_t state
Definition vsf_eda.h:1766
vsf_eda_feature_t feature
Definition vsf_eda.h:1767
__vsf_eda_flag_word value
Definition vsf_eda.h:1769
Definition vsf_eda.h:1772
vsf_param_eda_evthandler_t param_evthandler
Definition vsf_eda.h:1775
vsf_eda_evthandler_t evthandler
Definition vsf_eda.h:1774
uintptr_t func
Definition vsf_eda.h:1773
Definition vsf_eda.h:1737
uint8_t is_to_set_due
Definition vsf_eda.h:1753
uint8_t is_to_exit
Definition vsf_eda.h:1743
uint8_t is_limitted
Definition vsf_eda.h:1750
uint8_t is_timed
Definition vsf_eda.h:1758
uint8_t value
Definition vsf_eda.h:1761
uint8_t is_new_prio
Definition vsf_eda.h:1741
uint8_t is_sync_got
Definition vsf_eda.h:1751
Task feature flags passed in vsf_eda_cfg_t.
Definition vsf_eda.h:1702
__vsf_eda_feature_word is_subcall_has_return_value
Definition vsf_eda.h:1725
__vsf_eda_feature_word is_stack_owner
Definition vsf_eda.h:1720
__vsf_eda_feature_word user_bits
Definition vsf_eda.h:1730
__vsf_eda_feature_word is_use_frame
Definition vsf_eda.h:1715
__vsf_eda_feature_word value
Definition vsf_eda.h:1734
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:745
void __vsf_eda_on_terminate(vsf_eda_t *pthis)
Definition vsf_eda.c:149
void __vsf_dispatch_evt(vsf_eda_t *pthis, vsf_evt_t evt)
Definition vsf_eda.c:224
void vsf_eda_polling_state_set(vsf_eda_t *pthis, bool state)
Definition vsf_eda.c:436
vsf_err_t __vsf_eda_init(vsf_eda_t *pthis, vsf_prio_t priority, vsf_eda_feature_t feature)
Definition vsf_eda.c:819
vsf_err_t __vsf_eda_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force)
Definition vsf_eda.c:953
void vsf_kernel_init(const vsf_kernel_cfg_t *cfg_ptr)
Definition vsf_eda.c:162
bool vsf_eda_polling_state_get(vsf_eda_t *pthis)
Definition vsf_eda.c:429
vsf_err_t vsf_eda_fini(vsf_eda_t *pthis)
Definition vsf_eda.c:903
int16_t vsf_evt_t
Kernel event type.
Definition vsf_eda.h:1658
vsf_mutex_t vsf_crit_t
Critical section (alias of mutex semantics)
Definition vsf_eda.h:2323
uintptr_t vsf_eda_get_return_value(void)
Get the return value passed back by the sub-called task.
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)
Initialize a sync object, the base of semaphore, mutex, trigger etc.
void vsf_systimer_on_tick(void)
System timer tick handler; called by the user on every system tick to drive the kernel timers.
vsf_sync_reason_t vsf_eda_sync_get_reason(vsf_sync_t *pthis, vsf_evt_t evt)
Retrieve the result of a sync operation from the wakeup event.
struct vsf_bmpevt_adapter_op_t vsf_bmpevt_adapter_op_t
Adapter init/reset operations, mapping an IPC object (e.g. a semaphore) onto bitmap-event bits so one...
vsf_sync_owner_t vsf_mutex_t
Mutex (vsf_sync_owner_t with priority inheritance); the owner must leave it itself.
Definition vsf_eda.h:2316
vsf_err_t vsf_eda_bmpevt_reset(vsf_bmpevt_t *pthis, uint_fast32_t mask)
Reset (clear) event bits of a bitmap event, resetting the bound adapters whose bits are cleared.
void __vsf_eda_yield(void)
Yield the current task by posting VSF_EVT_YIELD to itself, so that it is dispatched again later.
Definition vsf_eda.c:539
vsf_err_t vsf_teda_cancel_timer(void)
Cancel the pending timer of the current teda task.
vsf_err_t vsf_callback_timer_add_isr(vsf_callback_timer_t *timer, vsf_systimer_tick_t tick)
Add a callback timer with a relative interval in ticks from interrupt context.
void(* vsf_eda_on_terminate_t)(vsf_eda_t *eda)
On-terminate callback; invoked with the terminating task (eda)
Definition vsf_eda.h:1673
uint8_t vsf_eda_get_user_value(void)
Get the user-defined bits in the feature of the current eda.
Definition vsf_eda.c:556
vsf_err_t vsf_eda_queue_init(vsf_eda_queue_t *pthis, uint_fast16_t max)
Initialize an OS-aware queue whose enqueue/dequeue operations are provided by the user in the op memb...
vsf_err_t vsf_callback_timer_remove_isr(vsf_callback_timer_t *timer)
Remove a callback timer from interrupt context.
vsf_err_t vsf_teda_set_timer(vsf_systimer_tick_t tick)
Set a one-shot timer of the given ticks for the current teda task; the task receives VSF_EVT_TIMER wh...
vsf_err_t vsf_eda_post_evt(vsf_eda_t *pthis, vsf_evt_t evt)
Post an event to an eda task.
Definition vsf_eda.c:935
vsf_err_t vsf_eda_bmpevt_cancel(vsf_bmpevt_t *pthis, uint_fast32_t mask)
Cancel the pending tasks on a bitmap event whose mask intersects the given mask; they are woken with ...
vsf_sync_t vsf_trig_t
Trigger/event flag (sync with max 1, auto or manual reset)
Definition vsf_eda.h:2303
vsf_teda_t vsf_peda_t
Definition vsf_eda.h:2249
#define VSF_KERNEL_TIMEOUT_TICK_T
Underlying integer type of vsf_timeout_tick_t; redefine it before including this header to change the...
Definition vsf_eda.h:1482
vsf_err_t vsf_eda_sync_increase(vsf_sync_t *pthis)
Increase a sync object, waking up the pending tasks if any.
union __vsf_eda_state_t __vsf_eda_state_t
@ VSF_EVT_NONE
No event; compatible with fsm_rt_cpl.
Definition vsf_eda.h:1512
@ VSF_EVT_SYNC_CANCEL
The pending sync IPC was cancelled (e.g. by vsf_eda_sync_cancel())
Definition vsf_eda.h:1583
@ VSF_EVT_SYNC
A pending sync IPC (semaphore/mutex/trigger/queue/bmpevt) was obtained.
Definition vsf_eda.h:1577
@ VSF_EVT_SYNC_POLL
Sync poll event (used by bmpevt polling)
Definition vsf_eda.h:1588
@ VSF_EVT_SYSTEM
Base of system events; system events start here, user events start at VSF_EVT_USER.
Definition vsf_eda.h:1531
@ VSF_EVT_DUMMY
Dummy system event.
Definition vsf_eda.h:1536
@ VSF_EVT_SIGNAL
POSIX-like thread signal event (VSF_KERNEL_CFG_THREAD_SIGNAL)
Definition vsf_eda.h:1523
@ VSF_EVT_EXIT
Received when a called sub task returns.
Definition vsf_eda.h:1556
@ VSF_EVT_YIELD
Cooperative yield event; compatible with fsm_rt_on_going.
Definition vsf_eda.h:1517
@ VSF_EVT_INVALID
Invalid event; waiting for it means waiting for any event; also compatible with fsm_rt_err.
Definition vsf_eda.h:1507
@ VSF_EVT_INIT
Received once when a task starts.
Definition vsf_eda.h:1541
@ VSF_EVT_ENTER
Received when entering a sub-call frame.
Definition vsf_eda.h:1551
@ VSF_EVT_FINI
Received once when a task terminates.
Definition vsf_eda.h:1546
@ VSF_EVT_MESSAGE
A message event carrying a pointer, retrieved with vsf_eda_get_cur_msg()
Definition vsf_eda.h:1596
@ VSF_EVT_RETURN
Same value as VSF_EVT_EXIT; received when a called sub task returns.
Definition vsf_eda.h:1562
@ VSF_EVT_TIMER
teda timer expired (only for teda tasks)
Definition vsf_eda.h:1569
@ VSF_EVT_USER
Base of user-defined events; values from here on are user events.
Definition vsf_eda.h:1602
vsf_err_t vsf_eda_queue_recv_isr(vsf_eda_queue_t *pthis, void **node)
Receive a node from a queue from interrupt context.
void vsf_eda_queue_cancel(vsf_eda_queue_t *pthis)
Cancel all pending senders and the pending receiver on a queue; they are woken with VSF_EVT_SYNC_CANC...
vsf_err_t vsf_eda_bmpevt_set(vsf_bmpevt_t *pthis, uint_fast32_t mask)
Set event bits of a bitmap event, polling the pending tasks.
void vsf_eda_cpu_usage_start(vsf_eda_t *pthis, vsf_cpu_usage_ctx_t *ctx)
Start measuring the CPU usage of an eda task.
Definition vsf_eda.c:976
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)
Prepare an extended sub-call frame without dispatching VSF_EVT_INIT.
Definition vsf_eda.c:633
vsf_kernel_error_t
Kernel error codes reported to vsf_kernel_err_report()
Definition vsf_eda.h:2355
@ VSF_KERNEL_ERR_INVALID_CONTEXT
API called from an invalid context.
Definition vsf_eda.h:2365
@ VSF_KERNEL_ERR_NONE
No error.
Definition vsf_eda.h:2360
@ VSF_KERNEL_ERR_SHOULD_NOT_USE_PRIO_INHERIT_IN_IDLE_OR_ISR
vsf_prio_inherit used where there is no current event queue (idle or ISR)
Definition vsf_eda.h:2381
@ VSF_KERNEL_ERR_EDA_DOES_NOT_SUPPORT_TIMER
Timer service used on an eda without timer support.
Definition vsf_eda.h:2375
@ VSF_KERNEL_ERR_INVALID_USAGE
API used incorrectly.
Definition vsf_eda.h:2370
struct vsf_kernel_cfg_t vsf_kernel_cfg_t
union vsf_eda_feature_t vsf_eda_feature_t
Task feature flags passed in vsf_eda_cfg_t.
vsf_err_t vsf_eda_go_to(uintptr_t evthandler)
Switch the current task to a new event handler and post VSF_EVT_INIT to it.
Definition vsf_eda.c:762
void(* vsf_eda_evthandler_t)(vsf_eda_t *eda, vsf_evt_t evt)
eda event handler; invoked with the task (eda) and the event (evt)
Definition vsf_eda.h:1666
vsf_sync_t __vsf_crit_npb_t
Definition vsf_eda.h:2305
const vsf_bmpevt_adapter_op_t vsf_eda_bmpevt_adapter_bmpevt_op
Adapter operation table vsf_bmpevt_adapter_op_t used to bind another bitmap event to a bitmap event.
struct __vsf_eda_frame_state_t __vsf_eda_frame_state_t
vsf_err_t vsf_eda_bmpevt_init(vsf_bmpevt_t *pthis, uint_fast8_t adapter_count)
Initialize a bitmap event, initializing the bound adapters as well.
void vsf_callback_timer_init(vsf_callback_timer_t *timer)
Initialize a task-independent callback timer; set the on_timer callback before adding the timer.
void vsf_eda_cpu_usage_stop(vsf_eda_t *pthis)
Stop measuring the CPU usage of an eda task.
Definition vsf_eda.c:990
vsf_err_t vsf_eda_sync_decrease(vsf_sync_t *pthis, vsf_timeout_tick_t timeout)
Decrease a sync object, pending if the resource is not available.
struct vsf_eda_queue_op_t vsf_eda_queue_op_t
User-provided queue backend operations for vsf_eda_queue_t; enqueue/dequeue return bool success,...
union __vsf_eda_flag_t __vsf_eda_flag_t
vsf_err_t vsf_eda_post_evt_msg(vsf_eda_t *pthis, vsf_evt_t evt, void *msg)
Post an event carrying a pointer message to an eda task; the pointer is retrieved with vsf_eda_get_cu...
Definition vsf_eda.c:969
uintptr_t vsf_eda_target_get(void)
Get the target parameter of the current frame of the current task.
Definition vsf_eda.c:615
vsf_systimer_tick_t vsf_systimer_get_elapsed(vsf_systimer_tick_t from_time)
Get the ticks elapsed from the given tick count to now.
vsf_systimer_tick_t vsf_systimer_get_tick(void)
Get the current system timer tick count.
vsf_err_t vsf_eda_start(vsf_eda_t *pthis, vsf_eda_cfg_t *cfg)
Start an eda task with the given configuration and post VSF_EVT_INIT to it.
Definition vsf_eda.c:835
vsf_err_t vsf_callback_timer_add_due(vsf_callback_timer_t *timer, vsf_systimer_tick_t due)
Add a callback timer with an absolute due tick.
uintptr_t __vsf_eda_get_local(vsf_eda_t *pthis)
Get the local variable storage of a frame-based eda.
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)
Receive a node from a queue on behalf of the given eda.
struct vsf_eda_cfg_t vsf_eda_cfg_t
Configuration for starting an eda/teda task (vsf_eda_start(), vsf_teda_start(), init_vsf_peda(),...
vsf_err_t vsf_eda_bmpevt_pend(vsf_bmpevt_t *pthis, vsf_bmpevt_pender_t *pender, vsf_timeout_tick_t timeout)
Pend on a bitmap event until the masked bits are set (in OR or AND mode according to the pender confi...
VSF_KERNEL_TIMEOUT_TICK_T vsf_timeout_tick_t
Timeout type in system timer ticks: negative means wait forever, 0 means non-blocking try,...
Definition vsf_eda.h:1491
vsf_err_t vsf_teda_set_timer_ex(vsf_teda_t *pthis, vsf_systimer_tick_t tick)
Set a one-shot timer of the given ticks for the given teda task; the task receives VSF_EVT_TIMER when...
vsf_err_t vsf_callback_timer_add(vsf_callback_timer_t *timer, vsf_systimer_tick_t tick)
Add a callback timer with a relative interval in ticks.
vsf_sync_reason_t vsf_eda_bmpevt_poll(vsf_bmpevt_t *pthis, vsf_bmpevt_pender_t *pender, vsf_evt_t evt)
Retrieve the result of a bitmap event pend from the wakeup event.
vsf_err_t vsf_teda_start(vsf_teda_t *pthis, vsf_eda_cfg_t *cfg)
Start a teda (eda with timer support) task with the given configuration and post VSF_EVT_INIT to it.
uint_fast16_t vsf_eda_queue_get_cnt(vsf_eda_queue_t *pthis)
Get the number of nodes currently held in a queue.
void vsf_eda_set_user_value(uint8_t value)
Set the user-defined bits in the feature of the current eda.
Definition vsf_eda.c:547
vsf_err_t vsf_eda_queue_recv(vsf_eda_queue_t *pthis, void **node, vsf_timeout_tick_t timeout)
Receive a node from a queue, pending while the queue is empty.
void * vsf_eda_get_cur_msg(void)
Get the pointer message carried by the current event (e.g. VSF_EVT_MESSAGE)
Definition vsf_eda.c:466
uint16_t __vsf_eda_flag_word
Definition vsf_eda.h:1685
@ VSF_KERNEL_EVT_QUEUE_SEND_NOTIFY
Definition vsf_eda.h:1609
@ VSF_KERNEL_EVT_CALLBACK_TIMER
Definition vsf_eda.h:1607
@ VSF_KERNEL_EVT_QUEUE_RECV_NOTIFY
Definition vsf_eda.h:1610
@ VSF_KERNEL_EVT_CALLBACK_TIMER_ADD
Definition vsf_eda.h:1608
struct vsf_cpu_usage_ctx_t vsf_cpu_usage_ctx_t
Context for per-task CPU usage sampling; the user provides the ctx storage and must keep it valid unt...
vsf_err_t vsf_teda_set_due_ex(vsf_teda_t *this_ptr, vsf_systimer_tick_t due)
Set a one-shot timer with an absolute due tick for the given teda task.
uint8_t __vsf_eda_feature_word
Definition vsf_eda.h:1684
vsf_eda_t * vsf_eda_get_cur(void)
Get the eda task currently being dispatched.
Definition vsf_eda.c:416
vsf_err_t vsf_callback_timer_add_due_isr(vsf_callback_timer_t *timer, vsf_systimer_tick_t due)
Add a callback timer with an absolute due tick from interrupt context.
vsf_err_t __vsf_eda_go_to_ex(uintptr_t evthandler, uintptr_t param)
Switch the current frame to a new event handler with a target parameter and dispatch VSF_EVT_INIT.
Definition vsf_eda.c:723
vsf_err_t __vsf_eda_sync_decrease_ex(vsf_sync_t *pthis, vsf_timeout_tick_t timeout, vsf_eda_t *eda, bool manual)
Decrease a sync object with an explicit manual-reset flag.
vsf_systimer_tick_t vsf_systimer_get_duration(vsf_systimer_tick_t from_time, vsf_systimer_tick_t to_time)
Get the tick duration between two tick counts, handling wrap-around.
union __vsf_eda_fn_t __vsf_eda_fn_t
vsf_err_t vsf_eda_target_set(uintptr_t param)
Set the target parameter of the current frame of the current task.
Definition vsf_eda.c:601
void vsf_eda_sync_force_reset(vsf_sync_t *pthis)
Force the count of a sync object to 0.
vsf_err_t __vsf_eda_call_eda_ex(uintptr_t func, uintptr_t param, __vsf_eda_frame_state_t state, bool is_sub_call)
Extended sub-call: prepare a frame and dispatch VSF_EVT_INIT.
Definition vsf_eda.c:696
vsf_sync_t vsf_sem_t
Counting semaphore (vsf_sync_t with auto-reset)
Definition vsf_eda.h:2296
vsf_sync_reason_t vsf_eda_queue_send_get_reason(vsf_eda_queue_t *pthis, vsf_evt_t evt, void *node)
Retrieve the result of a queue send from the wakeup event, retrying the enqueue if the resource is ob...
#define VSF_KERNEL_CFG_EDA_USER_BITLEN
Definition vsf_eda.h:88
uintptr_t vsf_irq_enter(void)
Notify the kernel of entering interrupt context.
Definition vsf_eda.c:129
vsf_err_t vsf_eda_queue_send_isr(vsf_eda_queue_t *pthis, void *node)
Send a node to a queue from interrupt context.
vsf_evt_t vsf_eda_get_cur_evt(void)
Get the event currently being processed by the current task.
Definition vsf_eda.c:458
bool vsf_eda_is_stack_owner(vsf_eda_t *pthis)
Check whether an eda owns a dedicated stack.
Definition vsf_eda.c:450
struct vsf_cpu_usage_t vsf_cpu_usage_t
Per-task CPU usage sampling data; points to the user-provided sampling context vsf_cpu_usage_ctx_t.
const vsf_bmpevt_adapter_op_t vsf_eda_bmpevt_adapter_sync_op
Adapter operation table vsf_bmpevt_adapter_op_t used to bind a sync object to a bitmap event.
vsf_err_t __vsf_eda_sync_increase_ex(vsf_sync_t *pthis, vsf_eda_t *eda, bool manual)
Increase a sync object with an explicit manual-reset flag.
vsf_err_t __vsf_eda_call_eda_prepare(uintptr_t evthandler, uintptr_t param, size_t local_size)
Prepare a sub-call frame without dispatching VSF_EVT_INIT.
Definition vsf_eda.c:685
vsf_err_t __vsf_eda_call_eda(uintptr_t evthandler, uintptr_t param, size_t local_size)
Sub-call an event handler: prepare a frame and dispatch VSF_EVT_INIT.
Definition vsf_eda.c:730
vsf_err_t vsf_eda_post_msg(vsf_eda_t *pthis, void *msg)
Post a pointer message to an eda task; the task receives VSF_EVT_MESSAGE and retrieves the pointer wi...
Definition vsf_eda.c:961
vsf_err_t vsf_eda_queue_send_ex(vsf_eda_queue_t *pthis, void *node, vsf_timeout_tick_t timeout, vsf_eda_t *eda)
Send a node to a queue on behalf of the given eda.
void vsf_irq_leave(uintptr_t ctx)
Notify the kernel of leaving interrupt context.
Definition vsf_eda.c:141
vsf_err_t vsf_eda_sync_increase_isr(vsf_sync_t *pthis)
Increase a sync object from interrupt context.
vsf_sync_reason_t vsf_eda_queue_recv_get_reason(vsf_eda_queue_t *pthis, vsf_evt_t evt, void **node)
Retrieve the result of a queue receive from the wakeup event, retrying the dequeue if the resource is...
vsf_err_t vsf_eda_sync_decrease_ex(vsf_sync_t *pthis, vsf_timeout_tick_t timeout, vsf_eda_t *eda)
Decrease a sync object on behalf of the given eda.
void(* vsf_param_eda_evthandler_t)(uintptr_t target, vsf_evt_t evt)
Parameterized event handler; invoked with the user parameter (target) and the event (evt)
Definition vsf_eda.h:1681
bool __vsf_eda_return(uintptr_t return_value)
Return from the current (sub-called) eda with the given return value.
Definition vsf_eda.c:484
vsf_err_t __vsf_teda_cancel_timer(vsf_teda_t *pthis)
Cancel the pending timer of the given teda task.
vsf_sync_reason_t
Result of a sync wait, returned by the *_get_reason() APIs and thread IPC.
Definition vsf_eda.h:2262
@ VSF_SYNC_GET
Obtained.
Definition vsf_eda.h:2282
@ VSF_SYNC_FAIL
Failed/error.
Definition vsf_eda.h:2267
@ VSF_SYNC_CANCEL
Cancelled.
Definition vsf_eda.h:2287
@ VSF_SYNC_TIMEOUT
Timed out.
Definition vsf_eda.h:2272
@ VSF_SYNC_PENDING
Still waiting, retry.
Definition vsf_eda.h:2277
vsf_err_t vsf_eda_queue_send(vsf_eda_queue_t *pthis, void *node, vsf_timeout_tick_t timeout)
Send a node to a queue, pending while the queue is full.
vsf_err_t vsf_callback_timer_remove(vsf_callback_timer_t *timer)
Remove a callback timer before it expires.
vsf_err_t vsf_eda_sync_increase_ex(vsf_sync_t *pthis, vsf_eda_t *eda)
Increase a sync object on behalf of the given eda (e.g. the owner of a mutex)
void vsf_eda_sync_cancel(vsf_sync_t *pthis)
Cancel all pending tasks on a sync object; they are woken with VSF_EVT_SYNC_CANCEL.
vsf_prio_t __vsf_eda_get_cur_priority(vsf_eda_t *pthis)
Definition vsf_evtq_list.c:77
vsf_err_t __vsf_eda_set_priority(vsf_eda_t *pthis, vsf_prio_t priority)
Definition vsf_evtq_list.c:84
#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
Kernel priority enumeration.
Definition vsf_kernel_common.h:55
uint8_t state
Definition vsf_msg_tree.h:247
Generated from commit: vsfteam/vsf@a5104db