28#ifndef _SYS_TIMEPPS_H_
29#define _SYS_TIMEPPS_H_
32#include <sys/ioccom.h>
37#define hardpps _Timecounter_Discipline
43#define PPS_API_VERS_1 1
45typedef int pps_handle_t;
48typedef unsigned pps_seq_t;
50typedef Atomic_Uint pps_seq_t;
54 unsigned int integral;
55 unsigned int fractional;
59 struct timespec tspec;
61 unsigned long longpad[3];
65 pps_seq_t assert_sequence;
66 pps_seq_t clear_sequence;
73 pps_seq_t assert_sequence;
74 pps_seq_t clear_sequence;
77 ffcounter assert_ffcount;
78 ffcounter clear_ffcount;
82#define assert_timestamp assert_tu.tspec
83#define clear_timestamp clear_tu.tspec
85#define assert_timestamp_ntpfp assert_tu.ntpfp
86#define clear_timestamp_ntpfp clear_tu.ntpfp
95#define assert_offset assert_off_tu.tspec
96#define clear_offset clear_off_tu.tspec
98#define assert_offset_ntpfp assert_off_tu.ntpfp
99#define clear_offset_ntpfp clear_off_tu.ntpfp
102#define PPS_CAPTUREASSERT 0x01
103#define PPS_CAPTURECLEAR 0x02
104#define PPS_CAPTUREBOTH 0x03
106#define PPS_OFFSETASSERT 0x10
107#define PPS_OFFSETCLEAR 0x20
109#define PPS_ECHOASSERT 0x40
110#define PPS_ECHOCLEAR 0x80
112#define PPS_CANWAIT 0x100
113#define PPS_CANPOLL 0x200
115#define PPS_TSFMT_TSPEC 0x1000
116#define PPS_TSFMT_NTPFP 0x2000
118#define PPS_TSCLK_FBCK 0x10000
119#define PPS_TSCLK_FFWD 0x20000
120#define PPS_TSCLK_MASK 0x30000
122#define PPS_KC_HARDPPS 0
123#define PPS_KC_HARDPPS_PLL 1
124#define PPS_KC_HARDPPS_FLL 2
129 struct timespec timeout;
135 struct timespec timeout;
144#define PPS_IOC_CREATE _IO('1', 1)
145#define PPS_IOC_DESTROY _IO('1', 2)
146#define PPS_IOC_SETPARAMS _IOW('1', 3, pps_params_t)
147#define PPS_IOC_GETPARAMS _IOR('1', 4, pps_params_t)
148#define PPS_IOC_GETCAP _IOR('1', 5, int)
149#define PPS_IOC_FETCH _IOWR('1', 6, struct pps_fetch_args)
150#define PPS_IOC_KCBIND _IOW('1', 7, struct pps_kcbind_args)
151#define PPS_IOC_FETCH_FFCOUNTER _IOWR('1', 8, struct pps_fetch_ffc_args)
157#define KCMODE_EDGEMASK 0x03
158#define KCMODE_ABIFLAG 0x80000000
160#define PPS_ABI_VERSION 1
162#define PPSFLAG_MTX_SPIN 0x01
167 struct fftimehands *capffth;
178 unsigned ppscount[3];
194 int (*wait)(
struct pps_state *pps,
struct timespec timeout);
201 void (*wakeup)(
struct pps_state *pps);
208 struct mtx *driver_mtx;
212void pps_capture(
struct pps_state *pps);
213void pps_event(
struct pps_state *pps,
int event);
214void pps_init(
struct pps_state *pps);
215void pps_init_abi(
struct pps_state *pps);
216int pps_ioctl(
unsigned long cmd, caddr_t data,
struct pps_state *pps);
217void hardpps(
struct timespec *tsp,
long nsec);
222time_pps_create(
int filedes, pps_handle_t *handle)
227 error = ioctl(filedes, PPS_IOC_CREATE, 0);
235time_pps_destroy(pps_handle_t handle)
237 return (ioctl(handle, PPS_IOC_DESTROY, 0));
241time_pps_setparams(pps_handle_t handle,
const pps_params_t *ppsparams)
243 return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams));
247time_pps_getparams(pps_handle_t handle,
pps_params_t *ppsparams)
249 return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams));
253time_pps_getcap(pps_handle_t handle,
int *mode)
255 return (ioctl(handle, PPS_IOC_GETCAP, mode));
259time_pps_fetch(pps_handle_t handle,
const int tsformat,
260 pps_info_t *ppsinfobuf,
const struct timespec *timeout)
265 arg.tsformat = tsformat;
266 if (timeout == NULL) {
267 arg.timeout.tv_sec = -1;
268 arg.timeout.tv_nsec = -1;
270 arg.timeout = *timeout;
271 error = ioctl(handle, PPS_IOC_FETCH, &arg);
272 *ppsinfobuf = arg.pps_info_buf;
277time_pps_fetch_ffc(pps_handle_t handle,
const int tsformat,
283 arg.tsformat = tsformat;
284 if (timeout == NULL) {
285 arg.timeout.tv_sec = -1;
286 arg.timeout.tv_nsec = -1;
288 arg.timeout = *timeout;
290 error = ioctl(handle, PPS_IOC_FETCH_FFCOUNTER, &arg);
291 *ppsinfobuf = arg.pps_info_buf_ffc;
296time_pps_kcbind(pps_handle_t handle,
const int kernel_consumer,
297 const int edge,
const int tsformat)
301 arg.kernel_consumer = kernel_consumer;
303 arg.tsformat = tsformat;
304 return (ioctl(handle, PPS_IOC_KCBIND, &arg));
This header file provides interfaces of the feed-forward clock counter.
This header file provides the interfaces of the Atomic Operations.
Definition: timepps.h:126
Definition: timepps.h:132
Definition: timepps.h:138
Definition: kern_tc.c:200