cpuport.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. */
  12. #ifndef CPUPORT_H__
  13. #define CPUPORT_H__
  14. #include <rtconfig.h>
  15. #ifndef __ASSEMBLY__
  16. #ifdef RT_USING_SMP
  17. typedef union {
  18. unsigned long slock;
  19. struct __arch_tickets {
  20. unsigned short owner;
  21. unsigned short next;
  22. } tickets;
  23. } rt_hw_spinlock_t;
  24. #endif
  25. #endif
  26. /* Preprocessor Definition */
  27. #if __riscv_flen == 32
  28. #define ARCH_RISCV_FPU_S
  29. #endif
  30. #if __riscv_flen == 64
  31. #define ARCH_RISCV_FPU_D
  32. #endif
  33. /* bytes of register width */
  34. #ifdef ARCH_CPU_64BIT
  35. #define STORE sd
  36. #define LOAD ld
  37. #define REGBYTES 8
  38. #else
  39. #define STORE sw
  40. #define LOAD lw
  41. #define REGBYTES 4
  42. #endif
  43. /* Preprocessor Definition */
  44. #ifdef ARCH_RISCV_FPU
  45. #ifdef ARCH_RISCV_FPU_D
  46. #define FSTORE fsd
  47. #define FLOAD fld
  48. #define FREGBYTES 8
  49. #define rv_floatreg_t rt_int64_t
  50. #endif
  51. #ifdef ARCH_RISCV_FPU_S
  52. #define FSTORE fsw
  53. #define FLOAD flw
  54. #define FREGBYTES 4
  55. #define rv_floatreg_t rt_int32_t
  56. #endif
  57. #endif
  58. #endif