From e16f5f81dfb2e97a554ec19b941ec05a7942fd2d Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 4 Aug 2023 20:50:41 +0300 Subject: add initial smp bringup --- arch/riscv64/kernel/cpu.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'arch/riscv64/kernel/cpu.c') 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) :); } -- cgit v1.3