MentOS  0.8.0
The Mentoring Operating System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Macros | Functions | Variables
fpu.c File Reference

Floating Point Unit (FPU). More...

Macros

#define __DEBUG_HEADER__   "[FPU ]"
 Change header.
 
#define __DEBUG_LEVEL__   LOGLEVEL_NOTICE
 Set log level.
 

Functions

static void __set_fpu_cw (const uint16_t cw)
 Set the FPU control word. More...
 
static void __enable_fpu (void)
 Enable the FPU and SSE.
 
static void __disable_fpu (void)
 Disable FPU and SSE so it traps to the kernel.
 
static void __restore_fpu (task_struct *proc)
 Restore the FPU for a process. More...
 
static void __save_fpu (task_struct *proc)
 Save the FPU for a process. More...
 
static void __init_fpu (void)
 Initialize the FPU.
 
static void __invalid_op (pt_regs *f)
 
static void __sigfpe_handler (pt_regs *f)
 
static int __fpu_test (void)
 Ensure basic FPU functionality works. More...
 
void switch_fpu (void)
 Called during a context switch to save the FPU registers status of the currently running thread.
 
void unswitch_fpu (void)
 Called during a context switch to load the FPU registers status of the currently running thread inside the FPU.
 
int fpu_install (void)
 Enable the FPU context handling. More...
 

Variables

task_structthread_using_fpu = NULL
 Pointerst to the current thread using the FPU.
 
uint8_t saves[512] _syscall0 = _syscall0( (aligned(16)) )= _syscall1( (aligned(16)) )= _syscall2( (aligned(16)) )= _syscall3( (aligned(16)) )=
 Temporary aligned buffer for copying around FPU contexts.
 

Detailed Description

Floating Point Unit (FPU).

Function Documentation

◆ __fpu_test()

static int __fpu_test ( void  )
static

Ensure basic FPU functionality works.

For processors without a FPU, this tests that maths libraries link correctly.

Returns
1 on success, 0 on failure.

◆ __invalid_op()

static void __invalid_op ( pt_regs f)
inlinestatic

Kernel trap for FPU usage when FPU is disabled.

Parameters
fThe interrupt stack frame.

◆ __restore_fpu()

static void __restore_fpu ( task_struct proc)
inlinestatic

Restore the FPU for a process.

Parameters
procthe process for which we are restoring the FPU registers.

◆ __save_fpu()

static void __save_fpu ( task_struct proc)
inlinestatic

Save the FPU for a process.

Parameters
procthe process for which we are saving the FPU registers.

◆ __set_fpu_cw()

static void __set_fpu_cw ( const uint16_t  cw)
inlinestatic

Set the FPU control word.

Parameters
cwWhat to set the control word to.

◆ __sigfpe_handler()

static void __sigfpe_handler ( pt_regs f)
inlinestatic

Kernel trap for various integer and floating-point errors

Parameters
fThe interrupt stack frame.