23#if VSF_USE_KERNEL == ENABLED && defined(__EDA_GADGET__)
38#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
47 eda = __vsf_eda_get_valid_eda(eda);
50#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
51 eda->flag.state.is_limitted =
true;
52# ifdef __VSF_OS_CFG_EVTQ_LIST
57 eda->flag.state.is_to_set_due =
true;
63 #ifndef WEAK_VSF_KERNEL_ERR_REPORT
76 eda = __vsf_eda_get_valid_eda(eda);
84 __vsf_eda_sync_set_timeout(eda,
timeout);
99#if __IS_COMPILER_LLVM__ || __IS_COMPILER_ARM_COMPILER_6__
100# pragma clang diagnostic push
101# pragma clang diagnostic ignored "-Wcast-align"
104#if __IS_COMPILER_GCC__
105# pragma GCC diagnostic push
106# pragma GCC diagnostic ignored "-Wcast-align"
120#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
123 if (eda->flag.state.is_sync_got) {
142 eda->flag.state.is_sync_got =
false;
149 eda->flag.state.is_limitted =
false;
153#if __IS_COMPILER_LLVM__ || __IS_COMPILER_ARM_COMPILER_6__
154# pragma clang diagnostic pop
156#if __IS_COMPILER_GCC__
157# pragma GCC diagnostic pop
165 pthis->cur_union.cur_value = cur;
166 pthis->max_union.max_value =
max;
168 if (pthis->cur_union.bits.has_owner) {
174#if VSF_SYNC_CFG_SUPPORT_ISR == ENABLED
192 if (pthis->cur_union.bits.cur >= pthis->max_union.bits.max) {
196 pthis->cur_union.bits.cur++;
197#if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
198 if (pthis->cur_union.bits.has_owner) {
199 eda = __vsf_eda_get_valid_eda(eda);
204 if (eda->cur_priority != eda->priority) {
206 }
else if (eda->flag.state.is_new_prio) {
210 eda->flag.state.is_new_prio =
false;
220 if (pthis->cur_union.bits.cur > 0) {
221 eda_pending = __vsf_eda_sync_get_eda_pending(pthis);
222 if (eda_pending !=
NULL) {
223 eda_pending->flag.state.is_sync_got =
true;
225 pthis->cur_union.bits.cur--;
227#if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
228 if (pthis->cur_union.bits.has_owner) {
235 if (eda_pending !=
NULL) {
268 pthis->cur_union.bits.cur = 0;
279 eda = __vsf_eda_get_valid_eda(eda);
284 pthis->cur_union.bits.cur--;
286#if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
287 if (pthis->cur_union.bits.has_owner) {
297#if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
298 if (pthis->cur_union.bits.has_owner) {
303 &pthis->pending_list,
305 _->cur_priority < cur_priority);
306 __vsf_eda_sync_set_timeout(eda,
timeout);
312#if VSF_KERNEL_CFG_SUPPORT_DYNAMIC_PRIOTIRY == ENABLED
313 if (pthis->cur_union.bits.has_owner) {
316 if (eda->cur_priority > eda_owner->cur_priority) {
348 eda = __vsf_eda_sync_get_eda_pending(pthis);
350 eda->flag.state.is_sync_got =
true;
356 }
while (eda !=
NULL);
362 return __vsf_eda_sync_get_reason(pthis, evt,
true);
#define VSF_CAL_SECTION(__SEC_STR)
Definition __compiler.h:189
#define VSF_UNUSED_PARAM(__VAL)
Definition __type.h:190
vsf_err_t
Definition __type.h:42
@ VSF_ERR_NONE
none error
Definition __type.h:44
@ VSF_ERR_NOT_READY
service not ready yet
Definition __type.h:43
@ VSF_ERR_OVERRUN
overrun
Definition __type.h:60
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
__le16 timeout
Definition ieee80211.h:94
#define NULL
Definition lvgl.h:26
#define max(x, y)
Definition minmax.h:12
unsigned short uint_fast16_t
Definition stdint.h:25
void sync(void)
Definition vsf_linux_fs.c:2266
uintalu_t vsf_protect_t
Definition vsf_arch_abstraction.h:60
vsf_eda_t * vsf_eda_get_cur(void)
Get the eda task currently being dispatched.
Definition vsf_eda.c:416
vsf_err_t __vsf_os_evtq_set_priority(vsf_evtq_t *pthis, vsf_prio_t priority)
Definition vsf_os.c:345
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_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force)
Definition vsf_eda.c:953
void vsf_kernel_err_report(enum vsf_kernel_error_t err)
Report a kernel error.
Definition vsf_eda.c:409
int16_t vsf_evt_t
Kernel event type.
Definition vsf_eda.h:1658
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.
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.
vsf_err_t vsf_eda_sync_increase(vsf_sync_t *pthis)
Increase a sync object, waking up the pending tasks if any.
@ 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_TIMER
teda timer expired (only for teda tasks)
Definition vsf_eda.h:1569
@ VSF_KERNEL_ERR_EDA_DOES_NOT_SUPPORT_TIMER
Timer service used on an eda without timer support.
Definition vsf_eda.h:2375
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.
vsf_systimer_tick_t vsf_systimer_get_tick(void)
Get the current system timer tick count.
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_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.
void vsf_eda_sync_force_reset(vsf_sync_t *pthis)
Force the count of a sync object to 0.
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_sync_increase_isr(vsf_sync_t *pthis)
Increase a sync object from interrupt context.
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.
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_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_ASSERT
Definition vsf_kernel_cfg.h:32
vsf_prio_t
Kernel priority enumeration.
Definition vsf_kernel_common.h:55
void __vsf_eda_sync_pend(vsf_sync_t *sync, vsf_eda_t *eda, vsf_timeout_tick_t timeout)
#define vsf_dlist_insert( __host_type, __member, __list_ptr, __item_ptr, __cond)
Definition vsf_list.h:769
#define vsf_dlist_queue_dequeue(__host_type, __member, __list_ptr, __item_ref_ptr)
Definition vsf_list.h:859
#define vsf_dlist_remove( __host_type, __member, __list_ptr, __item_ptr)
Definition vsf_list.h:810
#define vsf_dlist_is_empty(__list_ptr)
Definition vsf_list.h:705
#define vsf_dlist_init(__list_ptr)
Definition vsf_list.h:702
#define vsf_dlist_queue_enqueue(__host_type, __member, __list_ptr, __item_ptr)
Definition vsf_list.h:852
#define vsf_protect_sched()
Lock the scheduler and return the previous status as vsf_protect_t.
Definition vsf_os.h:271
#define vsf_unprotect_sched(__prot)
Restore the scheduler lock status saved by vsf_protect_sched()
Definition vsf_os.h:283
vsf_evtq_t * __vsf_os_evtq_get(vsf_prio_t priority)
Definition vsf_os.c:328