/** INTERNAL * * This function is capable of supporting invocations from both a fiber and an * ISR context. However, the nano_isr_lifo_put and nano_fiber_lifo_put aliases * are created to support any required implementation differences in the future * without introducing a source code migration issue. */ void _lifo_put_non_preemptible(struct nano_lifo *lifo, void *data) { tCCS *ccs; unsigned int imask; imask = irq_lock_inline(); ccs = _nano_wait_q_remove(&lifo->wait_q); if (ccs) { _nano_timeout_abort(ccs); fiberRtnValueSet(ccs, (unsigned int) data); } else { *(void **) data = lifo->list; lifo->list = data; } irq_unlock_inline(imask); }
void nano_task_lifo_put(struct nano_lifo *lifo, void *data) { struct tcs *tcs; unsigned int imask; imask = irq_lock(); tcs = _nano_wait_q_remove(&lifo->wait_q); if (tcs) { _nano_timeout_abort(tcs); fiberRtnValueSet(tcs, (unsigned int) data); _Swap(imask); return; } *(void **) data = lifo->list; lifo->list = data; irq_unlock(imask); }
/** * * @brief Push data onto a stack (no context switch) * * This routine pushes a data item onto a stack object; it may be called from * either a fiber or ISR context. A fiber pending on the stack object will be * made ready, but will NOT be scheduled to execute. * * @param stack Stack on which to interact * @param data Data to push on stack * @return N/A * * @internal * This function is capable of supporting invocations from both a fiber and an * ISR context. However, the nano_isr_stack_push and nano_fiber_stack_push * aliases are created to support any required implementation differences in * the future without introducing a source code migration issue. * @endinternal */ void _stack_push_non_preemptible(struct nano_stack *stack, uint32_t data) { struct tcs *tcs; unsigned int imask; imask = irq_lock(); tcs = stack->fiber; if (tcs) { stack->fiber = 0; fiberRtnValueSet(tcs, data); _nano_fiber_ready(tcs); } else { *(stack->next) = data; stack->next++; } irq_unlock(imask); }
void nano_task_stack_push(struct nano_stack *stack, uint32_t data) { struct tcs *tcs; unsigned int imask; imask = irq_lock(); tcs = stack->fiber; if (tcs) { stack->fiber = 0; fiberRtnValueSet(tcs, data); _nano_fiber_ready(tcs); _Swap(imask); return; } *(stack->next) = data; stack->next++; irq_unlock(imask); }