From 426da8be0db33405b0cfe53108b65040623972f0 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 11 Jun 2022 19:08:18 +0300 Subject: continue documentation --- arch/riscv64/kernel/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'arch/riscv64/kernel/cpu.c') diff --git a/arch/riscv64/kernel/cpu.c b/arch/riscv64/kernel/cpu.c index 0558040..91b39b6 100644 --- a/arch/riscv64/kernel/cpu.c +++ b/arch/riscv64/kernel/cpu.c @@ -3,9 +3,17 @@ * riscv64 implementation of cpu handling. */ +#include #include id_t cpu_id() { - return 0; /* VERY MUCH TEMP */ + /* 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) ::); + return t->cpu_id; } -- cgit v1.3