aboutsummaryrefslogtreecommitdiff
path: root/include/arch/cpu.h
blob: 3156076582cd235d1cdf290b4856a731e6256ca4 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright 2021 - 2022, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */

#ifndef APOS_CPU_H
#define APOS_CPU_H

/**
 * @file cpu.h
 * Arch-specific cpu handling, generally implemented in
 * arch/whatever/kernel/cpu.c
 */

#include <apos/types.h>
#include <apos/tcb.h>

#if defined(riscv64)
#include "../../arch/riscv64/include/cpu.h"
#elif defined(riscv32)
#include "../../arch/riscv32/include/cpu.h"
#endif

/**
 * Get current CPU ID.
 * ID must be in range \c 0 .. \c num_cpus, where \c num_cpus is the number of
 * cpus on this system.
 *
 * @return Current CPU ID.
 */
id_t cpu_id();

/**
 * Assign tcb to current cpu.
 *
 * @param t \ref tcb to assign to current cpu.
 */
void cpu_assign(struct tcb *t);

/** \todo Should init be assigned one thread per core, or how should I handle
 * giving out CPU IDs? */

#endif /* APOS_CPU_H */