Module fpu

Module fpu 

Source
Expand description

Floating-Point Unit and Vector context for RISC-V 64-bit

This module provides the FPU and Vector context structures for saving and restoring floating-point and vector register state during context switches.

§FPU (F/D Extensions)

RISC-V uses the F (single-precision) and D (double-precision) extensions with 32 floating-point registers (f0-f31, each 64-bit for D extension) and fcsr control/status register.

§Vector (V Extension)

RISC-V Vector extension provides 32 vector registers (v0-v31) with configurable VLEN (vector length). The actual size depends on the implementation. This module supports VLEN up to 256 bits (32 bytes per register, vlenb=32).

Modules§

fpu_switch 🔒

Structs§

FpuContext
FPU context for RISC-V 64-bit (F/D extensions)
VectorContext
Vector context for RISC-V 64-bit (V extension)

Constants§

MAX_VLENB
Maximum vector length in bytes (VLEN / 8) supported by this implementation. This supports VLEN up to 256 bits (32 bytes per register). QEMU virt machine typically uses VLEN=128 (vlenb=16).

Functions§

disable_fpu
Disable FPU access by setting sstatus.FS to Off.
disable_vector
Disable Vector extension access by setting sstatus.VS to Off.
enable_fpu
Enable FPU access by setting sstatus.FS to Initial state
enable_vector
Enable Vector extension access by setting sstatus.VS to Initial state
get_vlenb
Get the vector length in bytes (vlenb = VLEN / 8)
is_fpu_dirty
Check if the FPU state is marked Dirty in sstatus (FS == 0b11).
is_fpu_enabled
Check if FPU is enabled (sstatus.FS != Off)
is_vector_dirty
Check if the Vector state is marked Dirty in sstatus (VS == 0b11).
is_vector_enabled
Check if Vector extension is enabled (sstatus.VS != Off)
kernel_switch_in_user_fpu
Restore user FPU context when resuming a task in the kernel.
kernel_switch_out_user_fpu
Save user FPU context when switching away from a task in the kernel.
kernel_switch_out_user_vector
Handle user vector state on kernel switch-out.
mark_fpu_clean
Mark the FPU state as Clean in sstatus (FS = 0b10).
mark_vector_clean
Mark the Vector state as Clean in sstatus (VS = 0b10).