From 11490a493511c4f760af74c12cb7da15b2b404a2 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 16 Sep 2020 21:38:19 +0200 Subject: Added *very* basic keymap parsing --- kernel/features/event.c | 6 +++--- kernel/features/proc.c | 5 +++-- kernel/features/syscall.c | 5 +++++ kernel/inc/event.h | 8 ++++---- kernel/inc/proc.h | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) (limited to 'kernel') diff --git a/kernel/features/event.c b/kernel/features/event.c index 1aa0cd0..633f633 100644 --- a/kernel/features/event.c +++ b/kernel/features/event.c @@ -10,7 +10,7 @@ struct list *event_table[] = { [EVENT_KEYBOARD] = NULL, [EVENT_MOUSE] = NULL }; -u32 event_register(enum message_type id, struct proc *proc) +u32 event_register(u32 id, struct proc *proc) { assert(id < sizeof(event_table) / sizeof(*event_table)); @@ -25,7 +25,7 @@ u32 event_register(enum message_type id, struct proc *proc) return 0; } -void event_unregister(enum message_type id, struct proc *proc) +void event_unregister(u32 id, struct proc *proc) { assert(id < sizeof(event_table) / sizeof(*event_table)); @@ -42,7 +42,7 @@ void event_unregister(enum message_type id, struct proc *proc) } } -u32 event_trigger(enum message_type id, void *data) +u32 event_trigger(u32 id, void *data) { assert(id < sizeof(event_table) / sizeof(*event_table)); diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 3f8dcf1..7544b68 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -83,10 +83,11 @@ struct proc *proc_current() return current && current->data ? current->data : NULL; } -void proc_send(struct proc *src, struct proc *dest, enum message_type type, void *data) +void proc_send(struct proc *src, struct proc *dest, u32 type, void *data) { // TODO: Use unique key instead of pid for IPC messaging - assert(src && dest); + if (!src || !dest) + return; struct proc_message *msg = malloc(sizeof(*msg)); msg->src = src; msg->dest = dest; diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index 25770a4..f6e3f15 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -100,6 +100,11 @@ void syscall_handler(struct regs *r) r->eax = (u32)(msg ? msg->msg : NULL); break; } + case SYS_GETPID: { + printf("getpid\n"); + r->eax = proc_current()->pid; + break; + } default: { printf("unknown\n"); loop(); diff --git a/kernel/inc/event.h b/kernel/inc/event.h index 89c3e56..59a0df1 100644 --- a/kernel/inc/event.h +++ b/kernel/inc/event.h @@ -8,12 +8,12 @@ #include struct event_descriptor { - enum message_type id; + u32 id; struct proc *proc; }; -u32 event_register(enum message_type id, struct proc *proc); -void event_unregister(enum message_type id, struct proc *proc); -u32 event_trigger(enum message_type id, void *data); +u32 event_register(u32 id, struct proc *proc); +void event_unregister(u32 id, struct proc *proc); +u32 event_trigger(u32 id, void *data); #endif diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h index 7b47ed6..97ee69a 100644 --- a/kernel/inc/proc.h +++ b/kernel/inc/proc.h @@ -41,7 +41,7 @@ void scheduler_disable(); void proc_init(); void proc_print(); struct proc *proc_current(); -void proc_send(struct proc *src, struct proc *dest, enum message_type type, void *data); +void proc_send(struct proc *src, struct proc *dest, u32 type, void *data); struct proc_message *proc_receive(struct proc *proc); struct proc *proc_from_pid(u32 pid); void proc_exit(struct proc *proc, int status); -- cgit v1.2.3