diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-20 12:28:30 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-20 12:37:55 +0200 |
| commit | dc2e2cc9dc9d7790e23dd9a4ccc265d7bb6d76aa (patch) | |
| tree | ee12863bb4aab536810bbe13638bf21317b37658 /arch/riscv/kernel/main.c | |
| parent | 98255910aa82c27d04ba79704086eca2310b3075 (diff) | |
| download | kmi-dc2e2cc9dc9d7790e23dd9a4ccc265d7bb6d76aa.tar.gz kmi-dc2e2cc9dc9d7790e23dd9a4ccc265d7bb6d76aa.zip | |
Added init back
Diffstat (limited to 'arch/riscv/kernel/main.c')
| -rw-r--r-- | arch/riscv/kernel/main.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/arch/riscv/kernel/main.c b/arch/riscv/kernel/main.c index 40f0eb6..6c504f8 100644 --- a/arch/riscv/kernel/main.c +++ b/arch/riscv/kernel/main.c @@ -259,15 +259,17 @@ static void init_proc(void *fdt, struct vm_branch_t *b) t->pid = 0; t->tid = 0; threads_insert(t); - sp_mem_init(&t->sp_r, uvmem_size()); + sp_mem_init(&t->sp_r, -uvmem_size(), uvmem_size() - 1); /* binary itself */ size_t sz = align_up(get_init_size(fdt), BASE_PAGE_SIZE); - t->bin = alloc_uvmem(t, sz, VM_V | VM_X); + t->bin = alloc_uvmem(t, sz, VM_V | VM_X | VM_R | VM_W | VM_U); /* stack */ - t->stack = alloc_uvmem(t, SZ_2M, VM_V | VM_R | VM_W); + t->stack = alloc_uvmem(t, SZ_2M, VM_V | VM_R | VM_W | VM_U); /* if it needs heap, it'll ask for it */ + __asm__ ("sfence.vma" : : : "memory"); + move_init(fdt, (void *)t->bin); jump_to_userspace(t, 0, 0); } @@ -277,6 +279,8 @@ void __main main(void *fdt) init_dbg(fdt); dbg_fdt(fdt); + /* allow supervisor code to touch user data */ + csr_set(CSR_SSTATUS, SSTATUS_SUM); struct vm_branch_t *b = init_vmem(fdt); init_mem_blocks(); init_irq(fdt); |
