void wakeup_queue(wait_queue_t * queue, uint32_t wakeup_flags, bool del) { wait_t *wait; if ((wait = wait_queue_first(queue)) != NULL) { if (del) { do { wakeup_wait(queue, wait, wakeup_flags, 1); } while ((wait = wait_queue_first(queue)) != NULL); } else { do { wakeup_wait(queue, wait, wakeup_flags, 0); } while ((wait = wait_queue_next(queue, wait)) != NULL); } } }
void wakeup_first(wait_queue_t *queue, uint32_t wakeup_flags, bool del) { wait_t *wait; if ((wait = wait_queue_first(queue)) != NULL) { wakeup_wait(queue, wait, wakeup_flags, del); } }
static int recv_event(int *pid_store, int *event_store, timer_t *timer) { bool intr_flag; local_intr_save(intr_flag); wait_queue_t *wait_queue = &(current->event_box.wait_queue); if (wait_queue_empty(wait_queue)) { current->state = PROC_SLEEPING; current->wait_state = WT_EVENT_RECV; ipc_add_timer(timer); local_intr_restore(intr_flag); schedule(); local_intr_save(intr_flag); ipc_del_timer(timer); } int ret = -1; wait_t *wait; if ((wait = wait_queue_first(wait_queue)) != NULL) { struct proc_struct *proc = wait->proc; *pid_store = proc->pid, *event_store = proc->event_box.event, ret = 0; wakeup_wait(wait_queue, wait, WT_EVENT_SEND, 1); } local_intr_restore(intr_flag); return ret; }
static void mc13783_interrupt_thread(void) { uint32_t pending[2]; /* Enable mc13783 GPIO event */ gpio_enable_event(MC13783_EVENT_ID); while (1) { const struct mc13783_event *event, *event_last; wakeup_wait(&mc13783_svc_wake, TIMEOUT_BLOCK); if (mc13783_thread_id == 0) break; mc13783_read_regs(pmic_ints_regs, pending, 2); /* Only clear interrupts being dispatched */ pending[0] &= pmic_int_enabled[0]; pending[1] &= pmic_int_enabled[1]; mc13783_write_regs(pmic_ints_regs, pending, 2); /* Whatever is going to be serviced in this loop has been * acknowledged. Reenable interrupt and if anything was still * pending or became pending again, another signal will be * generated. */ imx31_regset32(&MC13783_GPIO_IMR, 1ul << MC13783_GPIO_LINE); event = mc13783_events; event_last = event + MC13783_NUM_EVENTS; /* .count is surely expected to be > 0 */ do { enum mc13783_event_sets set = event->set; uint32_t pnd = pending[set]; uint32_t mask = event->mask; if (pnd & mask) { event->callback(); pnd &= ~mask; pending[set] = pnd; } if ((pending[0] | pending[1]) == 0) break; /* Terminate early if nothing more to service */ } while (++event < event_last); } gpio_disable_event(MC13783_EVENT_ID); }
static __noinline void __up(semaphore_t *sem, uint32_t wait_state) { bool intr_flag; local_intr_save(intr_flag); { wait_t *wait; if ((wait = wait_queue_first(&(sem->wait_queue))) == NULL) { sem->value ++; } else { assert(wait->proc->wait_state == wait_state); wakeup_wait(&(sem->wait_queue), wait, wait_state, 1); } } local_intr_restore(intr_flag); }
__attribute__ ((noinline)) __up(semaphore_t * sem, uint32_t wait_state) { assert(sem->valid); bool intr_flag; spin_lock_irqsave(&sem->lock, intr_flag); { wait_t *wait; if ((wait = wait_queue_first(&(sem->wait_queue))) == NULL) { sem->value++; } else { assert(wait->proc->wait_state == wait_state); wakeup_wait(&(sem->wait_queue), wait, wait_state, 1); } } spin_unlock_irqrestore(&sem->lock, intr_flag); }
static inline bool wait_for_transfer_complete(void) { return wakeup_wait(&mc13783_spi_wake, HZ*2) == OBJ_WAIT_SUCCEEDED && mc13783_transfer.count == 0; }