diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-25 19:40:53 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-25 19:44:11 +0300 |
| commit | 7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81 (patch) | |
| tree | 51ded3e49cb467915a6e2b0e570b5d9973515553 /arch/riscv/kernel | |
| parent | 59a374b0eed4313d1a67e2cdb673a295e79a6494 (diff) | |
| download | kmi-7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81.tar.gz kmi-7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81.zip | |
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.
Diffstat (limited to 'arch/riscv/kernel')
| -rw-r--r-- | arch/riscv/kernel/main.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 <apos/debug.h> #include <apos/init.h> #include <apos/vmem.h> +#include <apos/mem.h> + +#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 |
