summaryrefslogtreecommitdiff
path: root/firmware/kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r--firmware/kernel.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c
index da3ddf5ca7..f408c77bae 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -35,3 +35,30 @@ void yield(void)
35{ 35{
36 switch_thread(); 36 switch_thread();
37} 37}
38
39/****************************************************************************
40 * Queue handling stuff
41 ****************************************************************************/
42void queue_init(struct event_queue *q)
43{
44 q->read = 0;
45 q->write = 0;
46}
47
48struct event *queue_wait(struct event_queue *q)
49{
50 while(q->read == q->write)
51 {
52 switch_thread();
53 }
54
55 return &q->events[(q->read++) & QUEUE_LENGTH_MASK];
56}
57
58void queue_post(struct event_queue *q, int id, void *data)
59{
60 int wr = (q->write++) & QUEUE_LENGTH_MASK;
61
62 q->events[wr].id = id;
63 q->events[wr].data = data;
64}