blob: a59c01404605c93f91841432e11944e42c451b9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <kernel/arch/generic.h>
#include <kernel/main.h>
#include <kernel/mem.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/util.h>
#include <stdint.h>
static void setup_paging() {
struct pagedir *dir = pagedir_new();
// map VGA
pagedir_map(dir, 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
pagedir_switch(dir);
}
void kmain(struct kmain_info info) {
log_const("mem...");
mem_init(&info);
log_const("paging...");
setup_paging();
log_const("creating process...");
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);
}
|