cpuport.h 1.6 KB

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