From 3dbd8c34176312b0bd3aba2309d284ac83181411 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 4 Jun 2023 15:13:43 +0300 Subject: visionfive2 boots + Make 8250 serial driver more generic + Still TODO: write a tutorial on how to boot on the visionfive2 --- arch/riscv64/config.h | 3 +-- arch/riscv64/kernel/vmem.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'arch') diff --git a/arch/riscv64/config.h b/arch/riscv64/config.h index 3eb2e72..a2694d5 100644 --- a/arch/riscv64/config.h +++ b/arch/riscv64/config.h @@ -21,8 +21,7 @@ #include /* --- START ARCH USER CONFIG VALUES --- */ -/** Physical address to where the OS image will be loaded. */ -//#define RAM_BASE 0x80000000 +/* nada for now */ /* --- END ARCH USER CONFIG VALUES --- */ /* don't touch >:( */ diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c index f29c325..89d895f 100644 --- a/arch/riscv64/kernel/vmem.c +++ b/arch/riscv64/kernel/vmem.c @@ -369,7 +369,7 @@ void flush_tlb(uintptr_t addr) void flush_tlb_full() { - __asm__ volatile ("sfence.vma %0\n" :: "r" (0) : "memory"); + __asm__ volatile ("sfence.vma %0\n" : : "r" (0) : "memory"); } void flush_tlb_all() @@ -451,9 +451,17 @@ stat_t populate_kvmem(struct vmem *b) vm_t setup_kernel_io(struct vmem *b, vm_t paddr) { pm_t top_page = paddr / TOP_PAGE_SIZE; - b->leaf[IO_PAGE] = (struct vmem *)to_pte(top_page * TOP_PAGE_SIZE, - VM_V | VM_R | VM_W | VM_A | VM_D); - return -TOP_PAGE_SIZE + paddr - (top_page * TOP_PAGE_SIZE); + pm_t addr = top_page * TOP_PAGE_SIZE; + b->leaf[IO_PAGE] = (struct vmem *)to_pte(addr, + VM_V | VM_R | VM_W | VM_A | + VM_D); + /* flush might be necessary when we're in the actual vmem we're + * modifying, or during the startup stage where we don't have a tcb yet. + * I don't think checking the rpc context is necessary? */ + if (!cur_tcb() || cur_tcb()->proc.vmem == b) + flush_tlb((uintptr_t)pte_addr(b->leaf[IO_PAGE])); + + return -TOP_PAGE_SIZE + paddr - addr; } #endif -- cgit v1.3