Update to draft-mogul-pps-api-02.txt as submitted to IETF

This commit is contained in:
Poul-Henning Kamp 1998-06-12 23:15:53 +00:00
parent 28ed032673
commit 389825d558
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36938
2 changed files with 56 additions and 20 deletions

View File

@ -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);

View File

@ -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 {
pps_seq_t assert_sequence;
pps_seq_t clear_sequence;
struct timespec assert_timestamp;
struct timespec clear_timestamp;
int current_mode;
} pps_info_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 {
int mode;
struct timespec assert_offset;
struct timespec clear_offset;
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; /* 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;