aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/kernel
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-06-04 15:13:43 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-06-04 15:13:43 +0300
commit3dbd8c34176312b0bd3aba2309d284ac83181411 (patch)
tree9bf6216f2c120a388308457444738d0c55002bd2 /arch/riscv64/kernel
parent52e5c94314fa8e10efded82db85d181ed32f00bd (diff)
downloadkmi-3dbd8c34176312b0bd3aba2309d284ac83181411.tar.gz
kmi-3dbd8c34176312b0bd3aba2309d284ac83181411.zip
visionfive2 boots
+ Make 8250 serial driver more generic + Still TODO: write a tutorial on how to boot on the visionfive2
Diffstat (limited to 'arch/riscv64/kernel')
-rw-r--r--arch/riscv64/kernel/vmem.c16
1 files changed, 12 insertions, 4 deletions
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