]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/timepps.h
This commit was generated by cvs2svn to compensate for changes in r42888,
[FreeBSD/FreeBSD.git] / sys / sys / timepps.h
1 /*
2  * ----------------------------------------------------------------------------
3  * "THE BEER-WARE LICENSE" (Revision 42):
4  * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
5  * can do whatever you want with this stuff. If we meet some day, and you think
6  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7  * ----------------------------------------------------------------------------
8  *
9  * $Id: timepps.h,v 1.3 1998/06/13 09:30:24 phk Exp $
10  *
11  * The is a FreeBSD protype version of the "draft-mogul-pps-api-02.txt" 
12  * specification for Pulse Per Second timing interfaces.  
13  *
14  */
15
16 #ifndef _SYS_TIMEPPS_H_
17 #define _SYS_TIMEPPS_H_
18
19 #include <sys/ioccom.h>
20
21 typedef int pps_handle_t;       
22
23 typedef unsigned pps_seq_t;
24
25 typedef struct ntp_fp {
26         unsigned int    integral;
27         unsigned int    fractional;
28 } ntp_fp_t;
29
30 typedef union pps_timeu {
31         struct timespec tspec;
32         ntp_fp_t        ntpfp;
33         unsigned long   longpair[2];
34 } pps_timeu_t;
35
36 typedef struct {
37         pps_seq_t       assert_sequence;        /* assert event seq # */
38         pps_seq_t       clear_sequence;         /* clear event seq # */
39         pps_timeu_t     assert_tu;
40         pps_timeu_t     clear_tu;
41         int             current_mode;           /* current mode bits */
42 } pps_info_t;
43
44 #define assert_timestamp        assert_tu.tspec
45 #define clear_timestamp         clear_tu.tspec
46
47 #define assert_timestamp_ntpfp  assert_tu.ntpfp
48 #define clear_timestamp_ntpfp   clear_tu.ntpfp
49
50 typedef struct {
51         int mode;                               /* mode bits */
52         pps_timeu_t assert_off_tu;
53         pps_timeu_t clear_off_tu;
54 } pps_params_t;
55
56 #define assert_offset   assert_off_tu.tspec
57 #define clear_offset    clear_off_tu.tspec
58
59 #define assert_offset_ntpfp     assert_off_tu.ntpfp
60 #define clear_offset_ntpfp      clear_off_tu.ntpfp
61
62
63 #define PPS_CAPTUREASSERT       0x01
64 #define PPS_CAPTURECLEAR        0x02
65 #define PPS_CAPTUREBOTH         0x03
66
67 #define PPS_OFFSETASSERT        0x10
68 #define PPS_OFFSETCLEAR         0x20
69
70 #define PPS_HARDPPSONASSERT     0x04
71 #define PPS_HARDPPSONCLEAR      0x08
72
73 #define PPS_ECHOASSERT          0x40
74 #define PPS_ECHOCLEAR           0x80
75
76 #define PPS_CANWAIT             0x100
77
78 #define PPS_TSFMT_TSPEC         0x1000
79 #define PPS_TSFMT_NTPFP         0x2000
80
81 struct pps_wait_args {
82         struct timespec timeout;
83         pps_info_t      pps_info_buf;
84 };
85
86 #define PPS_IOC_CREATE          _IO('1', 1)
87 #define PPS_IOC_DESTROY         _IO('1', 2)
88 #define PPS_IOC_SETPARAMS       _IOW('1', 3, pps_params_t)
89 #define PPS_IOC_GETPARAMS       _IOR('1', 4, pps_params_t)
90 #define PPS_IOC_GETCAP          _IOR('1', 5, int)
91 #define PPS_IOC_FETCH           _IOWR('1', 6, pps_info_t)
92 #define PPS_IOC_WAIT            _IOWR('1', 6, struct pps_wait_args)
93
94 #ifdef KERNEL
95 int std_pps_ioctl __P((u_long cmd, caddr_t data, pps_params_t *pp, 
96         pps_info_t *pi, int ppscap));
97
98 #endif /* KERNEL */
99 #endif /* _SYS_TIMEPPS_H_ */