23#if VSF_USE_KERNEL == ENABLED && defined(__EDA_GADGET__)
27#if VSF_EDA_QUEUE_CFG_REGION != ENABLED
28# if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
29# define __vsf_eda_queue_protect vsf_protect(interrupt)
30# define __vsf_eda_queue_unprotect vsf_unprotect(interrupt)
32# define __vsf_eda_queue_protect vsf_protect(scheduler)
33# define __vsf_eda_queue_unprotect vsf_unprotect(scheduler)
36# define vsf_protect_eda_queue_region() pthis->region->enter()
37# define vsf_unprotect_eda_queue_region(__orig) pthis->region->leave(__orig)
38# define __vsf_eda_queue_protect vsf_protect(eda_queue_region)
39# define __vsf_eda_queue_unprotect vsf_unprotect(eda_queue_region)
49#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED && VSF_KERNEL_CFG_SUPPORT_EDA_QUEUE == ENABLED
57 bool is_dequeued =
false;
59#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
60 if (pthis->readable_cnt > 0) {
61 pthis->readable_cnt--;
63 if (pthis->cur_union.cur_value > 0) {
65 pthis->cur_union.cur_value--;
66 pthis->op.dequeue(pthis, node);
69 __vsf_eda_queue_unprotect(origlevel);
73#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
74# define __vsf_eda_queue_enqueue(__queue, __node, __readable) \
75 ____vsf_eda_queue_enqueue((__queue), (__node), (__readable))
78static
bool ____vsf_eda_queue_enqueue(
vsf_eda_queue_t *pthis,
void *node,
bool readable)
80# define __vsf_eda_queue_enqueue(__queue, __node, __readable) \
81 ____vsf_eda_queue_enqueue((__queue), (__node))
84static
bool ____vsf_eda_queue_enqueue(
vsf_eda_queue_t *pthis,
void *node)
87 bool is_enqueued =
false;
89 if (pthis->cur_union.cur_value < pthis->max_union.max_value) {
90 pthis->cur_union.cur_value++;
91#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
93 pthis->readable_cnt++;
96 pthis->op.enqueue(pthis, node);
99 __vsf_eda_queue_unprotect(origlevel);
107#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
108 __vsf_eda_sync_get_eda_pending(&pthis->use_as__vsf_sync_t)
116#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
117 pthis->tx_processing =
true;
119 pthis->eda_tx =
NULL;
122 pthis->eda_rx =
NULL;
123#if VSF_KERNEL_CFG_QUEUE_HAS_RX_NOTIFIED == ENABLED
124 pthis->rx_notified =
true;
128 eda->flag.state.is_sync_got =
true;
133#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
135 pthis->tx_processing =
false;
146#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
147 pthis->tx_processing =
false;
149 pthis->eda_rx =
NULL;
150#if VSF_EDA_QUEUE_CFG_REGION == ENABLED
151 if (
NULL == pthis->region) {
155#if VSF_KERNEL_CFG_QUEUE_HAS_RX_NOTIFIED == ENABLED
156 pthis->rx_notified =
false;
158#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
159 pthis->readable_cnt = 0;
169 bool is_enqueued = __vsf_eda_queue_enqueue(pthis, node,
true);
172 __vsf_eda_queue_notify(pthis,
false, origlevel);
196 bool is_enqueued = __vsf_eda_queue_enqueue(pthis, node,
true);
199 __vsf_eda_queue_notify(pthis,
false, origlevel);
201#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
203 if (
sync->cur_union.cur_value <
sync->max) {
204 __vsf_eda_queue_notify(pthis,
true, origlevel);
207 pthis->tx_processing =
false;
227 bool is_dequeued = __vsf_eda_queue_dequeue(pthis, node);
230#if VSF_KERNEL_CFG_QUEUE_MULTI_TX_EN == ENABLED
231 if (!pthis->tx_processing) {
232 __vsf_eda_queue_notify(pthis,
true, origlevel);
238 __vsf_eda_queue_notify(pthis,
true, origlevel);
244 pthis->eda_rx = __vsf_eda_sync_set_timeout(eda,
timeout);
263 bool is_dequeued = __vsf_eda_queue_dequeue(pthis, node);
266#if VSF_KERNEL_CFG_QUEUE_HAS_RX_NOTIFIED == ENABLED
267 pthis->rx_notified =
false;
269 __vsf_eda_queue_notify(pthis,
true, origlevel);
277 pthis->eda_rx =
NULL;
287 cnt = pthis->cur_union.cur_value;
288 __vsf_eda_queue_unprotect(origlevel);
296 if (pthis->eda_rx !=
NULL) {
298 pthis->eda_rx =
NULL;
303#if VSF_EDA_QUEUE_CFG_SUPPORT_ISR == ENABLED
310 pthis->readable_cnt++;
311 __vsf_eda_queue_unprotect(origlevel);
322 if (!__vsf_eda_queue_enqueue(pthis, node,
false)) {
333 if (!__vsf_eda_queue_dequeue(pthis, node)) {
#define VSF_CAL_SECTION(__SEC_STR)
Definition __compiler.h:189
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
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
Base sync IPC object; sem/mutex/trig/crit are built on it.
Definition vsf_eda.h:1964
__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
Definition vsf_arch_abstraction.h:61
void sync(void)
Definition vsf_linux_fs.c:2266
uintalu_t vsf_protect_t
Definition vsf_arch_abstraction.h:60
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
vsf_err_t __vsf_eda_post_evt_ex(vsf_eda_t *pthis, vsf_evt_t evt, bool force)
Definition vsf_eda.c:953
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_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_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_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_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.
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
uint_fast16_t vsf_eda_queue_get_cnt(vsf_eda_queue_t *pthis)
Get the number of nodes currently held in a queue.
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.
@ VSF_KERNEL_EVT_QUEUE_SEND_NOTIFY
Definition vsf_eda.h:1609
@ VSF_KERNEL_EVT_QUEUE_RECV_NOTIFY
Definition vsf_eda.h:1610
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...
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_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.
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_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_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.
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_err_t vsf_evtq_post_evt_ex(vsf_eda_t *eda, vsf_evt_t evt, bool force)
Post an event to the event queue of the target eda, with force control.
Definition vsf_evtq_list.c:222
#define VSF_KERNEL_ASSERT
Definition vsf_kernel_cfg.h:32
void __vsf_eda_sync_pend(vsf_sync_t *sync, vsf_eda_t *eda, vsf_timeout_tick_t timeout)
#define vsf_protect_region_sched
Definition vsf_os.h:516
#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