diff options
author | phk <phk@FreeBSD.org> | 1998-06-12 23:15:53 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-06-12 23:15:53 +0000 |
commit | 90b89a118c811a2a88c48b9f5da4b481c65425ec (patch) | |
tree | 4c3ed48257566fff1e49a18060045b7da10dd035 | |
parent | e30abc2a08346cbe0b1ae0b43667d1efc7544966 (diff) | |
download | FreeBSD-src-90b89a118c811a2a88c48b9f5da4b481c65425ec.zip FreeBSD-src-90b89a118c811a2a88c48b9f5da4b481c65425ec.tar.gz |
Update to draft-mogul-pps-api-02.txt as submitted to IETF
-rw-r--r-- | sys/dev/ppbus/pps.c | 21 | ||||
-rw-r--r-- | sys/sys/timepps.h | 51 |
2 files changed, 54 insertions, 18 deletions
diff --git a/sys/dev/ppbus/pps.c b/sys/dev/ppbus/pps.c index 70274b3..74bcf0c 100644 --- a/sys/dev/ppbus/pps.c +++ b/sys/dev/ppbus/pps.c @@ -6,7 +6,12 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: pps.c,v 1.5 1998/06/07 19:44:22 phk Exp $ + * $Id: pps.c,v 1.6 1998/06/08 02:43:12 bde Exp $ + * + * This driver implements a draft-mogul-pps-api-02.txt PPS source. + * + * The input pin is pin#10 + * The echo output pin is pin#14 * */ @@ -39,7 +44,8 @@ static int ppscap = PPS_CAPTUREASSERT | PPS_HARDPPSONASSERT | PPS_OFFSETASSERT | - PPS_ECHOASSERT; + PPS_ECHOASSERT | + PPS_TSFMT_TSPEC; static int npps; @@ -152,10 +158,12 @@ ppsintr(int unit) return; if (sc->ppsparam.mode & PPS_ECHOASSERT) ppb_wctr(&sc->pps_dev, IRQENABLE | AUTOFEED); - timespecadd(&tc, &sc->ppsparam.assert_offset); - if (tc.tv_nsec < 0) { - tc.tv_sec--; - tc.tv_nsec += 1000000000; + if (sc->ppsparam.mode & PPS_OFFSETASSERT) { + timespecadd(&tc, &sc->ppsparam.assert_offset); + if (tc.tv_nsec < 0) { + tc.tv_sec--; + tc.tv_nsec += 1000000000; + } } sc->ppsinfo.assert_timestamp = tc; sc->ppsinfo.assert_sequence++; @@ -196,6 +204,7 @@ ppsioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) case PPS_IOC_FETCH: pi = (pps_info_t *)data; *pi = sc->ppsinfo; + pi->current_mode = sc->ppsparam.mode; return (0); case PPS_IOC_WAIT: return (EOPNOTSUPP); diff --git a/sys/sys/timepps.h b/sys/sys/timepps.h index b2bf4e3..78d0901 100644 --- a/sys/sys/timepps.h +++ b/sys/sys/timepps.h @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id$ + * $Id: timepps.h,v 1.1 1998/06/07 19:44:16 phk Exp $ * * The is a FreeBSD protype version of the "draft-mogul-pps-api-02.txt" * specification for Pulse Per Second timing interfaces. @@ -22,35 +22,62 @@ typedef int pps_handle_t; typedef unsigned pps_seq_t; +typedef struct ntp_fp { + unsigned int integral; + unsigned int fractional; +} ntp_fp_t; + +typedef union pps_timeu { + struct timespec tspec; + ntp_fp_t ntpfp; + unsigned long longpair[2]; +} pps_timeu_t; + typedef struct { - pps_seq_t assert_sequence; - pps_seq_t clear_sequence; - struct timespec assert_timestamp; - struct timespec clear_timestamp; - int current_mode; + pps_seq_t assert_sequence; /* assert event seq # */ + pps_seq_t clear_sequence; /* clear event seq # */ + pps_timeu_t assert_tu; + pps_timeu_t clear_tu; + int current_mode; /* current mode bits */ } pps_info_t; +#define assert_timestamp assert_tu.tspec +#define clear_timestamp clear_tu.tspec + +#define assert_timestamp_ntpfp assert_tu.ntpfp +#define clear_timestamp_ntpfp clear_tu.ntpfp + typedef struct { - int mode; - struct timespec assert_offset; - struct timespec clear_offset; + int mode; /* mode bits */ + pps_timeu_t assert_off_tu; + pps_timeu_t clear_off_tu; } pps_params_t; +#define assert_offset assert_off_tu.tspec +#define clear_offset clear_off_tu.tspec + +#define assert_offset_ntpfp assert_off_tu.ntpfp +#define clear_offset_ntpfp clear_off_tu.ntpfp + + #define PPS_CAPTUREASSERT 0x01 #define PPS_CAPTURECLEAR 0x01 #define PPS_CAPTUREBOTH 0x03 -#define PPS_HARDPPSONASSERT 0x04 -#define PPS_HARDPPSONCLEAR 0x08 - #define PPS_OFFSETASSERT 0x10 #define PPS_OFFSETCLEAR 0x20 +#define PPS_HARDPPSONASSERT 0x04 +#define PPS_HARDPPSONCLEAR 0x08 + #define PPS_ECHOASSERT 0x40 #define PPS_ECHOCLEAR 0x80 #define PPS_CANWAIT 0x100 +#define PPS_TSFMT_TSPEC 0x1000 +#define PPS_TSFMT_NTPFP 0x2000 + struct pps_wait_args { struct timespec timeout; pps_info_t pps_info_buf; |