diff options
author | Marvin Borner | 2020-08-22 13:20:40 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-22 13:20:40 +0200 |
commit | 00a64ff4675b4c1e22d6b4856e1f6b7c04ed96d8 (patch) | |
tree | e4f2e6df5750fc6b7334c35ee3d8554cd4b303ce /kernel/features/event.c | |
parent | 593c80e99342df5e1147b3c0fc893f77ec6f00d5 (diff) |
Added proc event list
Diffstat (limited to 'kernel/features/event.c')
-rw-r--r-- | kernel/features/event.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/features/event.c b/kernel/features/event.c index 9bcce6d..e0a7d93 100644 --- a/kernel/features/event.c +++ b/kernel/features/event.c @@ -24,10 +24,11 @@ u32 event_map(enum event id, struct proc *proc, u32 *func) } while ((iterator = iterator->next) != NULL); struct event_descriptor *desc = malloc(sizeof(*desc)); + desc->id = id; desc->func = func; desc->proc = proc; - list_add((struct list *)event_table[id], (void *)desc); + list_add(event_table[id], (void *)desc); return 0; } @@ -36,9 +37,10 @@ void event_unmap(enum event id, struct proc *proc, u32 *func) assert(id < sizeof(event_table) / sizeof(*event_table)); assert(func); - struct list *list = ((struct list *)event_table[id]); + struct list *list = event_table[id]; struct event_descriptor *desc = malloc(sizeof(*desc)); + desc->id = id; desc->func = func; desc->proc = proc; @@ -49,21 +51,24 @@ void event_unmap(enum event id, struct proc *proc, u32 *func) } while ((iterator = iterator->next) != NULL); } -u32 event_trigger(enum event id, u32 *data) +u32 event_trigger(enum event id, void *data) { (void)data; assert(id < sizeof(event_table) / sizeof(*event_table)); - struct node *iterator = ((struct list *)event_table[id])->head; + struct node *iterator = event_table[id]->head; - if (memcmp(event_table[id], 0, sizeof(struct list)) == 0) { + 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; - desc->proc->event = 1 << id; + proc_event->desc = desc; + proc_event->data = data; + list_add(desc->proc->events, proc_event); iterator = iterator->next; if (iterator == NULL) break; |