vdso_arch.h 906 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. uint32_t lo;
  20. uint32_t hi;
  21. __asm__ volatile("mrrc p15, 1, %0, %1, c14" : "=r"(lo), "=r"(hi));
  22. rt_vdso_arch_barrier(dmb, ish);
  23. return ((uint64_t)hi << 32) | lo;
  24. }
  25. static inline void rt_vdso_arch_cpu_relax(void)
  26. {
  27. __asm__ volatile("yield" ::: "memory");
  28. }
  29. static inline void rt_vdso_arch_rmb(void)
  30. {
  31. rt_vdso_arch_barrier(dmb, ish);
  32. }
  33. #endif