aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/kernel
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-01-10 17:45:09 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-01-10 17:45:09 +0200
commita5cfead3bd0761ba22a07a4e168670dfb7c9fb84 (patch)
tree8081f1ba46f93b6788b94c167e16cba700b9fbb1 /arch/riscv64/kernel
parent23207f0393be1776fdcc224248b7e7d88c1bf622 (diff)
downloadkmi-a5cfead3bd0761ba22a07a4e168670dfb7c9fb84.tar.gz
kmi-a5cfead3bd0761ba22a07a4e168670dfb7c9fb84.zip
some kmx alleviations
Diffstat (limited to 'arch/riscv64/kernel')
-rw-r--r--arch/riscv64/kernel/proc.c17
-rw-r--r--arch/riscv64/kernel/vmem.c11
2 files changed, 17 insertions, 11 deletions
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c
index a7721e2..4e4d7ec 100644
--- a/arch/riscv64/kernel/proc.c
+++ b/arch/riscv64/kernel/proc.c
@@ -15,9 +15,9 @@
#include "regs.h"
#include "csr.h"
-void run_init(struct tcb *t, void *fdt)
+void run_init(struct tcb *t, void *fdt, void *initrd)
{
- /** \todo actually map fdt into the target address space */
+ /** \todo actually map fdt and initrd into the target address space */
csr_write(CSR_SSCRATCH, t);
csr_write(CSR_SEPC, t->exec);
/* gcc gives a warning 'the value of the stack pointer after an asm
@@ -27,10 +27,15 @@ void run_init(struct tcb *t, void *fdt)
* Could be fixed with a separate pure asm run_init, but I guess this
* works for now.
*/
- __asm__ volatile ("mv sp, %0\n" : : "r" (t->thread_stack_top) : "memory");
- __asm__ volatile ("mv a0, %0\n" : : "r" (t->tid) : "a0");
- __asm__ volatile ("mv a1, %0\n" : : "r" (fdt) : "a1");
- __asm__ volatile ("sret\n" ::: "memory");
+ __asm__ volatile ("mv sp, %0\n"
+ "mv a0, %1\n"
+ "mv a1, %2\n"
+ "mv a2, %3\n"
+ "sret\n"
+ :
+ : "r" (t->thread_stack_top), "r" (t->tid), "r" (fdt),
+ "r" (initrd)
+ : "memory");
/* we should never reach this */
unreachable();
}
diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c
index 37b9040..bc984e4 100644
--- a/arch/riscv64/kernel/vmem.c
+++ b/arch/riscv64/kernel/vmem.c
@@ -493,12 +493,12 @@ void setup_rpc_stack(struct tcb *t)
for (size_t i = 0; i < pages; ++i) {
pm_t page = alloc_page(BASE_PAGE);
map_vpage(t->rpc.vmem, page,
- RPC_STACK_BASE + BASE_PAGE_SIZE * i,
- flags, BASE_PAGE);
+ RPC_STACK_BASE + BASE_PAGE_SIZE * i,
+ flags, BASE_PAGE);
map_vpage(t->proc.vmem, page,
- RPC_STACK_BASE + BASE_PAGE_SIZE * i,
- flags, BASE_PAGE);
+ RPC_STACK_BASE + BASE_PAGE_SIZE * i,
+ flags, BASE_PAGE);
}
/* we allocated a second order page for rpc stack usage */
@@ -506,7 +506,8 @@ void setup_rpc_stack(struct tcb *t)
/* slightly hacky maybe but we know the first pte is at RPC_STACK_BASE,
* which means that it must also be the leaf */
t->arch.rpc_leaf = (struct vmem *)__find_vmem(t->rpc.vmem,
- RPC_STACK_BASE, BASE_PAGE);
+ RPC_STACK_BASE,
+ BASE_PAGE);
/* 'reserve' top page of stack for kernel use */
t->arch.rpc_idx = 511;
}