summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/kernel.h1
-rw-r--r--firmware/kernel.c22
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);
extern bool queue_in_queue_send(struct event_queue *q);
#endif /* HAVE_EXTENDED_MESSAGING_AND_NAME */
extern bool queue_empty(const struct event_queue* q);
+extern bool queue_peek(struct event_queue *q, struct queue_event *ev);
extern void queue_clear(struct event_queue* q);
extern void queue_remove_from_head(struct event_queue *q, long id);
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)
return ( q->read == q->write );
}
+bool queue_peek(struct event_queue *q, struct queue_event *ev)
+{
+ if (q->read == q->write)
+ return false;
+
+ bool have_msg = false;
+
+ int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
+ corelock_lock(&q->cl);
+
+ if (q->read != q->write)
+ {
+ *ev = q->events[q->read & QUEUE_LENGTH_MASK];
+ have_msg = true;
+ }
+
+ corelock_unlock(&q->cl);
+ set_irq_level(oldlevel);
+
+ return have_msg;
+}
+
void queue_clear(struct event_queue* q)
{
int oldlevel;