pspsdk-1.0+beta2
pspfpu.h File Reference
#include <stdint.h>
Include dependency graph for pspfpu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FPU_RM_MASK   0x03
 Mask value for rounding mode.
#define FPU_FLAGS_POS   2
 Bit position of the flag bits.
#define FPU_ENABLE_POS   7
 Bit position of the enable bits.
#define FPU_CAUSE_POS   12
 Bit position of the cause bits.
#define FPU_CC0_POS   23
 Bit position of the cc0 bit.
#define FPU_FS_POS   24
 Bit position of the fs bit.
#define FPU_CC17_POS   25
 Bit position of the cc1->7 bits.
#define FPU_FLAGS_MASK   (0x1F << FPU_FLAGS_POS)
#define FPU_ENABLE_MASK   (0x1F << FPU_ENABLE_POS)
#define FPU_CAUSE_MASK   (0x3F << FPU_CAUSE_POS)
#define FPU_CC0_MASK   (1 << FPU_CC0_POS)
#define FPU_FS_MASK   (1 << FPU_FS_POS)
#define FPU_CC17_MASK   (0x7F << FPU_CC17_POS)

Enumerations

enum  FpuRoundMode { FPU_RN = 0, FPU_RZ = 1, FPU_RP = 2, FPU_RM = 3 }
 Enumeration for FPU rounding modes. More...
enum  FpuExceptions {
  FPU_EXCEPTION_INEXACT = 0x01, FPU_EXCEPTION_UNDERFLOW = 0x02, FPU_EXCEPTION_OVERFLOW = 0x04, FPU_EXCEPTION_DIVBYZERO = 0x08,
  FPU_EXCEPTION_INVALIDOP = 0x10, FPU_EXCEPTION_UNIMPOP = 0x20, FPU_EXCEPTION_ALL = 0x3F
}
 Enumeration for FPU exceptions. More...

Functions

uint32_t pspfpu_get_fcr31 (void)
 Get the current value of the control/status register.
void pspfpu_set_fcr31 (uint32_t var)
 Set the current value of the control/status register.
void pspfpu_set_roundmode (enum FpuRoundMode mode)
 Set the current round mode.
enum FpuRoundMode pspfpu_get_roundmode (void)
 Get the current round mode.
uint32_t pspfpu_get_flags (void)
 Get the exception flags (set when an exception occurs but the actual exception bit is not enabled)
void pspfpu_clear_flags (uint32_t clear)
 Clear the flags bits.
uint32_t pspfpu_get_enable (void)
 Get the exception enable flags.
void pspfpu_set_enable (uint32_t enable)
 Set the enable flags bits.
uint32_t pspfpu_get_cause (void)
 Get the cause bits (only useful if you installed your own exception handler)
void pspfpu_clear_cause (uint32_t clear)
 Clear the cause bits.
uint32_t pspfpu_get_fs (void)
 Get the current value of the FS bit (if FS is 0 then an exception occurs with denormalized values, if 1 then they are rewritten as 0.
void pspfpu_set_fs (uint32_t fs)
 Set the FS bit.
uint32_t pspfpu_get_condbits (void)
 Get the condition flags (8 bits)
void pspfpu_clear_condbits (uint32_t clear)
 Clear the condition bits.

Macro Definition Documentation

#define FPU_CAUSE_MASK   (0x3F << FPU_CAUSE_POS)

Referenced by pspfpu_get_cause().

#define FPU_CAUSE_POS   12

Bit position of the cause bits.

Referenced by pspfpu_clear_cause(), and pspfpu_get_cause().

#define FPU_CC0_MASK   (1 << FPU_CC0_POS)

Referenced by pspfpu_get_condbits().

#define FPU_CC0_POS   23

Bit position of the cc0 bit.

Referenced by pspfpu_clear_condbits(), and pspfpu_get_condbits().

#define FPU_CC17_MASK   (0x7F << FPU_CC17_POS)

Referenced by pspfpu_get_condbits().

#define FPU_CC17_POS   25

Bit position of the cc1->7 bits.

Referenced by pspfpu_clear_condbits(), and pspfpu_get_condbits().

#define FPU_ENABLE_MASK   (0x1F << FPU_ENABLE_POS)
#define FPU_ENABLE_POS   7

Bit position of the enable bits.

Referenced by pspfpu_get_enable(), and pspfpu_set_enable().

#define FPU_FLAGS_MASK   (0x1F << FPU_FLAGS_POS)

Referenced by pspfpu_get_flags().

#define FPU_FLAGS_POS   2

Bit position of the flag bits.

Referenced by pspfpu_clear_flags(), and pspfpu_get_flags().

#define FPU_FS_MASK   (1 << FPU_FS_POS)

Referenced by pspfpu_get_fs(), and pspfpu_set_fs().

#define FPU_FS_POS   24

Bit position of the fs bit.

Referenced by pspfpu_get_fs(), and pspfpu_set_fs().

#define FPU_RM_MASK   0x03

Mask value for rounding mode.

Referenced by pspfpu_get_roundmode(), and pspfpu_set_roundmode().

Enumeration Type Documentation

Enumeration for FPU exceptions.

Enumerator:
FPU_EXCEPTION_INEXACT 

Inexact operation exception.

FPU_EXCEPTION_UNDERFLOW 

Underflow exception.

FPU_EXCEPTION_OVERFLOW 

Overflow exception.

FPU_EXCEPTION_DIVBYZERO 

Division by zero exception.

FPU_EXCEPTION_INVALIDOP 

Invalid operation exception.

FPU_EXCEPTION_UNIMPOP 

Unimplemented operation exception (only supported in the cause bits)

FPU_EXCEPTION_ALL 

All exceptions.

Enumeration for FPU rounding modes.

Enumerator:
FPU_RN 

Round to nearest representable value.

FPU_RZ 

Round towards zero.

FPU_RP 

Round towards plus infinity.

FPU_RM 

Round towards minus infinity.

Function Documentation

void pspfpu_clear_cause ( uint32_t  clear)

Clear the cause bits.

Parameters
clear- Bitmask of the bits to clear, one or more of FpuExceptions

References FPU_CAUSE_POS, pspfpu_get_fcr31(), pspfpu_set_fcr31(), and uint32_t.

void pspfpu_clear_condbits ( uint32_t  clear)

Clear the condition bits.

Parameters
clear- Bitmask of the bits to clear

References FPU_CC0_POS, FPU_CC17_POS, pspfpu_get_fcr31(), pspfpu_set_fcr31(), and uint32_t.

void pspfpu_clear_flags ( uint32_t  clear)

Clear the flags bits.

Parameters
clear- Bitmask of the bits to clear, one or more of FpuExceptions

References FPU_FLAGS_POS, pspfpu_get_fcr31(), pspfpu_set_fcr31(), and uint32_t.

uint32_t pspfpu_get_cause ( void  )

Get the cause bits (only useful if you installed your own exception handler)

Returns
Bitmask of flags, zero or more of FpuExceptions

References FPU_CAUSE_MASK, FPU_CAUSE_POS, pspfpu_get_fcr31(), and uint32_t.

uint32_t pspfpu_get_condbits ( void  )

Get the condition flags (8 bits)

Returns
The current condition flags

References FPU_CC0_MASK, FPU_CC0_POS, FPU_CC17_MASK, FPU_CC17_POS, pspfpu_get_fcr31(), and uint32_t.

uint32_t pspfpu_get_enable ( void  )

Get the exception enable flags.

Returns
Bitmask of the flags, zero or more of FpuExceptions

References FPU_ENABLE_MASK, FPU_ENABLE_POS, pspfpu_get_fcr31(), and uint32_t.

uint32_t pspfpu_get_fcr31 ( void  )
uint32_t pspfpu_get_flags ( void  )

Get the exception flags (set when an exception occurs but the actual exception bit is not enabled)

Returns
Bitmask of the flags, zero or more of FpuExceptions

References FPU_FLAGS_MASK, FPU_FLAGS_POS, pspfpu_get_fcr31(), and uint32_t.

uint32_t pspfpu_get_fs ( void  )

Get the current value of the FS bit (if FS is 0 then an exception occurs with denormalized values, if 1 then they are rewritten as 0.

Returns
The current state of the FS bit (0 or 1)

References FPU_FS_MASK, FPU_FS_POS, pspfpu_get_fcr31(), and uint32_t.

enum FpuRoundMode pspfpu_get_roundmode ( void  )

Get the current round mode.

Returns
The round mode, one of FpuRoundMode

References FPU_RM_MASK, and pspfpu_get_fcr31().

void pspfpu_set_enable ( uint32_t  enable)

Set the enable flags bits.

Parameters
enable- Bitmask of exceptions to enable, zero or more of FpuExceptions

References FPU_ENABLE_MASK, FPU_ENABLE_POS, pspfpu_get_fcr31(), pspfpu_set_fcr31(), and uint32_t.

void pspfpu_set_fcr31 ( uint32_t  var)

Set the current value of the control/status register.

Parameters
var- The value to set.

Referenced by pspfpu_clear_cause(), pspfpu_clear_condbits(), pspfpu_clear_flags(), pspfpu_set_enable(), pspfpu_set_fs(), and pspfpu_set_roundmode().

void pspfpu_set_fs ( uint32_t  fs)

Set the FS bit.

Parameters
fs- 0 or 1 to unset or set fs

References FPU_FS_MASK, FPU_FS_POS, pspfpu_get_fcr31(), pspfpu_set_fcr31(), and uint32_t.

void pspfpu_set_roundmode ( enum FpuRoundMode  mode)

Set the current round mode.

Parameters
mode- The rounding mode to set, one of FpuRoundMode

References FPU_RM_MASK, pspfpu_get_fcr31(), pspfpu_set_fcr31(), and uint32_t.