From 7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 25 Oct 2021 19:40:53 +0300 Subject: Some minor changes to virtual memory handling + Should start to think about how virtual memory should be handled efficiently, I'm sort of flailing around and not actually doing anything beneficial. The mapping system I've so far implemented _works_, but it's not good and I'm not happy with it. I might come back and fix/improve it, but I think I'll go ahead and do other things for a while, might give me a better overhead view of what the virtual memory system should do. + TODO: should probably document the memory layout I'm going with at the moment. --- arch/riscv/kernel/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'arch/riscv/kernel') diff --git a/arch/riscv/kernel/main.c b/arch/riscv/kernel/main.c index c8eca26..d4fa7b8 100644 --- a/arch/riscv/kernel/main.c +++ b/arch/riscv/kernel/main.c @@ -1,9 +1,37 @@ #include #include #include +#include + +#ifdef DEBUG + +static void kernel_dbg(void *fdt) +{ + struct dbg_info_t dbg = dbg_from_fdt(fdt); + dbg_init(dbg.dbg_ptr, dbg.dev); +} + +#else +#define kernel_dbg(...) +#endif + +static void map_fdt(struct vm_branch_t *branch, vm_t fdt_base, vm_t fdt_top) +{ + map_vregion(branch, fdt_base, 0, fdt_top - fdt_base, VM_R | VM_W |VM_V); +} void __main main(struct init_data_t d) { + /* feck */ + dbg_init(0x10000000, NS16550A); + dbg("test\n"); + init_pmap((void *)d.pmap_base); + init_mem(d.max_order, d.bits, d.page_shift); + init_vmem(ROOT_PTE, d.tmp_pte); + /* TODO: move pmap into vmem somewhere */ + /* TODO: mark kernel area as used */ + map_fdt(ROOT_PTE, d.fdt_base, d.fdt_top); + kernel_dbg((void *)d.fdt_base); /* TODO: approximate order of business: * setup debugging in vmem (requires mapping fdt) * free unnecessary init -- cgit v1.3