aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/kernel/cpu.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-06-11 19:08:18 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-06-11 19:08:18 +0300
commit426da8be0db33405b0cfe53108b65040623972f0 (patch)
treec1776cf14695d717a92d5d46d7a07c978a0e3618 /arch/riscv64/kernel/cpu.c
parentde99380f12f8e2fe4acf7734db0e1e37a356c45f (diff)
downloadkmi-426da8be0db33405b0cfe53108b65040623972f0.tar.gz
kmi-426da8be0db33405b0cfe53108b65040623972f0.zip
continue documentation
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;
}