diff options
author | dzwdz | 2021-07-20 21:38:09 +0200 |
---|---|---|
committer | dzwdz | 2021-07-20 21:38:09 +0200 |
commit | 9ad0eafcf7e2f3e0532666c5353b0f5294401b06 (patch) | |
tree | 2e17da4c1953b6f24fb9a9a6c533a62d3f6c4d4c /src/kernel/main.c | |
parent | 061363a38eff486c809d397e69ae4fe290db95d2 (diff) |
per-process virtual memory
VGA is only mapped into the virtual memory because there are no other
ways of interacting with the OS.
Diffstat (limited to 'src/kernel/main.c')
-rw-r--r-- | src/kernel/main.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c index a59c014..729e39d 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -6,32 +6,29 @@ #include <kernel/util.h> #include <stdint.h> -static void setup_paging() { - struct pagedir *dir = pagedir_new(); +static void run_init(struct kmain_info *info) { + struct process *proc = process_new(); + void *init_base = (void*) 0x200000; - // map VGA - pagedir_map(dir, 0xB8000, 0xB8000, true, true); + // map VGA for testing + pagedir_map(proc->pages, 0xB8000, 0xB8000, true, true); - // map the kernel - for (size_t p = 0x100000; p < &_bss_end; p += PAGE_SIZE) - pagedir_map(dir, p, p, false, true); // yes, .text is writeable too + // map the module as rw + 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->eip = init_base; - pagedir_switch(dir); + log_const("switching..."); + process_switch(proc); } void kmain(struct kmain_info info) { log_const("mem..."); mem_init(&info); - log_const("paging..."); - setup_paging(); - - log_const("creating process..."); + log_const("loading init..."); + run_init(&info); - void *init_addr = (void*)0x200000; - memcpy(init_addr, info.init.at, info.init.size); - - struct process *proc = process_new(init_addr); - log_const("switching..."); - process_switch(proc); + panic(); } |