aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/kernel/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv64/kernel/cpu.c')
-rw-r--r--arch/riscv64/kernel/cpu.c10
1 files changed, 9 insertions, 1 deletions
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 <apos/tcb.h>
#include <arch/cpu.h>
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;
}