Skip to content

Commit d397a91

Browse files
peter-mitsiscfriedt
authored andcommitted
kernel: Add arch_coprocessors_disable()
The intent of arch_coprocessors_disable() is to replace arch_float_disable() in halt_thread() for the FPU will not always be the only coprocessor that will need to be disabled. Signed-off-by: Peter Mitsis <[email protected]>
1 parent decedca commit d397a91

File tree

14 files changed

+137
-3
lines changed

14 files changed

+137
-3
lines changed

arch/arc/core/thread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ int arch_float_enable(struct k_thread *thread, unsigned int options)
276276
}
277277
#endif /* CONFIG_FPU && CONFIG_FPU_SHARING */
278278

279+
int arch_coprocessors_disable(struct k_thread *thread)
280+
{
281+
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
282+
return arch_float_disable(thread);
283+
#else
284+
return -ENOTSUP;
285+
#endif
286+
}
287+
279288
#if !defined(CONFIG_MULTITHREADING)
280289

281290
K_KERNEL_STACK_ARRAY_DECLARE(z_interrupt_stacks, CONFIG_MP_MAX_NUM_CPUS, CONFIG_ISR_STACK_SIZE);

arch/arm/core/cortex_a_r/thread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,12 @@ int arch_float_enable(struct k_thread *thread, unsigned int options)
415415
return -ENOTSUP;
416416
}
417417
#endif /* CONFIG_FPU && CONFIG_FPU_SHARING */
418+
419+
int arch_coprocessors_disable(struct k_thread *thread)
420+
{
421+
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
422+
return arch_float_disable(thread);
423+
#else
424+
return -ENOTSUP;
425+
#endif
426+
}

arch/arm/core/cortex_m/thread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,15 @@ int arch_float_enable(struct k_thread *thread, unsigned int options)
462462
}
463463
#endif /* CONFIG_FPU && CONFIG_FPU_SHARING */
464464

465+
int arch_coprocessors_disable(struct k_thread *thread)
466+
{
467+
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
468+
return arch_float_disable(thread);
469+
#else
470+
return -ENOTSUP;
471+
#endif
472+
}
473+
465474
/* Internal function for Cortex-M initialization,
466475
* applicable to either case of running Zephyr
467476
* with or without multi-threading support.

arch/arm64/core/thread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,12 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
199199
CODE_UNREACHABLE;
200200
}
201201
#endif
202+
203+
int arch_coprocessors_disable(struct k_thread *thread)
204+
{
205+
#if defined(CONFIG_FPU_SHARING)
206+
return arch_float_disable(thread);
207+
#else
208+
return -ENOTSUP;
209+
#endif
210+
}

arch/mips/core/thread.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,8 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
3939

4040
thread->callee_saved.sp = (unsigned long)stack_init;
4141
}
42+
43+
int arch_coprocessors_disable(struct k_thread *thread)
44+
{
45+
return -ENOTSUP;
46+
}

arch/posix/core/thread.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ int arch_float_enable(struct k_thread *thread, unsigned int options)
115115
}
116116
#endif /* CONFIG_FPU && CONFIG_FPU_SHARING */
117117

118+
int arch_coprocessors_disable(struct k_thread *thread)
119+
{
120+
/* Posix does not support coprocessors */
121+
return -ENOTSUP;
122+
}
123+
118124
#if defined(CONFIG_ARCH_HAS_THREAD_ABORT)
119125
void z_impl_k_thread_abort(k_tid_t thread)
120126
{

arch/riscv/core/thread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,12 @@ FUNC_NORETURN void z_riscv_switch_to_main_no_multithreading(k_thread_entry_t mai
255255
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
256256
}
257257
#endif /* !CONFIG_MULTITHREADING */
258+
259+
int arch_coprocessors_disable(struct k_thread *thread)
260+
{
261+
#ifdef CONFIG_FPU_SHARING
262+
return arch_float_disable(thread);
263+
#else
264+
return -ENOTSUP;
265+
#endif
266+
}

arch/rx/core/thread.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, char *sta
5151

5252
thread->switch_handle = (void *)iframe;
5353
}
54+
55+
int arch_coprocessors_disable(struct k_thread *thread)
56+
{
57+
return -ENOTSUP;
58+
}

arch/sparc/core/thread.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,8 @@ int arch_float_enable(struct k_thread *thread, unsigned int options)
7777
return -ENOTSUP;
7878
}
7979
#endif /* CONFIG_FPU_SHARING */
80+
81+
int arch_coprocessors_disable(struct k_thread *thread)
82+
{
83+
return -ENOTSUP;
84+
}

arch/x86/core/ia32/thread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ int arch_float_enable(struct k_thread *thread, unsigned int options)
7272
}
7373
#endif /* CONFIG_FPU && CONFIG_FPU_SHARING */
7474

75+
int arch_coprocessors_disable(struct k_thread *thread)
76+
{
77+
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
78+
return arch_float_disable(thread);
79+
#else
80+
return -ENOTSUP;
81+
#endif
82+
}
83+
7584
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
7685
char *stack_ptr, k_thread_entry_t entry,
7786
void *p1, void *p2, void *p3)

0 commit comments

Comments
 (0)