pussuw commented on code in PR #9486:
URL: https://github.com/apache/nuttx/pull/9486#discussion_r1233682388
##########
arch/risc-v/src/common/riscv_fpu.S:
##########
@@ -57,18 +61,95 @@
* Returned Value:
* This function does not return anything explicitly.
*
-
************************************************************************************/
+ ****************************************************************************/
.type riscv_fpuconfig, function
riscv_fpuconfig:
- li a0, MSTATUS_FS_INIT
- csrs CSR_STATUS, a0
+ li a0, MSTATUS_FS_INIT
+ csrs CSR_STATUS, a0
+
+ fsflags zero
+ fsrm zero
+
+ fence.i
+ ret
+
+/****************************************************************************
+ * Name: riscv_savefpu
+ *
+ * Description:
+ * Given the pointer to a register save area (in A0), save the state of the
+ * floating point registers.
+ *
+ * C Function Prototype:
+ * void riscv_savefpu(uintptr_t *regs, uintptr_t *fregs);
+ *
+ * Input Parameters:
+ * regs - A pointer to the integer registers that contain the status
+ * fregs - A pointer to the register save area in which to save the
+ * floating point registers
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+ .type riscv_savefpu, function
+
+riscv_savefpu:
+
+ REGLOAD t0, REG_INT_CTX(a0)
+ li t1, MSTATUS_FS
+ and t2, t0, t1
+ li t1, MSTATUS_FS_DIRTY
+ bne t2, t1, 1f
+ li t1, ~MSTATUS_FS
+ and t0, t0, t1
+ li t1, MSTATUS_FS_CLEAN
+ or t0, t0, t1
+ REGSTORE t0, REG_INT_CTX(a0)
+
+ riscv_savefpu a1
+
+1:
+ ret
+
+/****************************************************************************
+ * Name: riscv_restorefpu
+ *
+ * Description:
+ * Given the pointer to a register save area (in A0), restore the state of
+ * the floating point registers.
+ *
+ * C Function Prototype:
+ * void riscv_restorefpu(uintptr_t *regs, uintptr_t *fregs);
+ *
+ * Input Parameters:
+ * regs - A pointer to the integer registers that contain the status
+ * fregs - A pointer to the register save area containing the floating
+ * point registers.
+ *
+ * Returned Value:
+ * This function does not return anything explicitly. However, it is
+ * called from interrupt level assembly logic that assumes that r0 is
+ * preserved.
+ *
+ ****************************************************************************/
+
+ .type riscv_restorefpu, function
+
+riscv_restorefpu:
+
+ REGLOAD t0, REG_INT_CTX(a0)
+ li t1, MSTATUS_FS
+ and t2, t0, t1
Review Comment:
True, but let's keep it as it does not change anything
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]