diff options
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/event.c | 61 | ||||
-rw-r--r-- | kernel/features/proc.c | 29 | ||||
-rw-r--r-- | kernel/features/syscall.c | 18 |
3 files changed, 0 insertions, 108 deletions
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 <assert.h> -#include <def.h> -#include <event.h> -#include <list.h> -#include <mem.h> -#include <proc.h> -#include <sys.h> - -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; -} diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 08f3b8e..93e97f1 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -82,34 +82,6 @@ struct proc *proc_current(void) return current && current->data ? current->data : NULL; } -void proc_send(struct proc *src, struct proc *dest, u32 type, void *data) -{ - // TODO: Use unique key instead of pid for IPC - if (!src || !dest) - return; - struct proc_message *msg = malloc(sizeof(*msg)); - msg->src = src; - msg->dest = dest; - msg->msg = malloc(sizeof(*msg->msg)); - msg->msg->src = (int)src->pid; - msg->msg->type = (int)type; - msg->msg->data = data; - list_add(dest->messages, msg); - priority_proc = dest; -} - -u32 proc_receive(struct proc *proc, struct message *buf) -{ - if (proc->messages && proc->messages->head) { - struct proc_message *msg = proc->messages->head->data; - list_remove(proc->messages, proc->messages->head); - memcpy(buf, msg->msg, sizeof(*buf)); - return 1; - } else { - return 0; - } -} - struct proc *proc_from_pid(u32 pid) { struct node *iterator = proc_list->head; @@ -157,7 +129,6 @@ struct proc *proc_make(void) { struct proc *proc = malloc(sizeof(*proc)); proc->pid = current_pid++; - proc->messages = list_new(); proc->state = PROC_RUNNING; if (current) diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index a6bfb2a..bb174a1 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -1,7 +1,6 @@ // MIT License, Copyright (c) 2020 Marvin Borner #include <cpu.h> -#include <event.h> #include <fs.h> #include <interrupts.h> #include <load.h> @@ -74,23 +73,6 @@ void syscall_handler(struct regs *r) r->eax = timer_get(); break; } - case SYS_REGISTER: { - event_register(r->ebx, proc_current()); - break; - } - case SYS_UNREGISTER: { - event_unregister(r->ebx, proc_current()); - break; - } - case SYS_SEND: { - proc_send(proc_current(), proc_from_pid(r->ebx), r->ecx, (void *)r->edx); - proc_yield(r); - break; - } - case SYS_RECEIVE: { - r->eax = proc_receive(proc_current(), (void *)r->ebx); - break; - } case SYS_GETPID: { r->eax = proc_current()->pid; break; |