From ff9c7766edded74f4d522484c828b1bdc7dfa96d Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 9 Jan 2021 23:31:28 +0100 Subject: Let's make a procfs for IPC instead --- kernel/features/event.c | 61 ------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 kernel/features/event.c (limited to 'kernel/features/event.c') diff --git a/kernel/features/event.c b/kernel/features/event.c deleted file mode 100644 index c9bd3a4..0000000 --- a/kernel/features/event.c +++ /dev/null @@ -1,61 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#include -#include -#include -#include -#include -#include -#include - -static struct list *event_table[] = { [EVENT_KEYBOARD] = NULL, [EVENT_MOUSE] = NULL }; - -u32 event_register(u32 id, struct proc *proc) -{ - assert(id < sizeof(event_table) / sizeof(*event_table)); - - if (event_table[id] == NULL) - event_table[id] = (struct list *)list_new(); - - struct event_descriptor *desc = malloc(sizeof(*desc)); - desc->id = id; - desc->proc = proc; - - list_add(event_table[id], (void *)desc); - return 0; -} - -void event_unregister(u32 id, struct proc *proc) -{ - assert(id < sizeof(event_table) / sizeof(*event_table)); - - struct event_descriptor desc; - desc.id = id; - desc.proc = proc; - - struct node *iterator = event_table[id]->head; - while (iterator != NULL) { - struct event_descriptor *desc_comp = iterator->data; - if (desc_comp->id == desc.id && desc_comp->proc == desc.proc) - list_remove(event_table[id], iterator); - iterator = iterator->next; - } -} - -u32 event_trigger(u32 id, void *data) -{ - assert(id < sizeof(event_table) / sizeof(*event_table)); - - if (!event_table[id] || !event_table[id]->head) { - printf("Event %d not mapped!\n", id); - return 1; - } - - struct node *iterator = event_table[id]->head; - while (iterator != NULL) { - proc_send(kernel_proc, ((struct event_descriptor *)iterator->data)->proc, id, data); - iterator = iterator->next; - } - - return 0; -} -- cgit v1.2.3