diff --git a/cpu/fe310/include/thread_arch.h b/cpu/fe310/include/thread_arch.h new file mode 100644 index 0000000000..2af55690d2 --- /dev/null +++ b/cpu/fe310/include/thread_arch.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2021 Koen Zandberg + * 2021 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License v2.1. See the file LICENSE in the top level directory for more + * details. + */ + +/** + * @ingroup cpu_fe310 + * @{ + * + * @file + * @brief Implementation of the kernels thread interface + * + * @author Koen Zandberg + * + * @} + */ +#ifndef THREAD_ARCH_H +#define THREAD_ARCH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define THREAD_API_INLINED + +#ifndef DOXYGEN /* Doxygen is in core/include/thread.h */ + +static inline void _ecall_dispatch(uint32_t num, void *ctx) +{ + /* function arguments are in a0 and a1 as per ABI */ + __asm__ volatile ( + "mv a0, %[num] \n" + "mv a1, %[ctx] \n" + "ECALL\n" + : /* No outputs */ + : [num] "r" (num), [ctx] "r" (ctx) + : "memory" + ); +} + +static inline __attribute__((always_inline)) void thread_yield_higher(void) +{ + _ecall_dispatch(0, NULL); +} + +#endif /* DOXYGEN */ + +#ifdef __cplusplus +} +#endif + +#endif /* THREAD_ARCH_H */ +/** @} */ diff --git a/cpu/fe310/thread_arch.c b/cpu/fe310/thread_arch.c index 54e5b3cf79..96674a15c6 100644 --- a/cpu/fe310/thread_arch.c +++ b/cpu/fe310/thread_arch.c @@ -179,24 +179,6 @@ void cpu_switch_context_exit(void) UNREACHABLE(); } -static inline void _ecall_dispatch(uint32_t num, void *ctx) -{ - /* function arguments are in a0 and a1 as per ABI */ - __asm__ volatile ( - "mv a0, %[num] \n" - "mv a1, %[ctx] \n" - "ECALL\n" - : /* No outputs */ - : [num] "r" (num), [ctx] "r" (ctx) - : "memory" - ); -} - -void thread_yield_higher(void) -{ - _ecall_dispatch(0, NULL); -} - /** * @brief Print heap statistics */