aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/riscv/init/init.c3
-rw-r--r--arch/riscv/kernel/main.c8
-rw-r--r--common/vmem.c13
3 files changed, 15 insertions, 9 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
diff --git a/common/vmem.c b/common/vmem.c
index c874e3d..87d5b3b 100644
--- a/common/vmem.c
+++ b/common/vmem.c
@@ -90,15 +90,19 @@ void init_vmem(struct vm_branch_t *branch, vm_t tmp_pte)
map_vmem(branch, first_block, (vm_t)root_region, VM_W | VM_R | VM_V, MM_O0);
memset(root_region, 0, __o_size(MM_O0));
+ /* apparently I'm overwriting some memory here which is fucking up
+ * things elsewhere, specifically some PTE. Really should come up with
+ * some sensible address mappings, as everything is at the moment sort
+ * of hither and tither. */
root_region->max_blocks = (__o_size(MM_O0) - sizeof(struct mm_block_region_t))
/ sizeof(struct mm_block_t);
- root_region->first = (struct mm_block_t *)sizeof(struct mm_block_t);
+ root_region->first = (struct mm_block_t *)((vm_t)root_region + sizeof(struct mm_block_t));
root_block = root_region->first;
root_block->start = __o_size(MM_O0);
/* TODO: add in UMEM_TOP or something */
root_block->end = -1;
- root_block->status = USED;
+ root_block->status = FREE;
}
@@ -185,10 +189,13 @@ vm_t map_vregion(struct vm_branch_t *branch, pm_t base, vm_t start, size_t size,
if(node->status == FREE && node->end >= start + size){
gobble_block(branch, node, start, start + size);
- break;
+ goto found;
}
}
+ return 0;
+
+found:
for(; size >= __o_size(MM_O0); size -= __o_size(MM_O0)){
map_vmem(branch, start, base, flags, MM_O0);
start += __o_size(MM_O0);