Skip to content

Commit

Permalink
kernel: sanitize thread options
Browse files Browse the repository at this point in the history
Some thread options were made architecture specific, i.e. K_ARC_DSP_IDX. We
have other architectures with similar functionality and we need to be
architecture agnostic at this level.

Changed the option to be more generic. The option is now called K_DSP_IDX.

Also remove multiple level of ifdefs and guards around those defines to
allow for documentation to be published and added a note about required
configs in the docstring.

Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif authored and fabiobaltieri committed Nov 27, 2023
1 parent 5da13ea commit b58a1f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
22 changes: 3 additions & 19 deletions include/zephyr/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ void k_thread_foreach_unlocked(
* */
#define K_ESSENTIAL (BIT(0))

#if defined(CONFIG_FPU_SHARING)
/**
* @brief FPU registers are managed by context switch
*
Expand All @@ -183,7 +182,6 @@ void k_thread_foreach_unlocked(
*/
#define K_FP_IDX 1
#define K_FP_REGS (BIT(K_FP_IDX))
#endif

/**
* @brief user mode thread
Expand Down Expand Up @@ -214,24 +212,18 @@ void k_thread_foreach_unlocked(
*/
#define K_CALLBACK_STATE (BIT(4))

#ifdef CONFIG_ARC
/* ARC processor Bitmask definitions for threads user options */

#if defined(CONFIG_ARC_DSP_SHARING)
/**
* @brief DSP registers are managed by context switch
*
* @details
* This option indicates that the thread uses the CPU's DSP registers.
* This instructs the kernel to take additional steps to save and
* restore the contents of these registers when scheduling the thread.
* No effect if @kconfig{CONFIG_ARC_DSP_SHARING} is not enabled.
* No effect if @kconfig{CONFIG_DSP_SHARING} is not enabled.
*/
#define K_DSP_IDX 6
#define K_ARC_DSP_REGS (BIT(K_DSP_IDX))
#endif
#define K_DSP_REGS (BIT(K_DSP_IDX))

#if defined(CONFIG_ARC_AGU_SHARING)
/**
* @brief AGU registers are managed by context switch
*
Expand All @@ -241,14 +233,8 @@ void k_thread_foreach_unlocked(
* No effect if @kconfig{CONFIG_ARC_AGU_SHARING} is not enabled.
*/
#define K_AGU_IDX 7
#define K_ARC_AGU_REGS (BIT(K_AGU_IDX))
#endif
#endif

#ifdef CONFIG_X86
/* x86 Bitmask definitions for threads user options */
#define K_AGU_REGS (BIT(K_AGU_IDX))

#if defined(CONFIG_FPU_SHARING) && defined(CONFIG_X86_SSE)
/**
* @brief FP and SSE registers are managed by context switch on x86
*
Expand All @@ -259,8 +245,6 @@ void k_thread_foreach_unlocked(
* the thread. No effect if @kconfig{CONFIG_X86_SSE} is not enabled.
*/
#define K_SSE_REGS (BIT(7))
#endif
#endif

/* end - thread options */

Expand Down
2 changes: 1 addition & 1 deletion tests/arch/arc/arc_dsp_sharing/src/test_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
#define THREAD_HIGH_PRIORITY 5
#define THREAD_LOW_PRIORITY 10

#define THREAD_DSP_FLAGS (K_ARC_DSP_REGS | K_ARC_AGU_REGS)
#define THREAD_DSP_FLAGS (K_DSP_REGS | K_AGU_REGS)

0 comments on commit b58a1f1

Please sign in to comment.