kernel, xtensa: Switch-specific thread return value

When using _arch_switch() context switching, the thread return value
is a generic hook and not provided by the architecture.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2017-12-17 08:53:44 -08:00 committed by Anas Nashif
commit 2c1449bc81
3 changed files with 17 additions and 1 deletions

View file

@ -78,11 +78,13 @@ static ALWAYS_INLINE void kernel_arch_init(void)
* *
* @return N/A * @return N/A
*/ */
#if !CONFIG_USE_SWITCH
static ALWAYS_INLINE void static ALWAYS_INLINE void
_set_thread_return_value(struct k_thread *thread, unsigned int value) _set_thread_return_value(struct k_thread *thread, unsigned int value)
{ {
thread->callee_saved.retval = value; thread->callee_saved.retval = value;
} }
#endif
extern void k_cpu_atomic_idle(unsigned int imask); extern void k_cpu_atomic_idle(unsigned int imask);

View file

@ -75,6 +75,7 @@ extern void _check_stack_sentinel(void);
static inline unsigned int _Swap(unsigned int key) static inline unsigned int _Swap(unsigned int key)
{ {
struct k_thread *new_thread, *old_thread; struct k_thread *new_thread, *old_thread;
int ret;
old_thread = _kernel.current; old_thread = _kernel.current;
@ -89,9 +90,11 @@ static inline unsigned int _Swap(unsigned int key)
_arch_switch(new_thread->switch_handle, _arch_switch(new_thread->switch_handle,
&old_thread->switch_handle); &old_thread->switch_handle);
ret = _kernel.current->swap_retval;
irq_unlock(key); irq_unlock(key);
return _kernel.current->swap_retval; return ret;
} }
#else /* !CONFIG_USE_SWITCH */ #else /* !CONFIG_USE_SWITCH */

View file

@ -138,6 +138,17 @@ extern struct _kernel _kernel;
#include <kernel_arch_func.h> #include <kernel_arch_func.h>
#if CONFIG_USE_SWITCH
/* This is a arch function traditionally, but when the switch-based
* _Swap() is in use it's a simple inline provided by the kernel.
*/
static ALWAYS_INLINE void
_set_thread_return_value(struct k_thread *thread, unsigned int value)
{
thread->swap_retval = value;
}
#endif
static ALWAYS_INLINE void static ALWAYS_INLINE void
_set_thread_return_value_with_data(struct k_thread *thread, _set_thread_return_value_with_data(struct k_thread *thread,
unsigned int value, unsigned int value,