From 7e8a831e1fa1fb98d2486f0c262c2609c176abab Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 25 Jun 2021 21:57:30 +0200 Subject: malloc stub + processes well, there's only one process, but shh --- kernel/proc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 kernel/proc.c (limited to 'kernel/proc.c') diff --git a/kernel/proc.c b/kernel/proc.c new file mode 100644 index 0000000..1178952 --- /dev/null +++ b/kernel/proc.c @@ -0,0 +1,21 @@ +#include +#include +#include + +struct process *process_current; + +struct process *process_new(void *eip) { + struct process *proc; + proc = malloc(sizeof(struct process)); + + // should allocate an actual page. TODO + proc->stack_top = proc->esp = malloc(4096); + proc->eip = eip; + + return proc; +} + +void process_switch(struct process *proc) { + process_current = proc; + sysexit(proc->eip, proc->esp); +} -- cgit v1.2.3