blob: 36dc2e640f97dbd0cefa6907110baecce9a44e8d [file] [log] [blame]
/*
* Copyright (c) 2021 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_ARCH_RISCV_ARCH_INLINES_H_
#define ZEPHYR_INCLUDE_ARCH_RISCV_ARCH_INLINES_H_
#ifndef _ASMLANGUAGE
#include <zephyr/kernel_structs.h>
#include "csr.h"
static ALWAYS_INLINE uint32_t arch_proc_id(void)
{
return csr_read(mhartid) & ((uintptr_t)CONFIG_RISCV_HART_MASK);
}
static ALWAYS_INLINE _cpu_t *arch_curr_cpu(void)
{
#if defined(CONFIG_SMP) || defined(CONFIG_USERSPACE)
return (_cpu_t *)csr_read(mscratch);
#else
return &_kernel.cpus[0];
#endif
}
static ALWAYS_INLINE unsigned int arch_num_cpus(void)
{
return CONFIG_MP_MAX_NUM_CPUS;
}
#endif /* !_ASMLANGUAGE */
#endif /* ZEPHYR_INCLUDE_ARCH_RISCV_ARCH_INLINES_H_ */