Lines Matching +full:tx +full:- +full:dummy

4  * SPDX-License-Identifier: Apache-2.0
32 struct _thread_base thread; /* dummy thread object */
52 * Do run-time initialization of mailbox object subsystem.
62 * A dummy thread requires minimal initialization, since it never gets in init_mbox_module()
64 * dummy thread from a real one. The threads are *not* added to the in init_mbox_module()
89 z_waitq_init(&mbox->tx_msg_queue); in k_mbox_init()
90 z_waitq_init(&mbox->rx_msg_queue); in k_mbox_init()
91 mbox->lock = (struct k_spinlock) {}; in k_mbox_init()
110 * @return 0 if successfully matched, otherwise -1.
117 if (((tx_msg->tx_target_thread == (k_tid_t)K_ANY) || in mbox_message_match()
118 (tx_msg->tx_target_thread == rx_msg->tx_target_thread)) && in mbox_message_match()
119 ((rx_msg->rx_source_thread == (k_tid_t)K_ANY) || in mbox_message_match()
120 (rx_msg->rx_source_thread == tx_msg->rx_source_thread))) { in mbox_message_match()
123 rx_msg->rx_source_thread = tx_msg->rx_source_thread; in mbox_message_match()
124 tx_msg->tx_target_thread = rx_msg->tx_target_thread; in mbox_message_match()
127 temp_info = rx_msg->info; in mbox_message_match()
128 rx_msg->info = tx_msg->info; in mbox_message_match()
129 tx_msg->info = temp_info; in mbox_message_match()
132 if (rx_msg->size > tx_msg->size) { in mbox_message_match()
133 rx_msg->size = tx_msg->size; in mbox_message_match()
137 rx_msg->tx_data = tx_msg->tx_data; in mbox_message_match()
140 rx_msg->_syncing_thread = tx_msg->_syncing_thread; in mbox_message_match()
145 return -1; in mbox_message_match()
161 if (rx_msg->_syncing_thread == NULL) { in mbox_message_dispose()
166 sending_thread = rx_msg->_syncing_thread; in mbox_message_dispose()
167 rx_msg->_syncing_thread = NULL; in mbox_message_dispose()
168 tx_msg = (struct k_mbox_msg *)sending_thread->base.swap_data; in mbox_message_dispose()
171 tx_msg->size = rx_msg->size; in mbox_message_dispose()
176 * dummy thread pair, then give semaphore (if needed) in mbox_message_dispose()
178 if ((sending_thread->base.thread_state & _THREAD_DUMMY) != 0U) { in mbox_message_dispose()
179 struct k_sem *async_sem = tx_msg->_async_sem; in mbox_message_dispose()
208 * @return 0 if successful, -ENOMSG if failed immediately, -EAGAIN if timed out
219 tx_msg->rx_source_thread = arch_current_thread(); in mbox_message_put()
221 /* finish readying sending thread (actual or dummy) for send */ in mbox_message_put()
222 sending_thread = tx_msg->_syncing_thread; in mbox_message_put()
223 sending_thread->base.swap_data = tx_msg; in mbox_message_put()
226 key = k_spin_lock(&mbox->lock); in mbox_message_put()
230 _WAIT_Q_FOR_EACH(&mbox->rx_msg_queue, receiving_thread) { in mbox_message_put()
231 rx_msg = (struct k_mbox_msg *)receiving_thread->base.swap_data; in mbox_message_put()
246 * note: dummy sending thread sits (unqueued) in mbox_message_put()
249 if ((sending_thread->base.thread_state & _THREAD_DUMMY) in mbox_message_put()
251 z_reschedule(&mbox->lock, key); in mbox_message_put()
261 int ret = z_pend_curr(&mbox->lock, key, NULL, K_FOREVER); in mbox_message_put()
271 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_mbox, message_put, mbox, timeout, -ENOMSG); in mbox_message_put()
273 k_spin_unlock(&mbox->lock, key); in mbox_message_put()
274 return -ENOMSG; in mbox_message_put()
278 /* asynchronous send: dummy thread waits on tx queue for receiver */ in mbox_message_put()
279 if ((sending_thread->base.thread_state & _THREAD_DUMMY) != 0U) { in mbox_message_put()
280 z_pend_thread(sending_thread, &mbox->tx_msg_queue, K_FOREVER); in mbox_message_put()
281 k_spin_unlock(&mbox->lock, key); in mbox_message_put()
287 /* synchronous send: sender waits on tx queue for receiver or timeout */ in mbox_message_put()
288 int ret = z_pend_curr(&mbox->lock, key, &mbox->tx_msg_queue, timeout); in mbox_message_put()
299 tx_msg->_syncing_thread = arch_current_thread(); in k_mbox_put()
324 async->thread.prio = arch_current_thread()->base.prio; in k_mbox_async_put()
326 async->tx_msg = *tx_msg; in k_mbox_async_put()
327 async->tx_msg._syncing_thread = (struct k_thread *)&async->thread; in k_mbox_async_put()
328 async->tx_msg._async_sem = sem; in k_mbox_async_put()
330 (void)mbox_message_put(mbox, &async->tx_msg, K_FOREVER); in k_mbox_async_put()
339 rx_msg->size = 0; in k_mbox_data_get()
345 if ((rx_msg->tx_data != NULL) && (rx_msg->size > 0U)) { in k_mbox_data_get()
346 (void)memcpy(buffer, rx_msg->tx_data, rx_msg->size); in k_mbox_data_get()
372 } else if (rx_msg->size == 0U) { in mbox_message_data_check()
391 rx_msg->tx_target_thread = arch_current_thread(); in k_mbox_get()
393 /* search mailbox's tx queue for a compatible sender */ in k_mbox_get()
394 key = k_spin_lock(&mbox->lock); in k_mbox_get()
398 _WAIT_Q_FOR_EACH(&mbox->tx_msg_queue, sending_thread) { in k_mbox_get()
399 tx_msg = (struct k_mbox_msg *)sending_thread->base.swap_data; in k_mbox_get()
402 /* take sender out of mailbox's tx queue */ in k_mbox_get()
405 k_spin_unlock(&mbox->lock, key); in k_mbox_get()
418 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_mbox, get, mbox, timeout, -ENOMSG); in k_mbox_get()
421 k_spin_unlock(&mbox->lock, key); in k_mbox_get()
422 return -ENOMSG; in k_mbox_get()
428 arch_current_thread()->base.swap_data = rx_msg; in k_mbox_get()
429 result = z_pend_curr(&mbox->lock, key, &mbox->rx_msg_queue, timeout); in k_mbox_get()