cpuport.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. rt_inline void rt_hw_dsb()
  53. {
  54. asm volatile("fence":::"memory");
  55. }
  56. rt_inline void rt_hw_dmb()
  57. {
  58. asm volatile("fence":::"memory");
  59. }
  60. rt_inline void rt_hw_isb()
  61. {
  62. asm volatile(".long 0x0000100F":::"memory");
  63. }
  64. #endif
  65. #endif
  66. #ifdef RISCV_U_MODE
  67. #define RISCV_USER_ENTRY 0xFFFFFFE000000000ULL
  68. #endif