vdso_arch.h 986 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2006-2026, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2026-04-27 rcitach init ver.
  9. */
  10. #ifndef RT_VDSO_ARCH_H
  11. #define RT_VDSO_ARCH_H
  12. #include <stdint.h>
  13. #define __RT_STRINGIFY(x...) #x
  14. #define RT_STRINGIFY(x...) __RT_STRINGIFY(x)
  15. #define rt_vdso_arch_barrier(cmd, ...) \
  16. __asm__ volatile(RT_STRINGIFY(cmd) " " RT_STRINGIFY(__VA_ARGS__)::: "memory")
  17. static inline uint64_t rt_vdso_arch_read_counter(void)
  18. {
  19. uint64_t value;
  20. uint64_t tmp;
  21. __asm__ volatile("mrs %0, CNTVCT_EL0" : "=r"(value));
  22. __asm__ volatile(
  23. "eor %0, %1, %1\n"
  24. "add %0, sp, %0\n"
  25. "ldr xzr, [%0]"
  26. : "=r"(tmp)
  27. : "r"(value));
  28. return value;
  29. }
  30. static inline void rt_vdso_arch_cpu_relax(void)
  31. {
  32. __asm__ volatile("yield" ::: "memory");
  33. }
  34. static inline void rt_vdso_arch_rmb(void)
  35. {
  36. rt_vdso_arch_barrier(dmb, ishld);
  37. }
  38. #endif