blob: 38cf2623696f3bf3dad41a512efed9da8ffd9ff4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright 2021 - 2022, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */
/**
* @file cpu.c
* riscv64 implementation of cpu handling.
*/
#include <apos/tcb.h>
#include <arch/cpu.h>
void cpu_assign(struct tcb *t)
{
__asm__ volatile ("mv tp, %0\n" : : "r" (t) :);
}
id_t cpu_id()
{
/* 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;
}
|