The unified diff between revisions [4f22e7ef..] and [9ca449dd..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'event.c'
# # old_revision [4f22e7ef7d3064e3b51a5b868a4722f3f13c747b] # new_revision [9ca449dd7941ad52e33bdcb5c28b2ba35d54219a] # # patch "event.c" # from [a1e88ceaa05efc054e07ea1958e27a871ea460fe] # to [0931d041137bc29648c8785b0198b3712fda631e] # ============================================================ --- event.c a1e88ceaa05efc054e07ea1958e27a871ea460fe +++ event.c 0931d041137bc29648c8785b0198b3712fda631e @@ -1,6 +1,7 @@ #include "event.h" #include "interrupt.h" #include "types.h" +#include "log.h" event_handler *event_handler_table[EVENT_MAX+1]; @@ -13,14 +14,18 @@ unsigned int event_pending[EVENT_WORDS]; #define EVENT_BIT(x) (x%EVENT_WORDLEN) #define EVENT_MASK(x) (1<<EVENT_BIT(x)) +/* + * This function must be called with interrupts disabled. + * This will normally be the case as it is typically called from within + * an interrupt handler anyway. + */ + void event_set(unsigned int event) { if (event > EVENT_MAX) return; - interrupt_block(); event_pending[EVENT_WORD(event)] |= EVENT_MASK(event); - interrupt_unblock(); } static int bitset(unsigned int x) @@ -56,15 +61,21 @@ void event_clear(unsigned int event) interrupt_unblock(); } -void event_dispatch(void) +bool event_dispatch(void) { unsigned int event; if (event_get(&event)) { event_clear(event); - if (event_handler_table[event] != NULL) + if (event_handler_table[event] != NULL) { + log_mark_busy(); (event_handler_table[event])(); + log_mark_idle(); + } + return TRUE; } + + return FALSE; } void event_register(unsigned int event, event_handler *handler)