#ifndef __MACHINE_FPU_H
#define __MACHINE_FPU_H
#include <config.h>
#include <object/structures.h>
#include <model/statedata.h>
#include <arch/machine/fpu.h>
#ifdef CONFIG_HAVE_FPU
void fpuThreadDelete(tcb_t *thread);
exception_t handleFPUFault(void);
void switchLocalFpuOwner(user_fpu_state_t *new_owner);
void switchFpuOwner(user_fpu_state_t *new_owner, word_t cpu);
static inline bool_t nativeThreadUsingFPU(tcb_t *thread)
{
return &thread->tcbArch.tcbContext.fpuState ==
NODE_STATE_ON_CORE(ksActiveFPUState, thread->tcbAffinity);
}
static inline void FORCE_INLINE lazyFPURestore(tcb_t *thread)
{
if (unlikely(NODE_STATE(ksActiveFPUState))) {
if (unlikely(NODE_STATE(ksFPURestoresSinceSwitch) > CONFIG_FPU_MAX_RESTORES_SINCE_SWITCH)) {
switchLocalFpuOwner(NULL);
NODE_STATE(ksFPURestoresSinceSwitch) = 0;
} else {
if (likely(nativeThreadUsingFPU(thread))) {
enableFpu();
} else {
disableFpu();
}
NODE_STATE(ksFPURestoresSinceSwitch)++;
}
} else {
}
}
#endif
#endif