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