diff options
author | phk <phk@FreeBSD.org> | 1999-03-11 15:09:51 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-03-11 15:09:51 +0000 |
commit | 1542a4a4974b31d78a2115e37a802c377265be93 (patch) | |
tree | 59c54f6ab6826395ea6c20a6d0d12cb2be4bc943 /sys/sys | |
parent | 9c47f49734c0ff3b3d666a5a7a2bb329444223f1 (diff) | |
download | FreeBSD-src-1542a4a4974b31d78a2115e37a802c377265be93.zip FreeBSD-src-1542a4a4974b31d78a2115e37a802c377265be93.tar.gz |
Make even more of the PPSAPI implementations generic.
FLL support in hardpps()
Various magic shuffles and improved comments
Style fixes from Bruce.
Diffstat (limited to 'sys/sys')
-rw-r--r-- | sys/sys/systm.h | 4 | ||||
-rw-r--r-- | sys/sys/time.h | 3 | ||||
-rw-r--r-- | sys/sys/timepps.h | 85 | ||||
-rw-r--r-- | sys/sys/timetc.h | 3 | ||||
-rw-r--r-- | sys/sys/timex.h | 27 |
5 files changed, 97 insertions, 25 deletions
diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 5724747..99539f1 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)systm.h 8.7 (Berkeley) 3/29/95 - * $Id: systm.h,v 1.85 1999/01/28 00:57:54 dillon Exp $ + * $Id: systm.h,v 1.86 1999/03/05 19:27:22 bde Exp $ */ #ifndef _SYS_SYSTM_H_ @@ -160,8 +160,6 @@ void startprofclock __P((struct proc *)); void stopprofclock __P((struct proc *)); void setstatclockrate __P((int hzrate)); -void hardpps __P((struct timeval *tvp, long usec)); - char *getenv __P((char *name)); int getenv_int __P((char *name, int *data)); extern char *kern_envp; diff --git a/sys/sys/time.h b/sys/sys/time.h index e117c74..712fffe 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.35 1998/12/15 17:38:32 des Exp $ + * $Id: time.h,v 1.36 1999/03/08 12:36:14 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -277,7 +277,6 @@ void microtime __P((struct timeval *tv)); void nanouptime __P((struct timespec *ts)); void nanotime __P((struct timespec *ts)); void set_timecounter __P((struct timespec *ts)); -void timecounter_timespec __P((unsigned count, struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); int tvtohz __P((struct timeval *)); diff --git a/sys/sys/timepps.h b/sys/sys/timepps.h index cc0e9ff..ba752d7 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: timepps.h,v 1.3 1998/06/13 09:30:24 phk Exp $ + * $Id: timepps.h,v 1.4 1998/06/22 21:09:10 phk Exp $ * * The is a FreeBSD protype version of the "draft-mogul-pps-api-02.txt" * specification for Pulse Per Second timing interfaces. @@ -92,8 +92,85 @@ struct pps_wait_args { #define PPS_IOC_WAIT _IOWR('1', 6, struct pps_wait_args) #ifdef KERNEL -int std_pps_ioctl __P((u_long cmd, caddr_t data, pps_params_t *pp, - pps_info_t *pi, int ppscap)); +struct pps_state { + pps_params_t ppsparam; + pps_info_t ppsinfo; + int ppscap; + struct timecounter *ppstc; + unsigned ppscount[3]; +}; -#endif /* KERNEL */ +void pps_event __P((struct pps_state *pps, struct timecounter *tc, unsigned count, int event)); +void pps_init __P((struct pps_state *pps)); +int pps_ioctl __P((u_long cmd, caddr_t data, struct pps_state *pps)); +void hardpps __P((struct timespec *tsp, long nsec)); + +#else /* !KERNEL */ + +int time_pps_create(int filedes, pps_handle_t *handle); +int time_pps_destroy(pps_handle_t handle); +int time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams); +int time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams); +int time_pps_getcap(pps_handle_t handle, int *mode); +int time_pps_fetch(pps_handle_t handle, pps_info_t *ppsinfobuf); +int time_pps_wait(pps_handle_t handle, const struct timespec *timeout, + pps_info_t *ppsinfobuf); + +static __inline int +time_pps_create(int filedes, pps_handle_t *handle) +{ + int error; + + *handle = -1; + error = ioctl(filedes, PPS_IOC_CREATE, 0); + if (error < 0) + return (-1); + *handle = filedes; + return (0); +} + +static __inline int +time_pps_destroy(pps_handle_t handle) +{ + return (ioctl(handle, PPS_IOC_DESTROY, 0)); +} + +static __inline int +time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams) +{ + return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams)); +} + +static __inline int +time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams) +{ + return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams)); +} + +static __inline int +time_pps_getcap(pps_handle_t handle, int *mode) +{ + return (ioctl(handle, PPS_IOC_GETCAP, mode)); +} + +static __inline int +time_pps_fetch(pps_handle_t handle, pps_info_t *ppsinfobuf) +{ + return (ioctl(handle, PPS_IOC_FETCH, ppsinfobuf)); +} + +static __inline int +time_pps_wait(pps_handle_t handle, const struct timespec *timeout, + pps_info_t *ppsinfobuf) +{ + int error; + struct pps_wait_args arg; + + arg.timeout = *timeout; + error = ioctl(handle, PPS_IOC_WAIT, &arg); + *ppsinfobuf = arg.pps_info_buf; + return (error); +} + +#endif /* !KERNEL */ #endif /* _SYS_TIMEPPS_H_ */ diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index e117c74..712fffe 100644 --- a/sys/sys/timetc.h +++ b/sys/sys/timetc.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.35 1998/12/15 17:38:32 des Exp $ + * $Id: time.h,v 1.36 1999/03/08 12:36:14 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -277,7 +277,6 @@ void microtime __P((struct timeval *tv)); void nanouptime __P((struct timespec *ts)); void nanotime __P((struct timespec *ts)); void set_timecounter __P((struct timespec *ts)); -void timecounter_timespec __P((unsigned count, struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); int tvtohz __P((struct timeval *)); diff --git a/sys/sys/timex.h b/sys/sys/timex.h index a829045..af926d3 100644 --- a/sys/sys/timex.h +++ b/sys/sys/timex.h @@ -59,14 +59,11 @@ * * SYNOPSIS * #include <sys/timex.h> - * #include <sys/syscall.h> * - * int syscall(SYS_ntp_gettime, tptr); - * int SYS_ntp_gettime; - * struct ntptimeval *tptr; + * int ntp_gettime(struct ntptimeval *ntv); * * DESCRIPTION - * The time returned by ntp_gettime() is in a timeval structure, + * The time returned by ntp_gettime() is in a timespec structure, * but may be in either microsecond (seconds and microseconds) or * nanosecond (seconds and nanoseconds) format. The particular * format in use is determined by the STA_NANO bit of the status @@ -80,6 +77,7 @@ * #include <sys/syscall.h> * * int syscall(SYS_ntp_adjtime, tptr); + * int SYS_ntp_adjtime; * struct timex *tptr; * * DESCRIPTION @@ -89,7 +87,7 @@ * further information. */ #ifndef _SYS_TIMEX_H_ -#define _SYS_TIMEX_H_ 1 +#define _SYS_TIMEX_H_ #ifndef MSDOS /* Microsoft specific */ #include <sys/syscall.h> @@ -171,7 +169,7 @@ * nanoseconds if not. */ struct ntptimeval { - struct timespec time; /* current time (ns) (ro) */ + struct timespec time; /* current time (ns/us) (ro) */ long maxerror; /* maximum error (us) (ro) */ long esterror; /* estimated error (us) (ro) */ int time_state; /* time status */ @@ -214,16 +212,17 @@ struct timex { #ifdef __FreeBSD__ #ifdef KERNEL -void ntp_update_second __P((struct timecounter *tc)); -#else +struct timecounter; +void ntp_update_second __P((struct timecounter *tc)); +#else /* !KERNEL */ #include <sys/cdefs.h> __BEGIN_DECLS -extern int ntp_gettime __P((struct ntptimeval *)); -extern int ntp_adjtime __P((struct timex *)); +int ntp_adjtime __P((struct timex *)); +int ntp_gettime __P((struct ntptimeval *)); __END_DECLS - -#endif /* not KERNEL */ +#endif /* KERNEL */ #endif /* __FreeBSD__ */ -#endif /* _SYS_TIMEX_H_ */ + +#endif /* !_SYS_TIMEX_H_ */ |