aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMarvin Borner2021-01-09 23:19:53 +0100
committerMarvin Borner2021-01-09 23:19:53 +0100
commit836294b9232c7d63d26db4f87c32cf1420cd856d (patch)
tree54f1b28951c53b38dcde5866a74c082c8ef83b0f /kernel
parentf27a5f8af9fc5a16b80a7d6646e44d718b0efd7d (diff)
To be continued
Diffstat (limited to 'kernel')
-rw-r--r--kernel/drivers/keyboard.c2
-rw-r--r--kernel/features/proc.c7
-rw-r--r--kernel/features/syscall.c3
-rw-r--r--kernel/inc/proc.h2
4 files changed, 8 insertions, 6 deletions
diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c
index e8690f1..ac97d36 100644
--- a/kernel/drivers/keyboard.c
+++ b/kernel/drivers/keyboard.c
@@ -28,6 +28,8 @@ void keyboard_handler()
// TODO: "Merge" scancode to linux keycode?
/* printf("%x %x = %x\n", scancode, state ? 0xe0 : 0, merged); */
+ if (event)
+ free(event);
event = malloc(sizeof(*event));
event->magic = KEYBOARD_MAGIC;
event->press = (scancode & 0x80) == 0;
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 76da36d..08f3b8e 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -98,14 +98,15 @@ void proc_send(struct proc *src, struct proc *dest, u32 type, void *data)
priority_proc = dest;
}
-struct proc_message *proc_receive(struct proc *proc)
+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);
- return msg;
+ memcpy(buf, msg->msg, sizeof(*buf));
+ return 1;
} else {
- return NULL;
+ return 0;
}
}
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index e2df79a..a6bfb2a 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -88,8 +88,7 @@ void syscall_handler(struct regs *r)
break;
}
case SYS_RECEIVE: {
- struct proc_message *msg = proc_receive(proc_current());
- r->eax = (u32)(msg ? msg->msg : NULL);
+ r->eax = proc_receive(proc_current(), (void *)r->ebx);
break;
}
case SYS_GETPID: {
diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h
index 5fc217c..93d8d48 100644
--- a/kernel/inc/proc.h
+++ b/kernel/inc/proc.h
@@ -41,7 +41,7 @@ void proc_init(void);
void proc_print(void);
struct proc *proc_current(void);
void proc_send(struct proc *src, struct proc *dest, u32 type, void *data);
-struct proc_message *proc_receive(struct proc *proc);
+u32 proc_receive(struct proc *proc, struct message *buf);
struct proc *proc_from_pid(u32 pid);
void proc_exit(struct proc *proc, int status);
void proc_yield(struct regs *r);