aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-10-26 12:42:01 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2021-10-26 12:42:01 +0300
commit5c335752c4fb7e472d68b2b2731c3674a10cbd97 (patch)
tree9339ea883b640c177e699a98aae9601a04310258 /arch
parent7f7b3d61baf46fe358d3f1bd1cb584e0daed3a81 (diff)
downloadkmi-5c335752c4fb7e472d68b2b2731c3674a10cbd97.tar.gz
kmi-5c335752c4fb7e472d68b2b2731c3674a10cbd97.zip
Identified issue with vmem implementation
+ Sensible mappings should help, discard what I wrote in the previous commit. Nothing works unless I get vmem up and running properly.
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv/init/init.c3
-rw-r--r--arch/riscv/kernel/main.c8
2 files changed, 5 insertions, 6 deletions
diff --git a/arch/riscv/init/init.c b/arch/riscv/init/init.c
index 9b7d371..721712c 100644
--- a/arch/riscv/init/init.c
+++ b/arch/riscv/init/init.c
@@ -244,8 +244,6 @@ struct vm_branch_t *prepare_vmem()
/* map root pte */
map_vmem(branch, (pm_t)branch, ROOT_PTE, VM_R | VM_W | VM_V, MM_KPAGE);
- map_vmem(branch, 0x10000000, 0x10000000, VM_R | VM_W | VM_V, MM_KPAGE);
-
/* TODO: map more stuff? */
return branch;
}
@@ -276,6 +274,7 @@ void start_vmem(void *fdt, struct vm_branch_t *branch)
else
csr_write(CSR_SATP, SATP_MODE_Sv48 | pm_to_pnum((pm_t)(branch)));
+ __asm__ ("sfence.vma" : : : "memory");
/* Sv57 && Sv64 in the future? */
}
diff --git a/arch/riscv/kernel/main.c b/arch/riscv/kernel/main.c
index d4fa7b8..207b0bc 100644
--- a/arch/riscv/kernel/main.c
+++ b/arch/riscv/kernel/main.c
@@ -8,6 +8,8 @@
static void kernel_dbg(void *fdt)
{
struct dbg_info_t dbg = dbg_from_fdt(fdt);
+ map_vmem(ROOT_PTE, (pm_t)dbg.dbg_ptr, (vm_t)dbg.dbg_ptr,
+ VM_R | VM_W | VM_V, MM_KPAGE);
dbg_init(dbg.dbg_ptr, dbg.dev);
}
@@ -17,14 +19,11 @@ static void kernel_dbg(void *fdt)
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);
+ map_vregion(branch, fdt_base, fdt_base, 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);
@@ -32,6 +31,7 @@ void __main main(struct init_data_t d)
/* TODO: mark kernel area as used */
map_fdt(ROOT_PTE, d.fdt_base, d.fdt_top);
kernel_dbg((void *)d.fdt_base);
+ dbg("test\n");
/* TODO: approximate order of business:
* setup debugging in vmem (requires mapping fdt)
* free unnecessary init