diff options
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/riscv64/kernel/cpu.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/arch/riscv64/kernel/cpu.c b/arch/riscv64/kernel/cpu.c index 38cf262..4273d02 100644 --- a/arch/riscv64/kernel/cpu.c +++ b/arch/riscv64/kernel/cpu.c @@ -16,12 +16,15 @@ void cpu_assign(struct tcb *t) id_t cpu_id() { - /* yes, slightly weird situation where cur_tcb() call cpu_id() which - * gets the current tcb and returns the cpu id in the tcb, so that that - * id can be used to get the tcb we want. I might try to work out - * something slightly smarter, although this is likely not going to have - * basically any kind of importance for perfomance. */ - struct tcb *t; - __asm__ volatile ("mv %0, tp\n" : "=r" (t) ::); + struct tcb *t = cur_tcb(); return t->cpu_id; } + +/* override cur_tcb() in common/tcb.c since on risc-v this is apparently the + * optimal strategy. */ +/* @todo should this be the default for all arches? */ +struct tcb *cur_tcb() +{ + register struct tcb *t __asm__ ("tp"); + return t; +} |
