arch: deprecate _current
`_current` is now functionally equals to `arch_curr_thread()`, remove its usage in-tree and deprecate it instead of removing it outright, as it has been with us since forever. Signed-off-by: Yong Cong Sin <ycsin@meta.com> Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
parent
1a752e8a35
commit
b1def7145f
107 changed files with 490 additions and 479 deletions
|
@ -177,7 +177,7 @@ ZTEST(arm_interrupt, test_arm_esf_collection)
|
|||
* crashy thread we create below runs to completion before we get
|
||||
* to the end of this function
|
||||
*/
|
||||
k_thread_priority_set(_current, K_PRIO_PREEMPT(MAIN_PRIORITY));
|
||||
k_thread_priority_set(arch_current_thread(), K_PRIO_PREEMPT(MAIN_PRIORITY));
|
||||
|
||||
TC_PRINT("Testing ESF Reporting\n");
|
||||
k_thread_create(&esf_collection_thread, esf_collection_stack,
|
||||
|
@ -366,9 +366,9 @@ ZTEST(arm_interrupt, test_arm_interrupt)
|
|||
uint32_t fp_extra_size =
|
||||
(__get_CONTROL() & CONTROL_FPCA_Msk) ?
|
||||
FPU_STACK_EXTRA_SIZE : 0;
|
||||
__set_PSP(_current->stack_info.start + 0x10 + fp_extra_size);
|
||||
__set_PSP(arch_current_thread()->stack_info.start + 0x10 + fp_extra_size);
|
||||
#else
|
||||
__set_PSP(_current->stack_info.start + 0x10);
|
||||
__set_PSP(arch_current_thread()->stack_info.start + 0x10);
|
||||
#endif
|
||||
|
||||
__enable_irq();
|
||||
|
|
|
@ -42,20 +42,20 @@ void z_impl_test_arm_user_syscall(void)
|
|||
* - PSPLIM register guards the privileged stack
|
||||
* - MSPLIM register still guards the interrupt stack
|
||||
*/
|
||||
zassert_true((_current->arch.mode & CONTROL_nPRIV_Msk) == 0,
|
||||
zassert_true((arch_current_thread()->arch.mode & CONTROL_nPRIV_Msk) == 0,
|
||||
"mode variable not set to PRIV mode in system call\n");
|
||||
|
||||
zassert_false(arch_is_user_context(),
|
||||
"arch_is_user_context() indicates nPRIV\n");
|
||||
|
||||
zassert_true(
|
||||
((__get_PSP() >= _current->arch.priv_stack_start) &&
|
||||
(__get_PSP() < (_current->arch.priv_stack_start +
|
||||
((__get_PSP() >= arch_current_thread()->arch.priv_stack_start) &&
|
||||
(__get_PSP() < (arch_current_thread()->arch.priv_stack_start +
|
||||
CONFIG_PRIVILEGED_STACK_SIZE))),
|
||||
"Process SP outside thread privileged stack limits\n");
|
||||
|
||||
#if defined(CONFIG_BUILTIN_STACK_GUARD)
|
||||
zassert_true(__get_PSPLIM() == _current->arch.priv_stack_start,
|
||||
zassert_true(__get_PSPLIM() == arch_current_thread()->arch.priv_stack_start,
|
||||
"PSPLIM not guarding the thread's privileged stack\n");
|
||||
zassert_true(__get_MSPLIM() == (uint32_t)z_interrupt_stacks,
|
||||
"MSPLIM not guarding the interrupt stack\n");
|
||||
|
@ -82,16 +82,16 @@ void arm_isr_handler(const void *args)
|
|||
* - MSPLIM register still guards the interrupt stack
|
||||
*/
|
||||
|
||||
zassert_true((_current->arch.mode & CONTROL_nPRIV_Msk) != 0,
|
||||
zassert_true((arch_current_thread()->arch.mode & CONTROL_nPRIV_Msk) != 0,
|
||||
"mode variable not set to nPRIV mode for user thread\n");
|
||||
|
||||
zassert_false(arch_is_user_context(),
|
||||
"arch_is_user_context() indicates nPRIV in ISR\n");
|
||||
|
||||
zassert_true(
|
||||
((__get_PSP() >= _current->stack_info.start) &&
|
||||
(__get_PSP() < (_current->stack_info.start +
|
||||
_current->stack_info.size))),
|
||||
((__get_PSP() >= arch_current_thread()->stack_info.start) &&
|
||||
(__get_PSP() < (arch_current_thread()->stack_info.start +
|
||||
arch_current_thread()->stack_info.size))),
|
||||
"Process SP outside thread stack limits\n");
|
||||
|
||||
static int first_call = 1;
|
||||
|
@ -101,7 +101,7 @@ void arm_isr_handler(const void *args)
|
|||
|
||||
/* Trigger thread yield() manually */
|
||||
(void)irq_lock();
|
||||
z_move_thread_to_end_of_prio_q(_current);
|
||||
z_move_thread_to_end_of_prio_q(arch_current_thread());
|
||||
SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
|
||||
irq_unlock(0);
|
||||
|
||||
|
@ -169,20 +169,20 @@ ZTEST(arm_thread_swap, test_arm_syscalls)
|
|||
* - PSPLIM register guards the default stack
|
||||
* - MSPLIM register guards the interrupt stack
|
||||
*/
|
||||
zassert_true((_current->arch.mode & CONTROL_nPRIV_Msk) == 0,
|
||||
zassert_true((arch_current_thread()->arch.mode & CONTROL_nPRIV_Msk) == 0,
|
||||
"mode variable not set to PRIV mode for supervisor thread\n");
|
||||
|
||||
zassert_false(arch_is_user_context(),
|
||||
"arch_is_user_context() indicates nPRIV\n");
|
||||
|
||||
zassert_true(
|
||||
((__get_PSP() >= _current->stack_info.start) &&
|
||||
(__get_PSP() < (_current->stack_info.start +
|
||||
_current->stack_info.size))),
|
||||
((__get_PSP() >= arch_current_thread()->stack_info.start) &&
|
||||
(__get_PSP() < (arch_current_thread()->stack_info.start +
|
||||
arch_current_thread()->stack_info.size))),
|
||||
"Process SP outside thread stack limits\n");
|
||||
|
||||
#if defined(CONFIG_BUILTIN_STACK_GUARD)
|
||||
zassert_true(__get_PSPLIM() == _current->stack_info.start,
|
||||
zassert_true(__get_PSPLIM() == arch_current_thread()->stack_info.start,
|
||||
"PSPLIM not guarding the default stack\n");
|
||||
zassert_true(__get_MSPLIM() == (uint32_t)z_interrupt_stacks,
|
||||
"MSPLIM not guarding the interrupt stack\n");
|
||||
|
|
|
@ -278,16 +278,16 @@ static void alt_thread_entry(void *p1, void *p2, void *p3)
|
|||
/* Verify that the _current_ (alt) thread is
|
||||
* initialized with EXC_RETURN.Ftype set
|
||||
*/
|
||||
zassert_true((_current->arch.mode_exc_return & EXC_RETURN_FTYPE) != 0,
|
||||
zassert_true((arch_current_thread()->arch.mode_exc_return & EXC_RETURN_FTYPE) != 0,
|
||||
"Alt thread FPCA flag not clear at initialization\n");
|
||||
#if defined(CONFIG_MPU_STACK_GUARD)
|
||||
/* Alt thread is created with K_FP_REGS set, so we
|
||||
* expect lazy stacking and long guard to be enabled.
|
||||
*/
|
||||
zassert_true((_current->arch.mode &
|
||||
zassert_true((arch_current_thread()->arch.mode &
|
||||
Z_ARM_MODE_MPU_GUARD_FLOAT_Msk) != 0,
|
||||
"Alt thread MPU GUAR DFLOAT flag not set at initialization\n");
|
||||
zassert_true((_current->base.user_options & K_FP_REGS) != 0,
|
||||
zassert_true((arch_current_thread()->base.user_options & K_FP_REGS) != 0,
|
||||
"Alt thread K_FP_REGS not set at initialization\n");
|
||||
zassert_true((FPU->FPCCR & FPU_FPCCR_LSPEN_Msk) != 0,
|
||||
"Lazy FP Stacking not set at initialization\n");
|
||||
|
@ -330,7 +330,7 @@ static void alt_thread_entry(void *p1, void *p2, void *p3)
|
|||
p_ztest_thread->arch.swap_return_value = SWAP_RETVAL;
|
||||
#endif
|
||||
|
||||
z_move_thread_to_end_of_prio_q(_current);
|
||||
z_move_thread_to_end_of_prio_q(arch_current_thread());
|
||||
|
||||
/* Modify the callee-saved registers by zero-ing them.
|
||||
* The main test thread will, later, assert that they
|
||||
|
@ -448,20 +448,20 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
*/
|
||||
load_callee_saved_regs(&ztest_thread_callee_saved_regs_init);
|
||||
|
||||
k_thread_priority_set(_current, K_PRIO_COOP(PRIORITY));
|
||||
k_thread_priority_set(arch_current_thread(), K_PRIO_COOP(PRIORITY));
|
||||
|
||||
/* Export current thread's callee-saved registers pointer
|
||||
* and arch.basepri variable pointer, into global pointer
|
||||
* variables, so they can be easily accessible by other
|
||||
* (alternative) test thread.
|
||||
*/
|
||||
p_ztest_thread = _current;
|
||||
p_ztest_thread = arch_current_thread();
|
||||
|
||||
/* Confirm initial conditions before starting the test. */
|
||||
test_flag = switch_flag;
|
||||
zassert_true(test_flag == false,
|
||||
"Switch flag not initialized properly\n");
|
||||
zassert_true(_current->arch.basepri == 0,
|
||||
zassert_true(arch_current_thread()->arch.basepri == 0,
|
||||
"Thread BASEPRI flag not clear at thread start\n");
|
||||
/* Verify, also, that the interrupts are unlocked. */
|
||||
#if defined(CONFIG_CPU_CORTEX_M_HAS_BASEPRI)
|
||||
|
@ -481,16 +481,16 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
"Main test thread does not start in privilege mode\n");
|
||||
|
||||
/* Assert that the mode status variable indicates privilege mode */
|
||||
zassert_true((_current->arch.mode & CONTROL_nPRIV_Msk) == 0,
|
||||
zassert_true((arch_current_thread()->arch.mode & CONTROL_nPRIV_Msk) == 0,
|
||||
"Thread nPRIV flag not clear for supervisor thread: 0x%0x\n",
|
||||
_current->arch.mode);
|
||||
arch_current_thread()->arch.mode);
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
|
||||
/* The main test thread is not (yet) actively using the FP registers */
|
||||
zassert_true((_current->arch.mode_exc_return & EXC_RETURN_FTYPE) != 0,
|
||||
zassert_true((arch_current_thread()->arch.mode_exc_return & EXC_RETURN_FTYPE) != 0,
|
||||
"Thread Ftype flag not set at initialization 0x%0x\n",
|
||||
_current->arch.mode);
|
||||
arch_current_thread()->arch.mode);
|
||||
|
||||
/* Verify that the main test thread is initialized with FPCA cleared. */
|
||||
zassert_true((__get_CONTROL() & CONTROL_FPCA_Msk) == 0,
|
||||
|
@ -503,7 +503,7 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
/* Clear the thread's floating-point callee-saved registers' container.
|
||||
* The container will, later, be populated by the swap mechanism.
|
||||
*/
|
||||
memset(&_current->arch.preempt_float, 0,
|
||||
memset(&arch_current_thread()->arch.preempt_float, 0,
|
||||
sizeof(struct _preempt_float));
|
||||
|
||||
/* Randomize the FP callee-saved registers at test initialization */
|
||||
|
@ -517,13 +517,13 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
/* The main test thread is using the FP registers, but the .mode
|
||||
* flag is not updated until the next context switch.
|
||||
*/
|
||||
zassert_true((_current->arch.mode_exc_return & EXC_RETURN_FTYPE) != 0,
|
||||
zassert_true((arch_current_thread()->arch.mode_exc_return & EXC_RETURN_FTYPE) != 0,
|
||||
"Thread Ftype flag not set at initialization\n");
|
||||
#if defined(CONFIG_MPU_STACK_GUARD)
|
||||
zassert_true((_current->arch.mode &
|
||||
zassert_true((arch_current_thread()->arch.mode &
|
||||
Z_ARM_MODE_MPU_GUARD_FLOAT_Msk) == 0,
|
||||
"Thread MPU GUAR DFLOAT flag not clear at initialization\n");
|
||||
zassert_true((_current->base.user_options & K_FP_REGS) == 0,
|
||||
zassert_true((arch_current_thread()->base.user_options & K_FP_REGS) == 0,
|
||||
"Thread K_FP_REGS not clear at initialization\n");
|
||||
zassert_true((FPU->FPCCR & FPU_FPCCR_LSPEN_Msk) == 0,
|
||||
"Lazy FP Stacking not clear at initialization\n");
|
||||
|
@ -552,13 +552,13 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
* explicitly required by the test.
|
||||
*/
|
||||
(void)irq_lock();
|
||||
z_move_thread_to_end_of_prio_q(_current);
|
||||
z_move_thread_to_end_of_prio_q(arch_current_thread());
|
||||
|
||||
/* Clear the thread's callee-saved registers' container.
|
||||
* The container will, later, be populated by the swap
|
||||
* mechanism.
|
||||
*/
|
||||
memset(&_current->callee_saved, 0, sizeof(_callee_saved_t));
|
||||
memset(&arch_current_thread()->callee_saved, 0, sizeof(_callee_saved_t));
|
||||
|
||||
/* Verify context-switch has not occurred yet. */
|
||||
test_flag = switch_flag;
|
||||
|
@ -672,7 +672,7 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
*/
|
||||
verify_callee_saved(
|
||||
&ztest_thread_callee_saved_regs_container,
|
||||
&_current->callee_saved);
|
||||
&arch_current_thread()->callee_saved);
|
||||
|
||||
/* Verify context-switch did occur. */
|
||||
test_flag = switch_flag;
|
||||
|
@ -688,7 +688,7 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
* the alternative thread modified it, since the thread
|
||||
* is now switched back in.
|
||||
*/
|
||||
zassert_true(_current->arch.basepri == 0,
|
||||
zassert_true(arch_current_thread()->arch.basepri == 0,
|
||||
"arch.basepri value not in accordance with the update\n");
|
||||
|
||||
#if defined(CONFIG_CPU_CORTEX_M_HAS_BASEPRI)
|
||||
|
@ -709,12 +709,12 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
|
||||
#if !defined(CONFIG_NO_OPTIMIZATIONS)
|
||||
/* The thread is now swapped-back in. */
|
||||
zassert_equal(_current->arch.swap_return_value, SWAP_RETVAL,
|
||||
zassert_equal(arch_current_thread()->arch.swap_return_value, SWAP_RETVAL,
|
||||
"Swap value not set as expected: 0x%x (0x%x)\n",
|
||||
_current->arch.swap_return_value, SWAP_RETVAL);
|
||||
zassert_equal(_current->arch.swap_return_value, ztest_swap_return_val,
|
||||
arch_current_thread()->arch.swap_return_value, SWAP_RETVAL);
|
||||
zassert_equal(arch_current_thread()->arch.swap_return_value, ztest_swap_return_val,
|
||||
"Swap value not returned as expected 0x%x (0x%x)\n",
|
||||
_current->arch.swap_return_value, ztest_swap_return_val);
|
||||
arch_current_thread()->arch.swap_return_value, ztest_swap_return_val);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
|
||||
|
@ -732,7 +732,7 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
*/
|
||||
verify_fp_callee_saved(
|
||||
&ztest_thread_fp_callee_saved_regs,
|
||||
&_current->arch.preempt_float);
|
||||
&arch_current_thread()->arch.preempt_float);
|
||||
|
||||
/* Verify that the main test thread restored the FPSCR bit-0. */
|
||||
zassert_true((__get_FPSCR() & 0x1) == 0x1,
|
||||
|
@ -741,13 +741,13 @@ ZTEST(arm_thread_swap, test_arm_thread_swap)
|
|||
/* The main test thread is using the FP registers, and the .mode
|
||||
* flag and MPU GUARD flag are now updated.
|
||||
*/
|
||||
zassert_true((_current->arch.mode_exc_return & EXC_RETURN_FTYPE) == 0,
|
||||
zassert_true((arch_current_thread()->arch.mode_exc_return & EXC_RETURN_FTYPE) == 0,
|
||||
"Thread Ftype flag not cleared after main returned back\n");
|
||||
#if defined(CONFIG_MPU_STACK_GUARD)
|
||||
zassert_true((_current->arch.mode &
|
||||
zassert_true((arch_current_thread()->arch.mode &
|
||||
Z_ARM_MODE_MPU_GUARD_FLOAT_Msk) != 0,
|
||||
"Thread MPU GUARD FLOAT flag not set\n");
|
||||
zassert_true((_current->base.user_options & K_FP_REGS) != 0,
|
||||
zassert_true((arch_current_thread()->base.user_options & K_FP_REGS) != 0,
|
||||
"Thread K_FPREGS not set after main returned back\n");
|
||||
zassert_true((FPU->FPCCR & FPU_FPCCR_LSPEN_Msk) != 0,
|
||||
"Lazy FP Stacking not set after main returned back\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue