Zephyr Project API  3.2.0
A Scalable Open Source RTOS
arch_inlines.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_ARCH_RISCV_ARCH_INLINES_H_
8#define ZEPHYR_INCLUDE_ARCH_RISCV_ARCH_INLINES_H_
9
10#ifndef _ASMLANGUAGE
11
13
15{
16 uint32_t hartid;
17
18#ifdef CONFIG_SMP
19 __asm__ volatile("csrr %0, mhartid" : "=r" (hartid));
20#else
21 hartid = 0;
22#endif
23
24 return hartid;
25}
26
27static ALWAYS_INLINE _cpu_t *arch_curr_cpu(void)
28{
29 /* linear hartid enumeration space assumed */
30 return &_kernel.cpus[arch_proc_id()];
31}
32
33#endif /* !_ASMLANGUAGE */
34#endif /* ZEPHYR_INCLUDE_ARCH_RISCV_ARCH_INLINES_H_ */
#define ALWAYS_INLINE
Definition: common.h:124
static ALWAYS_INLINE _cpu_t * arch_curr_cpu(void)
Definition: arch_inlines.h:27
static ALWAYS_INLINE uint32_t arch_proc_id(void)
Definition: arch_inlines.h:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90