File indexing completed on 2025-05-11 08:24:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 #ifndef _SYS_TIMEFF_H_
0042 #define _SYS_TIMEFF_H_
0043
0044 #include <sys/_ffcounter.h>
0045
0046
0047
0048
0049
0050
0051
0052 struct ffclock_estimate {
0053 struct bintime update_time;
0054 ffcounter update_ffcount;
0055 ffcounter leapsec_next;
0056 uint64_t period;
0057 uint32_t errb_abs;
0058 uint32_t errb_rate;
0059 uint32_t status;
0060 int16_t leapsec_total;
0061 int8_t leapsec;
0062 };
0063
0064 #if __BSD_VISIBLE
0065 #ifdef _KERNEL
0066
0067 #ifndef __rtems__
0068
0069 SYSCTL_DECL(_kern_sysclock);
0070
0071
0072 SYSCTL_DECL(_kern_sysclock_ffclock);
0073 #endif
0074
0075
0076
0077
0078
0079 #define SYSCLOCK_FBCK 0
0080 #define SYSCLOCK_FFWD 1
0081 extern int sysclock_active;
0082
0083
0084
0085
0086 #define FFCLOCK_SKM_SCALE 1024
0087
0088
0089
0090
0091 #define FFCLOCK_STA_UNSYNC 1
0092 #define FFCLOCK_STA_WARMUP 2
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 #define FFCLOCK_FAST 0x00000001
0107 #define FFCLOCK_LERP 0x00000002
0108 #define FFCLOCK_LEAPSEC 0x00000004
0109 #define FFCLOCK_UPTIME 0x00000008
0110 #define FFCLOCK_MASK 0x0000ffff
0111
0112 #define FBCLOCK_FAST 0x00010000
0113 #define FBCLOCK_UPTIME 0x00020000
0114 #define FBCLOCK_MASK 0xffff0000
0115
0116
0117
0118
0119
0120
0121 struct fbclock_info {
0122 struct bintime error;
0123 struct bintime tick_time;
0124 uint64_t th_scale;
0125 int status;
0126 };
0127
0128
0129
0130
0131
0132
0133
0134 struct ffclock_info {
0135 struct bintime error;
0136 struct bintime tick_time;
0137 struct bintime tick_time_lerp;
0138 uint64_t period;
0139 uint64_t period_lerp;
0140 int leapsec_adjustment;
0141 int status;
0142 };
0143
0144
0145
0146
0147
0148
0149
0150 struct sysclock_snap {
0151 struct fbclock_info fb_info;
0152 struct ffclock_info ff_info;
0153 ffcounter ffcount;
0154 unsigned int delta;
0155 int sysclock_active;
0156 };
0157
0158
0159 void sysclock_getsnapshot(struct sysclock_snap *clock_snap, int fast);
0160
0161
0162 int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt,
0163 int whichclock, uint32_t flags);
0164
0165
0166 void ffclock_reset_clock(struct timespec *ts);
0167
0168
0169
0170
0171
0172
0173 void ffclock_read_counter(ffcounter *ffcount);
0174
0175
0176
0177
0178
0179 void ffclock_last_tick(ffcounter *ffcount, struct bintime *bt, uint32_t flags);
0180
0181
0182
0183
0184
0185
0186 void ffclock_convert_abs(ffcounter ffcount, struct bintime *bt, uint32_t flags);
0187 void ffclock_convert_diff(ffcounter ffdelta, struct bintime *bt);
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207 void ffclock_abstime(ffcounter *ffcount, struct bintime *bt,
0208 struct bintime *error_bound, uint32_t flags);
0209 void ffclock_difftime(ffcounter ffdelta, struct bintime *bt,
0210 struct bintime *error_bound);
0211
0212
0213
0214
0215
0216
0217 void ffclock_bintime(struct bintime *bt);
0218 void ffclock_nanotime(struct timespec *tsp);
0219 void ffclock_microtime(struct timeval *tvp);
0220
0221 void ffclock_getbintime(struct bintime *bt);
0222 void ffclock_getnanotime(struct timespec *tsp);
0223 void ffclock_getmicrotime(struct timeval *tvp);
0224
0225 void ffclock_binuptime(struct bintime *bt);
0226 void ffclock_nanouptime(struct timespec *tsp);
0227 void ffclock_microuptime(struct timeval *tvp);
0228
0229 void ffclock_getbinuptime(struct bintime *bt);
0230 void ffclock_getnanouptime(struct timespec *tsp);
0231 void ffclock_getmicrouptime(struct timeval *tvp);
0232
0233
0234
0235
0236
0237 void ffclock_bindifftime(ffcounter ffdelta, struct bintime *bt);
0238 void ffclock_nanodifftime(ffcounter ffdelta, struct timespec *tsp);
0239 void ffclock_microdifftime(ffcounter ffdelta, struct timeval *tvp);
0240
0241
0242
0243
0244
0245
0246
0247 void fbclock_bintime(struct bintime *bt);
0248 void fbclock_nanotime(struct timespec *tsp);
0249 void fbclock_microtime(struct timeval *tvp);
0250
0251 void fbclock_getbintime(struct bintime *bt);
0252 void fbclock_getnanotime(struct timespec *tsp);
0253 void fbclock_getmicrotime(struct timeval *tvp);
0254
0255 void fbclock_binuptime(struct bintime *bt);
0256 void fbclock_nanouptime(struct timespec *tsp);
0257 void fbclock_microuptime(struct timeval *tvp);
0258
0259 void fbclock_getbinuptime(struct bintime *bt);
0260 void fbclock_getnanouptime(struct timespec *tsp);
0261 void fbclock_getmicrouptime(struct timeval *tvp);
0262
0263
0264
0265
0266
0267
0268
0269 static inline void
0270 bintime_fromclock(struct bintime *bt, int whichclock)
0271 {
0272
0273 if (whichclock == SYSCLOCK_FFWD)
0274 ffclock_bintime(bt);
0275 else
0276 fbclock_bintime(bt);
0277 }
0278
0279 static inline void
0280 nanotime_fromclock(struct timespec *tsp, int whichclock)
0281 {
0282
0283 if (whichclock == SYSCLOCK_FFWD)
0284 ffclock_nanotime(tsp);
0285 else
0286 fbclock_nanotime(tsp);
0287 }
0288
0289 static inline void
0290 microtime_fromclock(struct timeval *tvp, int whichclock)
0291 {
0292
0293 if (whichclock == SYSCLOCK_FFWD)
0294 ffclock_microtime(tvp);
0295 else
0296 fbclock_microtime(tvp);
0297 }
0298
0299 static inline void
0300 getbintime_fromclock(struct bintime *bt, int whichclock)
0301 {
0302
0303 if (whichclock == SYSCLOCK_FFWD)
0304 ffclock_getbintime(bt);
0305 else
0306 fbclock_getbintime(bt);
0307 }
0308
0309 static inline void
0310 getnanotime_fromclock(struct timespec *tsp, int whichclock)
0311 {
0312
0313 if (whichclock == SYSCLOCK_FFWD)
0314 ffclock_getnanotime(tsp);
0315 else
0316 fbclock_getnanotime(tsp);
0317 }
0318
0319 static inline void
0320 getmicrotime_fromclock(struct timeval *tvp, int whichclock)
0321 {
0322
0323 if (whichclock == SYSCLOCK_FFWD)
0324 ffclock_getmicrotime(tvp);
0325 else
0326 fbclock_getmicrotime(tvp);
0327 }
0328
0329 static inline void
0330 binuptime_fromclock(struct bintime *bt, int whichclock)
0331 {
0332
0333 if (whichclock == SYSCLOCK_FFWD)
0334 ffclock_binuptime(bt);
0335 else
0336 fbclock_binuptime(bt);
0337 }
0338
0339 static inline void
0340 nanouptime_fromclock(struct timespec *tsp, int whichclock)
0341 {
0342
0343 if (whichclock == SYSCLOCK_FFWD)
0344 ffclock_nanouptime(tsp);
0345 else
0346 fbclock_nanouptime(tsp);
0347 }
0348
0349 static inline void
0350 microuptime_fromclock(struct timeval *tvp, int whichclock)
0351 {
0352
0353 if (whichclock == SYSCLOCK_FFWD)
0354 ffclock_microuptime(tvp);
0355 else
0356 fbclock_microuptime(tvp);
0357 }
0358
0359 static inline void
0360 getbinuptime_fromclock(struct bintime *bt, int whichclock)
0361 {
0362
0363 if (whichclock == SYSCLOCK_FFWD)
0364 ffclock_getbinuptime(bt);
0365 else
0366 fbclock_getbinuptime(bt);
0367 }
0368
0369 static inline void
0370 getnanouptime_fromclock(struct timespec *tsp, int whichclock)
0371 {
0372
0373 if (whichclock == SYSCLOCK_FFWD)
0374 ffclock_getnanouptime(tsp);
0375 else
0376 fbclock_getnanouptime(tsp);
0377 }
0378
0379 static inline void
0380 getmicrouptime_fromclock(struct timeval *tvp, int whichclock)
0381 {
0382
0383 if (whichclock == SYSCLOCK_FFWD)
0384 ffclock_getmicrouptime(tvp);
0385 else
0386 fbclock_getmicrouptime(tvp);
0387 }
0388
0389 #else
0390
0391
0392 __BEGIN_DECLS
0393 int ffclock_getcounter(ffcounter *ffcount);
0394 int ffclock_getestimate(struct ffclock_estimate *cest);
0395 int ffclock_setestimate(struct ffclock_estimate *cest);
0396 __END_DECLS
0397
0398 #endif
0399 #endif
0400 #endif