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§
Structs§
- FpuContext
- FPU context for RISC-V 64-bit (F/D extensions)
- Vector
Context - 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).