cpuport.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2006-2021, 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. */
  10. #ifndef CPUPORT_H__
  11. #define CPUPORT_H__
  12. #include <rtconfig.h>
  13. /* bytes of register width */
  14. #ifdef ARCH_CPU_64BIT
  15. #define STORE sd
  16. #define LOAD ld
  17. #define REGBYTES 8
  18. #else
  19. // error here, not portable
  20. #error "Not supported XLEN"
  21. #endif
  22. /* 33 general register */
  23. #define CTX_GENERAL_REG_NR 33
  24. #ifdef ENABLE_FPU
  25. /* 32 fpu register */
  26. #define CTX_FPU_REG_NR 32
  27. #else
  28. #define CTX_FPU_REG_NR 0
  29. #endif
  30. #ifdef ENABLE_VECTOR
  31. #if defined(ARCH_VECTOR_VLEN_128)
  32. #define CTX_VECTOR_REGS 64
  33. #elif defined(ARCH_VECTOR_VLEN_256)
  34. #define CTX_VECTOR_REGS 128
  35. #endif
  36. #define CTX_VECTOR_REG_NR (CTX_VECTOR_REGS + 4)
  37. #else
  38. #define CTX_VECTOR_REG_NR 0
  39. #endif
  40. /* all context registers */
  41. #define CTX_REG_NR (CTX_GENERAL_REG_NR + CTX_FPU_REG_NR + CTX_VECTOR_REG_NR)
  42. #ifdef RT_USING_SMP
  43. typedef union {
  44. unsigned long slock;
  45. struct __arch_tickets {
  46. unsigned short owner;
  47. unsigned short next;
  48. } tickets;
  49. } rt_hw_spinlock_t;
  50. #endif
  51. #ifndef __ASSEMBLY__
  52. #include <rtdef.h>
  53. rt_inline void rt_hw_dsb(void)
  54. {
  55. asm volatile("fence":::"memory");
  56. }
  57. rt_inline void rt_hw_dmb(void)
  58. {
  59. asm volatile("fence":::"memory");
  60. }
  61. rt_inline void rt_hw_isb(void)
  62. {
  63. asm volatile(".long 0x0000100F":::"memory");
  64. }
  65. #endif
  66. #endif
  67. #ifdef RISCV_U_MODE
  68. #define RISCV_USER_ENTRY 0xFFFFFFE000000000ULL
  69. #endif