Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15788 from bergzand/pr/core/inline_thread_yield_h…
…igher core/thread: Allow for inline thread_yield_higher
- Loading branch information
Showing
12 changed files
with
327 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2008, 2009 Heiko Will <hwill@inf.fu-berlin.de> | ||
* Copyright (C) 2009 Kaspar Schleiser <kaspar@schleiser.de> | ||
* | ||
* 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_arm7_common | ||
* @{ | ||
* | ||
* @file | ||
* @brief Implementation of the kernels thread interface | ||
* | ||
* @author Kaspar Schleiser <kaspar@schleiser.de> | ||
* @author Heiko Will <heiko.will@fu-berlin.de> | ||
* | ||
* @} | ||
*/ | ||
#ifndef THREAD_ARCH_H | ||
#define THREAD_ARCH_H | ||
|
||
#include "irq.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define THREAD_API_INLINED | ||
|
||
#ifndef DOXYGEN /* Doxygen is in core/include/thread.h */ | ||
|
||
static inline __attribute__((always_inline)) void thread_yield_higher(void) | ||
{ | ||
if (irq_is_in()) { | ||
sched_context_switch_request = 1; | ||
} | ||
else { | ||
__asm__("svc 0\n"); | ||
} | ||
} | ||
|
||
#endif /* DOXYGEN */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* THREAD_ARCH_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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_avr8_common | ||
* @{ | ||
* | ||
* @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 | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* THREAD_ARCH_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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_cortexm_common | ||
* @{ | ||
* | ||
* @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 __attribute__((always_inline)) void thread_yield_higher(void) | ||
{ | ||
/* trigger the PENDSV interrupt to run scheduler and schedule new thread if | ||
* applicable */ | ||
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; | ||
/* flush the pipeline. Otherwise we risk that subsequent instructions are | ||
* executed before the IRQ has actually triggered */ | ||
__ISB(); | ||
} | ||
|
||
#endif /* DOXYGEN */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* THREAD_ARCH_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 ( | ||
"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 */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright(C) 2017, 2016, Imagination Technologies Limited and/or its | ||
* affiliated group companies. | ||
* | ||
* 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_mips32r2_common | ||
* @{ | ||
* | ||
* @file | ||
* @brief Implementation of the kernels thread interface | ||
* | ||
* @author Neil Jones <neil.jones@imgtec.com> | ||
* | ||
* @} | ||
*/ | ||
#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 __attribute__((always_inline)) void thread_yield_higher(void) | ||
{ | ||
/* | ||
* throw a syscall exception to get into exception level | ||
* we context switch at exception level. | ||
* | ||
* Note syscall 1 is reserved for UHI see: | ||
* http://wiki.prplfoundation.org/w/images/4/42/UHI_Reference_Manual.pdf | ||
*/ | ||
__asm volatile ("syscall 2"); | ||
} | ||
|
||
#endif /* DOXYGEN */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* THREAD_ARCH_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.