diff options
author | Marvin Borner | 2020-08-16 17:13:32 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-16 17:13:32 +0200 |
commit | 0dd3f5e6f4f7607611ce23510858ab3597b5df9f (patch) | |
tree | 19fa08636168489fa097dea675ef38a27d913d4d /kernel/features/event.c | |
parent | 36e36fae364dec02999f58edbe997780d901b674 (diff) |
Added events and map syscall
Diffstat (limited to 'kernel/features/event.c')
-rw-r--r-- | kernel/features/event.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/kernel/features/event.c b/kernel/features/event.c new file mode 100644 index 0000000..e91dcab --- /dev/null +++ b/kernel/features/event.c @@ -0,0 +1,32 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#include <assert.h> +#include <def.h> +#include <sys.h> + +u32 (*event_table[])() = { [EVENT_KEYBOARD] = NULL, [EVENT_MOUSE] = NULL }; + +u32 event_map(enum event id, u32 (*function)()) +{ + printf("%x to %x\n", id, function); + if (id >= sizeof(event_table) / sizeof(*event_table)) + return -1; + + event_table[id] = function; + return 0; +} + +u32 event_trigger(enum event id, u32 *data) +{ + assert(id < sizeof(event_table) / sizeof(*event_table)); + + u32 (*location)(u32 *) = event_table[id]; + if (!location) { + printf("Event %d not mapped!\n", id); + return -1; + } + + // TODO: Execute event function in ring3 with process stack, ... + location(data); + return 0; +} |