adi_event_wait immediately unblocks if there are pending amc messages
#include "adi.h"
#include <std/math.h>
#include <kernel/interrupts/pic.h>
+#include <kernel/util/amc/amc_internal.h>
#include <kernel/util/spinlock/spinlock.h>
#include <kernel/multitasking/tasks/task_small.h>
@@ -99,6 +100,12 @@ bool adi_event_await(uint32_t irq) {
return true;
}
+ // If the driver has at least one message to service now, don't block
+ if (amc_service_has_message(amc_service_of_active_task())) {
+ spinlock_release(&s);
+ return false;
+ }
+
// The driver has re-entered its await-event loop
// Await the next interrupt or amc message
task_small_t* task = (task_small_t*)(driver->task);
