32 #ifndef _SYS_TIMEFF_H_ 33 #define _SYS_TIMEFF_H_ 35 #include <sys/_ffcounter.h> 44 struct bintime update_time;
45 ffcounter update_ffcount;
46 ffcounter leapsec_next;
51 int16_t leapsec_total;
60 SYSCTL_DECL(_kern_sysclock);
63 SYSCTL_DECL(_kern_sysclock_ffclock);
70 #define SYSCLOCK_FBCK 0 71 #define SYSCLOCK_FFWD 1 72 extern int sysclock_active;
77 #define FFCLOCK_SKM_SCALE 1024 82 #define FFCLOCK_STA_UNSYNC 1 83 #define FFCLOCK_STA_WARMUP 2 97 #define FFCLOCK_FAST 0x00000001 98 #define FFCLOCK_LERP 0x00000002 99 #define FFCLOCK_LEAPSEC 0x00000004 100 #define FFCLOCK_UPTIME 0x00000008 101 #define FFCLOCK_MASK 0x0000ffff 103 #define FBCLOCK_FAST 0x00010000 104 #define FBCLOCK_UPTIME 0x00020000 105 #define FBCLOCK_MASK 0xffff0000 112 struct fbclock_info {
113 struct bintime error;
114 struct bintime tick_time;
125 struct ffclock_info {
126 struct bintime error;
127 struct bintime tick_time;
128 struct bintime tick_time_lerp;
130 uint64_t period_lerp;
131 int leapsec_adjustment;
141 struct sysclock_snap {
142 struct fbclock_info fb_info;
143 struct ffclock_info ff_info;
150 void sysclock_getsnapshot(
struct sysclock_snap *clock_snap,
int fast);
153 int sysclock_snap2bintime(
struct sysclock_snap *cs,
struct bintime *bt,
154 int whichclock, uint32_t flags);
157 void ffclock_reset_clock(
struct timespec *ts);
164 void ffclock_read_counter(ffcounter *ffcount);
170 void ffclock_last_tick(ffcounter *ffcount,
struct bintime *bt, uint32_t flags);
177 void ffclock_convert_abs(ffcounter ffcount,
struct bintime *bt, uint32_t flags);
178 void ffclock_convert_diff(ffcounter ffdelta,
struct bintime *bt);
198 void ffclock_abstime(ffcounter *ffcount,
struct bintime *bt,
199 struct bintime *error_bound, uint32_t flags);
200 void ffclock_difftime(ffcounter ffdelta,
struct bintime *bt,
201 struct bintime *error_bound);
208 void ffclock_bintime(
struct bintime *bt);
209 void ffclock_nanotime(
struct timespec *tsp);
210 void ffclock_microtime(
struct timeval *tvp);
212 void ffclock_getbintime(
struct bintime *bt);
213 void ffclock_getnanotime(
struct timespec *tsp);
214 void ffclock_getmicrotime(
struct timeval *tvp);
216 void ffclock_binuptime(
struct bintime *bt);
217 void ffclock_nanouptime(
struct timespec *tsp);
218 void ffclock_microuptime(
struct timeval *tvp);
220 void ffclock_getbinuptime(
struct bintime *bt);
221 void ffclock_getnanouptime(
struct timespec *tsp);
222 void ffclock_getmicrouptime(
struct timeval *tvp);
228 void ffclock_bindifftime(ffcounter ffdelta,
struct bintime *bt);
229 void ffclock_nanodifftime(ffcounter ffdelta,
struct timespec *tsp);
230 void ffclock_microdifftime(ffcounter ffdelta,
struct timeval *tvp);
238 void fbclock_bintime(
struct bintime *bt);
239 void fbclock_nanotime(
struct timespec *tsp);
240 void fbclock_microtime(
struct timeval *tvp);
242 void fbclock_getbintime(
struct bintime *bt);
243 void fbclock_getnanotime(
struct timespec *tsp);
244 void fbclock_getmicrotime(
struct timeval *tvp);
246 void fbclock_binuptime(
struct bintime *bt);
247 void fbclock_nanouptime(
struct timespec *tsp);
248 void fbclock_microuptime(
struct timeval *tvp);
250 void fbclock_getbinuptime(
struct bintime *bt);
251 void fbclock_getnanouptime(
struct timespec *tsp);
252 void fbclock_getmicrouptime(
struct timeval *tvp);
261 bintime_fromclock(
struct bintime *bt,
int whichclock)
264 if (whichclock == SYSCLOCK_FFWD)
271 nanotime_fromclock(
struct timespec *tsp,
int whichclock)
274 if (whichclock == SYSCLOCK_FFWD)
275 ffclock_nanotime(tsp);
277 fbclock_nanotime(tsp);
281 microtime_fromclock(
struct timeval *tvp,
int whichclock)
284 if (whichclock == SYSCLOCK_FFWD)
285 ffclock_microtime(tvp);
287 fbclock_microtime(tvp);
291 getbintime_fromclock(
struct bintime *bt,
int whichclock)
294 if (whichclock == SYSCLOCK_FFWD)
295 ffclock_getbintime(bt);
297 fbclock_getbintime(bt);
301 getnanotime_fromclock(
struct timespec *tsp,
int whichclock)
304 if (whichclock == SYSCLOCK_FFWD)
305 ffclock_getnanotime(tsp);
307 fbclock_getnanotime(tsp);
311 getmicrotime_fromclock(
struct timeval *tvp,
int whichclock)
314 if (whichclock == SYSCLOCK_FFWD)
315 ffclock_getmicrotime(tvp);
317 fbclock_getmicrotime(tvp);
321 binuptime_fromclock(
struct bintime *bt,
int whichclock)
324 if (whichclock == SYSCLOCK_FFWD)
325 ffclock_binuptime(bt);
327 fbclock_binuptime(bt);
331 nanouptime_fromclock(
struct timespec *tsp,
int whichclock)
334 if (whichclock == SYSCLOCK_FFWD)
335 ffclock_nanouptime(tsp);
337 fbclock_nanouptime(tsp);
341 microuptime_fromclock(
struct timeval *tvp,
int whichclock)
344 if (whichclock == SYSCLOCK_FFWD)
345 ffclock_microuptime(tvp);
347 fbclock_microuptime(tvp);
351 getbinuptime_fromclock(
struct bintime *bt,
int whichclock)
354 if (whichclock == SYSCLOCK_FFWD)
355 ffclock_getbinuptime(bt);
357 fbclock_getbinuptime(bt);
361 getnanouptime_fromclock(
struct timespec *tsp,
int whichclock)
364 if (whichclock == SYSCLOCK_FFWD)
365 ffclock_getnanouptime(tsp);
367 fbclock_getnanouptime(tsp);
371 getmicrouptime_fromclock(
struct timeval *tvp,
int whichclock)
374 if (whichclock == SYSCLOCK_FFWD)
375 ffclock_getmicrouptime(tvp);
377 fbclock_getmicrouptime(tvp);
384 int ffclock_getcounter(ffcounter *ffcount);