aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/riscv64/kernel/cpu.c3
-rw-r--r--arch/riscv64/kernel/proc.c11
2 files changed, 11 insertions, 3 deletions
diff --git a/arch/riscv64/kernel/cpu.c b/arch/riscv64/kernel/cpu.c
index 60140e6..e8c8f34 100644
--- a/arch/riscv64/kernel/cpu.c
+++ b/arch/riscv64/kernel/cpu.c
@@ -39,7 +39,8 @@ id_t cpu_id()
/* @todo should this be the default for all arches? */
struct tcb *cur_tcb()
{
- register struct tcb *t __asm__ ("tp");
+ struct tcb *t;
+ __asm__ volatile ("mv %0, tp" : "=r" (t) ::);
return t;
}
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c
index 1990523..0f19789 100644
--- a/arch/riscv64/kernel/proc.c
+++ b/arch/riscv64/kernel/proc.c
@@ -20,9 +20,16 @@ void run_init(struct tcb *t, void *fdt)
/** \todo actually map fdt 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
+ * statement must be the same as it was before the statement', so this
+ * is technically speaking undefined behavior, I think.
+ *
+ * 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) : );
- __asm__ volatile ("mv a1, %0\n" : : "r" (fdt) : );
+ __asm__ volatile ("mv a0, %0\n" : : "r" (t->tid) : "a0");
+ __asm__ volatile ("mv a1, %0\n" : : "r" (fdt) : "a1");
__asm__ volatile ("sret\n" ::: "memory");
/* we should never reach this */
unreachable();