1
0

vdso_data.c 915 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2006-2025 RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2025-04-22 ScuDays Add VDSO functionality under the riscv64 architecture.
  9. */
  10. #include <rtthread.h>
  11. #include <ktime.h>
  12. #include <time.h>
  13. #include <vdso_datapage.h>
  14. #include <vdso_data.h>
  15. #include <encoding.h>
  16. void rt_vdso_update_glob_time(void)
  17. {
  18. struct vdso_data *vdata = get_k_vdso_data();
  19. struct timespec *vdso_ts;
  20. uint64_t initdata = vdata->realtime_initdata;
  21. rt_vdso_write_begin(vdata);
  22. vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME];
  23. rt_ktime_boottime_get_ns(vdso_ts);
  24. vdso_ts->tv_sec = initdata + vdso_ts->tv_sec;
  25. vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC];
  26. rt_ktime_boottime_get_ns(vdso_ts);
  27. vdata->cycle_last = rdtime();
  28. rt_vdso_write_end(vdata);
  29. }