diff options
author | Marvin Borner | 2020-08-17 14:15:58 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-17 14:15:58 +0200 |
commit | ccbf380a850babc01ad2dfd4dcfca9ae44447161 (patch) | |
tree | f1eacdbc1e8fe5322f49e1fa419a9f985bb0f778 /kernel/features/event.c | |
parent | ca7d400b7705ba887df69391cb774d4de83e8bf3 (diff) |
Added event descriptor
Diffstat (limited to 'kernel/features/event.c')
-rw-r--r-- | kernel/features/event.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/kernel/features/event.c b/kernel/features/event.c index 8bdba1a..02f5f1d 100644 --- a/kernel/features/event.c +++ b/kernel/features/event.c @@ -2,7 +2,10 @@ #include <assert.h> #include <def.h> +#include <event.h> #include <list.h> +#include <mem.h> +#include <proc.h> #include <sys.h> struct list *event_table[] = { [EVENT_KEYBOARD] = NULL, [EVENT_MOUSE] = NULL }; @@ -15,7 +18,12 @@ u32 event_map(enum event id, u32 *func) if (event_table[id] == NULL) event_table[id] = (struct list *)list_new(); - list_add((struct list *)event_table[id], (void *)func); + + struct event_descriptor *desc = malloc(sizeof(*desc)); + desc->func = func; + desc->proc = proc_current(); + + list_add((struct list *)event_table[id], (void *)desc); return 0; } @@ -23,8 +31,13 @@ u32 event_map(enum event id, u32 *func) void event_unmap(enum event id, u32 *func) { struct list *list = ((struct list *)event_table[id]); + + struct event_descriptor *desc = malloc(sizeof(*desc)); + desc->func = func; + desc->proc = proc_current(); + struct node *iterator = list->head; - while (iterator->data != (void *)func) { + while (memcmp(iterator->data, (void *)desc, sizeof(*desc)) == 0) { iterator = iterator->next; if (!iterator) return; @@ -45,7 +58,8 @@ u32 event_trigger(enum event id, u32 *data) } while (1) { - u32 *func = iterator->data; + struct event_descriptor *desc = iterator->data; + desc->proc->event = 1 << id; iterator = iterator->next; if (iterator == NULL) break; |