vdso_datapage.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. * 2024-07-04 rcitach init ver.
  9. */
  10. #ifndef _VDSO_DATAPAGE_H
  11. #define _VDSO_DATAPAGE_H
  12. #include <time.h>
  13. #include <sys/types.h>
  14. #include "vdso_config.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. typedef signed char __s8;
  19. typedef signed short __s16;
  20. typedef signed int __s32;
  21. typedef signed long __s64;
  22. typedef unsigned char __u8;
  23. typedef unsigned short __u16;
  24. typedef unsigned int __u32;
  25. typedef unsigned long __u64;
  26. #define MAX_CLOCKS 16
  27. #define VDSO_BASES (CLOCK_TAI + 1)
  28. #define VDSO_REALTIME (BIT_MASK(CLOCK_REALTIME) | \
  29. BIT_MASK(CLOCK_REALTIME_COARSE))
  30. #define VDSO_MONOTIME (BIT_MASK(CLOCK_MONOTONIC) | \
  31. BIT_MASK(CLOCK_MONOTONIC_COARSE) | \
  32. BIT_MASK(CLOCK_MONOTONIC_RAW) | \
  33. BIT_MASK(CLOCK_BOOTTIME))
  34. #define CS_HRES_COARSE 0
  35. #define CS_RAW 1
  36. #define CS_BASES (CS_RAW + 1)
  37. /* 2018-01-30 14:44:50 = RTC_TIME_INIT(2018, 1, 30, 14, 44, 50) */
  38. #define RTC_VDSOTIME_INIT(year, month, day, hour, minute, second) \
  39. {.tm_year = year - 1900, .tm_mon = month - 1, .tm_mday = day, .tm_hour = hour, .tm_min = minute, .tm_sec = second}
  40. #ifndef SOFT_RTC_VDSOTIME_DEFAULT
  41. #define SOFT_RTC_VDSOTIME_DEFAULT RTC_VDSOTIME_INIT(2018, 1, 1, 0, 0 ,0)
  42. #endif
  43. struct vdso_data {
  44. uint32_t seq;
  45. uint32_t clock_mode;
  46. uint64_t realtime_initdata;
  47. uint64_t cycle_last;
  48. struct timespec basetime[VDSO_BASES];
  49. };
  50. typedef struct vdso_data *vdso_data_t;
  51. #define MSEC_PER_SEC 1000L
  52. #define USEC_PER_MSEC 1000L
  53. #define NSEC_PER_USEC 1000L
  54. #define NSEC_PER_MSEC 1000000L
  55. #define USEC_PER_SEC 1000000L
  56. #define NSEC_PER_SEC 1000000000L
  57. #define FSEC_PER_SEC 1000000000000000LL
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif /* _VDSO_DATAPAGE_H */