diff options
author | dzwdz | 2022-04-21 19:17:29 +0200 |
---|---|---|
committer | dzwdz | 2022-04-21 19:17:29 +0200 |
commit | a60b3ca993ac7ff428c4a545c357484237450c22 (patch) | |
tree | d7d153e2ec6da67cc33be964ac9a65bacf03ee28 /src/kernel/proc.c | |
parent | a990307680233460b2243c84002725b05a68b94a (diff) |
kernel: consolidate `process_seed` and `run_init`
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r-- | src/kernel/proc.c | 10 |
1 files changed, 8 insertions, 2 deletions
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; } |