1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2018-10-03     Bernard      The first version
9  * 2020/11/20     BalanceTWK   Add FPU support
10  * 2023/01/04     WangShun     Adapt to CH32
11  * 2023/08/11     HPMicro      Define ARCH_RISCV_FPU if FPU is enabled
12  */
13 
14 #ifndef CPUPORT_H__
15 #define CPUPORT_H__
16 
17 #include <rtconfig.h>
18 
19 #ifndef __ASSEMBLY__
20 #ifdef RT_USING_SMP
21 typedef union {
22     unsigned long slock;
23     struct __arch_tickets {
24         unsigned short owner;
25         unsigned short next;
26     } tickets;
27 } rt_hw_spinlock_t;
28 #endif
29 #endif
30 
31 /* Preprocessor Definition */
32 #if __riscv_flen == 32
33 #define ARCH_RISCV_FPU
34 #define ARCH_RISCV_FPU_S
35 #endif
36 
37 #if __riscv_flen == 64
38 #define ARCH_RISCV_FPU
39 #define ARCH_RISCV_FPU_D
40 #endif
41 
42 /* bytes of register width  */
43 #ifdef ARCH_CPU_64BIT
44 #define STORE                   sd
45 #define LOAD                    ld
46 #define REGBYTES                8
47 #else
48 #define STORE                   sw
49 #define LOAD                    lw
50 #define REGBYTES                4
51 #endif
52 
53 /* Preprocessor Definition */
54 #ifdef ARCH_RISCV_FPU
55 #ifdef ARCH_RISCV_FPU_D
56 #define FSTORE                  fsd
57 #define FLOAD                   fld
58 #define FREGBYTES               8
59 #define rv_floatreg_t           rt_int64_t
60 #endif
61 #ifdef ARCH_RISCV_FPU_S
62 #define FSTORE                  fsw
63 #define FLOAD                   flw
64 #define FREGBYTES               4
65 #define rv_floatreg_t           rt_int32_t
66 #endif
67 #endif
68 
69 #endif
70