diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/kernel.h | 1 | ||||
-rw-r--r-- | firmware/kernel.c | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index a72e004b33..041f846380 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h | |||
@@ -219,6 +219,7 @@ extern void queue_reply(struct event_queue *q, intptr_t retval); | |||
219 | extern bool queue_in_queue_send(struct event_queue *q); | 219 | extern bool queue_in_queue_send(struct event_queue *q); |
220 | #endif /* HAVE_EXTENDED_MESSAGING_AND_NAME */ | 220 | #endif /* HAVE_EXTENDED_MESSAGING_AND_NAME */ |
221 | extern bool queue_empty(const struct event_queue* q); | 221 | extern bool queue_empty(const struct event_queue* q); |
222 | extern bool queue_peek(struct event_queue *q, struct queue_event *ev); | ||
222 | extern void queue_clear(struct event_queue* q); | 223 | extern void queue_clear(struct event_queue* q); |
223 | extern void queue_remove_from_head(struct event_queue *q, long id); | 224 | extern void queue_remove_from_head(struct event_queue *q, long id); |
224 | extern int queue_count(const struct event_queue *q); | 225 | extern int queue_count(const struct event_queue *q); |
diff --git a/firmware/kernel.c b/firmware/kernel.c index 006a06dfe0..25249c6148 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -537,6 +537,28 @@ bool queue_empty(const struct event_queue* q) | |||
537 | return ( q->read == q->write ); | 537 | return ( q->read == q->write ); |
538 | } | 538 | } |
539 | 539 | ||
540 | bool queue_peek(struct event_queue *q, struct queue_event *ev) | ||
541 | { | ||
542 | if (q->read == q->write) | ||
543 | return false; | ||
544 | |||
545 | bool have_msg = false; | ||
546 | |||
547 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
548 | corelock_lock(&q->cl); | ||
549 | |||
550 | if (q->read != q->write) | ||
551 | { | ||
552 | *ev = q->events[q->read & QUEUE_LENGTH_MASK]; | ||
553 | have_msg = true; | ||
554 | } | ||
555 | |||
556 | corelock_unlock(&q->cl); | ||
557 | set_irq_level(oldlevel); | ||
558 | |||
559 | return have_msg; | ||
560 | } | ||
561 | |||
540 | void queue_clear(struct event_queue* q) | 562 | void queue_clear(struct event_queue* q) |
541 | { | 563 | { |
542 | int oldlevel; | 564 | int oldlevel; |