Skip to content

Commit ba7e281

Browse files
committed
port: riscv: Create some macros for the FPU context
1 parent 4939884 commit ba7e281

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

portable/GCC/RISC-V/portContext.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,36 @@
5959
#endif
6060
#define portICONTEXT_SIZE ( portIREG_COUNT * portWORD_SIZE )
6161

62-
#define portCONTEXT_SIZE ( portICONTEXT_SIZE )
62+
/* Provide a value for the reserved size for the FPU registers. portFPUCONTEXT_SIZE is always defined,
63+
* but it may be 0 if the FPU is not used */
64+
#ifdef portasmSTORE_FPU_CONTEXT
65+
#define MSTATUS_FS_MASK 0x6000 /* Floating-point Unit Status in mstatus register */
66+
#define MSTATUS_FS_INITIAL 0x2000
67+
#define MSTATUS_FS_CLEAN 0x4000
68+
#define MSTATUS_FS_DIRTY 0x6000
69+
#define MSTATUS_FS_USED_OFFSET 14
70+
#ifdef __riscv_fdiv
71+
#define portFPUREG_SIZE (__riscv_flen / 8)
72+
#if __riscv_flen == 32
73+
#define load_f flw
74+
#define store_f fsw
75+
#elif __riscv_flen == 64
76+
#define load_f fld
77+
#define store_f fsd
78+
#else
79+
#error Assembler did not define __riscv_flen
80+
#endif
81+
#define portFPUREG_COUNT 33 /* 32 Floating point registers plus one CSR */
82+
#define portFPUREG_OFFSET(_fpureg_) (_fpureg_ * portFPUREG_SIZE + portICONTEXT_SIZE)
83+
#define portFPUCONTEXT_SIZE (portFPUREG_SIZE * portFPUREG_COUNT)
84+
#else
85+
#define portFPUCONTEXT_SIZE 0
86+
#endif
87+
#else
88+
#define portFPUCONTEXT_SIZE 0
89+
#endif
90+
91+
#define portCONTEXT_SIZE ( portICONTEXT_SIZE + portFPUCONTEXT_SIZE )
6392
/*-----------------------------------------------------------*/
6493

6594
.extern pxCurrentTCB

0 commit comments

Comments
 (0)