Skip to content
Permalink
Browse files

arch: implement arch-specific float disable routines

This commit adds the architecture-specific implementation
of k_float_disable() for ARM and x86.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information...
ioannisg authored and andrewboie committed May 9, 2019
1 parent a2029eb commit d840d1cbb574adf06fddff4c2eff4d28031b685b
Showing with 23 additions and 17 deletions.
  1. +20 −0 arch/arm/core/thread.c
  2. +3 −1 arch/x86/core/float.c
  3. +0 −16 include/arch/x86/arch.h
@@ -298,3 +298,23 @@ u32_t z_check_thread_stack_fail(const u32_t fault_addr, const u32_t psp)
return 0;
}
#endif /* CONFIG_MPU_STACK_GUARD || CONFIG_USERSPACE */

#if defined(CONFIG_FLOAT) && defined(CONFIG_FP_SHARING)
int z_arch_float_disable(struct k_thread *thread)
{
if (thread != _current) {
return -EINVAL;
}

if (z_is_in_isr()) {
return -EINVAL;
}

/* Disable all floating point capabilities for the thread */

thread->base.user_options &= ~K_FP_REGS;

__set_CONTROL(__get_CONTROL() & (~CONTROL_FPCA_Msk));
return 0;
}
#endif /* CONFIG_FLOAT && CONFIG_FP_SHARING */
@@ -192,7 +192,7 @@ void k_float_enable(struct k_thread *thread, unsigned int options)
* The locking isn't really needed when the routine is called by a cooperative
* thread (since context switching can't occur), but it is harmless.
*/
void k_float_disable(struct k_thread *thread)
int z_arch_float_disable(struct k_thread *thread)
{
unsigned int imask;

@@ -214,6 +214,8 @@ void k_float_disable(struct k_thread *thread)
}

irq_unlock(imask);

return 0;
}

/*
@@ -518,22 +518,6 @@ struct k_thread;
*/
extern void k_float_enable(struct k_thread *thread, unsigned int options);

/**
* @brief Disable preservation of floating point context information.
*
* This routine informs the kernel that the specified thread (which may be
* the current thread) will no longer be using the floating point registers.
*
* @warning
* This routine should only be used to disable floating point support for
* a thread that currently has such support enabled.
*
* @param thread ID of thread.
*
* @return N/A
*/
extern void k_float_disable(struct k_thread *thread);

/**
* @}
*/

0 comments on commit d840d1c

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