Skip to content
Permalink
Browse files

arch: arm: extend use of arch.mode variable in FP sharing mode

Only a single bit of the 4-byte internal (thread.arch) status
variable 'mode' is currently used, when we build with User mode
support (CONFIG_USERSPACE=y). In this commit we extend the usage
of 'mode' variable, adding an additional bit-flag to track the
status of the floating point context in a particular thread,
i.e. to track whether FP context is active or not. The status
bit is meant to be used in context-switch, to restore the FP
register context when required.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information...
ioannisg authored and nashif committed Apr 26, 2019
1 parent 929e9ea commit 358d389c54363e28263f03c546b28f9ea58af99f
@@ -29,10 +29,12 @@
GEN_OFFSET_SYM(_thread_arch_t, basepri);
GEN_OFFSET_SYM(_thread_arch_t, swap_return_value);

#ifdef CONFIG_USERSPACE
#if defined(CONFIG_USERSPACE) || defined(CONFIG_FP_SHARING)
GEN_OFFSET_SYM(_thread_arch_t, mode);
#if defined(CONFIG_USERSPACE)
GEN_OFFSET_SYM(_thread_arch_t, priv_stack_start);
#endif
#endif

#if defined(CONFIG_FLOAT) && defined(CONFIG_FP_SHARING)
GEN_OFFSET_SYM(_thread_arch_t, preempt_float);
@@ -133,9 +133,11 @@ void z_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
thread->callee_saved.psp = (u32_t)pInitCtx;
thread->arch.basepri = 0;

#if defined(CONFIG_USERSPACE)
#if defined(CONFIG_USERSPACE) || defined(CONFIG_FP_SHARING)
thread->arch.mode = 0;
#if defined(CONFIG_USERSPACE)
thread->arch.priv_stack_start = 0;
#endif
#endif

/* swap_return_value can contain garbage */
@@ -74,10 +74,12 @@ struct _thread_arch {
struct _preempt_float preempt_float;
#endif

#ifdef CONFIG_USERSPACE
#if defined(CONFIG_USERSPACE) || defined(CONFIG_FP_SHARING)
u32_t mode;
#if defined(CONFIG_USERSPACE)
u32_t priv_stack_start;
#endif
#endif
};

typedef struct _thread_arch _thread_arch_t;
@@ -26,13 +26,15 @@
#define _thread_offset_to_preempt_float \
(___thread_t_arch_OFFSET + ___thread_arch_t_preempt_float_OFFSET)

#ifdef CONFIG_USERSPACE
#if defined(CONFIG_USERSPACE) || defined(CONFIG_FP_SHARING)
#define _thread_offset_to_mode \
(___thread_t_arch_OFFSET + ___thread_arch_t_mode_OFFSET)

#ifdef CONFIG_USERSPACE
#define _thread_offset_to_priv_stack_start \
(___thread_t_arch_OFFSET + ___thread_arch_t_priv_stack_start_OFFSET)
#endif
#endif

/* end - threads */

0 comments on commit 358d389

Please sign in to comment.
You can’t perform that action at this time.