From a60b3ca993ac7ff428c4a545c357484237450c22 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 21 Apr 2022 19:17:29 +0200 Subject: kernel: consolidate `process_seed` and `run_init` --- src/kernel/proc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/kernel/proc.c') diff --git a/src/kernel/proc.c b/src/kernel/proc.c index bb4509b..94a448a 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -12,7 +12,7 @@ struct process *process_first; struct process *process_current; static uint32_t next_pid = 0; -struct process *process_seed(void) { +struct process *process_seed(struct kmain_info *info) { struct process *proc = kmalloc(sizeof *proc); proc->pages = pagedir_new(); proc->state = PS_RUNNING; @@ -39,7 +39,13 @@ struct process *process_seed(void) { for (size_t p = 0x100000; p < (size_t)&_bss_end; p += PAGE_SIZE) pagedir_map(proc->pages, (userptr_t)p, (void*)p, false, true); - // the kernel still has to load the executable code and set EIP + // map the init module as rw + void __user *init_base = (userptr_t)0x200000; + for (uintptr_t off = 0; off < info->init.size; off += PAGE_SIZE) + pagedir_map(proc->pages, init_base + off, info->init.at + off, + true, true); + proc->regs.eip = init_base; + return proc; } -- cgit v1.2.3