aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/kernel/cpu.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-08-04 20:50:41 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-08-04 20:50:41 +0300
commite16f5f81dfb2e97a554ec19b941ec05a7942fd2d (patch)
tree46f0609b5be009d4d1057fa02ece4461732941e0 /arch/riscv64/kernel/cpu.c
parent5f30284181fcfe5b16dfb94d4fba9a9ed4a2dc6a (diff)
downloadkmi-e16f5f81dfb2e97a554ec19b941ec05a7942fd2d.tar.gz
kmi-e16f5f81dfb2e97a554ec19b941ec05a7942fd2d.zip
add initial smp bringup
Diffstat (limited to 'arch/riscv64/kernel/cpu.c')
-rw-r--r--arch/riscv64/kernel/cpu.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/arch/riscv64/kernel/cpu.c b/arch/riscv64/kernel/cpu.c
index dc87a13..0cb3d4c 100644
--- a/arch/riscv64/kernel/cpu.c
+++ b/arch/riscv64/kernel/cpu.c
@@ -13,18 +13,16 @@
#include "sbi.h"
-/** Keeps track of initialized cpus. */
-static atomic_long cpus = 0;
-
void cpu_assign(struct tcb *t)
{
- /* bounce cpu id forward, or if first time here, get a cpu id */
+ /* bounce cpu id forward */
struct tcb *c = cur_tcb();
- if (likely(c))
- t->cpu_id = c->cpu_id;
- else
- t->cpu_id = cpus++;
+ t->cpu_id = c->cpu_id;
+ __asm__ volatile ("mv tp, %0\n" : : "r" (t) :);
+}
+void tcb_assign(struct tcb *t)
+{
__asm__ volatile ("mv tp, %0\n" : : "r" (t) :);
}