1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/fe310/include/thread_arch.h
Koen Zandberg b57b3d490d
cpu/fe310: Allow using immediates for ecall arguments
The mv instruction (which is usually implemented as `add rd, x0, r1`) is
changed to `add rd, x0, %input`. This can either be used as a load
immediate or as an move.

The code size grows by two bytes. This because GCC does not compress the
li instruction to the compressed version (even though this is possible).
2021-01-22 20:49:52 +01:00

58 lines
1.1 KiB
C

/*
* Copyright (C) 2021 Koen Zandberg <koen@bergzand.net>
* 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 <koen@bergzand.net>
*
* @}
*/
#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 (
"add a0, x0, %[num] \n"
"add a1, x0, %[ctx] \n"
"ECALL\n"
: /* No outputs */
: [num] "r" (num), [ctx] "r" (ctx)
: "memory", "a0", "a1"
);
}
static inline __attribute__((always_inline)) void thread_yield_higher(void)
{
_ecall_dispatch(0, NULL);
}
#endif /* DOXYGEN */
#ifdef __cplusplus
}
#endif
#endif /* THREAD_ARCH_H */
/** @} */