diff options
author | Marvin Borner | 2020-08-24 12:21:23 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-24 12:21:23 +0200 |
commit | 0a4c8dd2d6048fe9851b8d92a311bba7aaa83a57 (patch) | |
tree | 5e1e235f4ff22b3233f43db768ddd373f6063856 /kernel/features/event.c | |
parent | 0e05b395cb8868b77d91d9d614ff5ae09b3b853a (diff) |
Removed async events
Diffstat (limited to 'kernel/features/event.c')
-rw-r--r-- | kernel/features/event.c | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/kernel/features/event.c b/kernel/features/event.c index e0a7d93..5436ef5 100644 --- a/kernel/features/event.c +++ b/kernel/features/event.c @@ -10,69 +10,50 @@ struct list *event_table[] = { [EVENT_KEYBOARD] = NULL, [EVENT_MOUSE] = NULL }; -u32 event_map(enum event id, struct proc *proc, u32 *func) +u32 event_register(enum message_type id, struct proc *proc) { assert(id < sizeof(event_table) / sizeof(*event_table)); - assert(func); if (event_table[id] == NULL) event_table[id] = (struct list *)list_new(); - struct node *iterator = event_table[id]->head; - do { - assert(((struct event_descriptor *)iterator->data)->func != func); - } while ((iterator = iterator->next) != NULL); - struct event_descriptor *desc = malloc(sizeof(*desc)); desc->id = id; - desc->func = func; desc->proc = proc; list_add(event_table[id], (void *)desc); return 0; } -void event_unmap(enum event id, struct proc *proc, u32 *func) +void event_unregister(enum message_type id, struct proc *proc) { assert(id < sizeof(event_table) / sizeof(*event_table)); - assert(func); - - struct list *list = event_table[id]; struct event_descriptor *desc = malloc(sizeof(*desc)); desc->id = id; - desc->func = func; desc->proc = proc; - struct node *iterator = list->head; + struct node *iterator = event_table[id]->head; do { - if (memcmp(iterator->data, desc, sizeof(*desc)) == 0) - list_remove(list, iterator); + struct event_descriptor *desc_comp = iterator->data; + if (desc_comp->id == desc->id && desc_comp->proc == desc->proc) + list_remove(event_table[id], iterator); } while ((iterator = iterator->next) != NULL); } -u32 event_trigger(enum event id, void *data) +u32 event_trigger(enum message_type id, void *data) { - (void)data; assert(id < sizeof(event_table) / sizeof(*event_table)); - struct node *iterator = event_table[id]->head; - if (memcmp(event_table[id], 0, sizeof(struct list)) == 0 || !event_table[id]->head) { printf("Event %d not mapped!\n", id); return 1; } - while (1) { - struct proc_event *proc_event = malloc(sizeof(*proc_event)); - struct event_descriptor *desc = iterator->data; - proc_event->desc = desc; - proc_event->data = data; - list_add(desc->proc->events, proc_event); - iterator = iterator->next; - if (iterator == NULL) - break; - } + struct node *iterator = event_table[id]->head; + do { + proc_send(kernel_proc, ((struct event_descriptor *)iterator->data)->proc, id, data); + } while ((iterator = iterator->next) != NULL); return 0; } |