diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 1998-06-07 19:44:22 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 1998-06-07 19:44:22 +0000 |
commit | 8afeddf0a8381d808a88260e0d8967e18d59d2a1 (patch) | |
tree | f1667eeda36f1e8b2e90cc347d9e988e90307817 /include | |
parent | 498b291e2657c683c2277990ea036a0b0c15dc22 (diff) | |
download | src-8afeddf0a8381d808a88260e0d8967e18d59d2a1.tar.gz src-8afeddf0a8381d808a88260e0d8967e18d59d2a1.zip |
This is a prototype implementation of the draft-mogul-pps-api-##.txt
paper.
It will be updated along with the draft and possible subsequent
standard.
The ppbus based pps driver is updated to implement this API.
Notes
Notes:
svn path=/head/; revision=36739
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile | 6 | ||||
-rw-r--r-- | include/timepps.h | 86 |
2 files changed, 89 insertions, 3 deletions
diff --git a/include/Makefile b/include/Makefile index cca7b0b2467b..a03da729f7cf 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,5 +1,5 @@ # From: @(#)Makefile 8.2 (Berkeley) 1/4/94 -# $Id: Makefile,v 1.76 1998/03/28 11:48:14 dufault Exp $ +# $Id: Makefile,v 1.77 1998/05/21 19:21:43 eivind Exp $ # # Doing a make install builds /usr/include # @@ -18,8 +18,8 @@ FILES= a.out.h ar.h assert.h bitstring.h ctype.h db.h dirent.h disktab.h \ paths.h pthread.h pthread_np.h pwd.h \ ranlib.h regex.h regexp.h resolv.h rune.h runetype.h setjmp.h sgtty.h \ signal.h stab.h stddef.h stdio.h stdlib.h string.h stringlist.h \ - strings.h struct.h sysexits.h tar.h time.h timers.h ttyent.h unistd.h \ - utime.h utmp.h vis.h + strings.h struct.h sysexits.h tar.h time.h timepps.h timers.h \ + ttyent.h unistd.h utime.h utmp.h vis.h .if defined(WANT_CSRG_LIBM) FILES+= math.h .endif diff --git a/include/timepps.h b/include/timepps.h new file mode 100644 index 000000000000..c9277cec2d7c --- /dev/null +++ b/include/timepps.h @@ -0,0 +1,86 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $Id$ + * + * The is a FreeBSD protype version of the "draft-mogul-pps-api-02.txt" + * specification for Pulse Per Second timing interfaces. + * + */ + +#ifndef _TIME_PPS_H_ +#define _TIME_PPS_H_ + +#include <sys/timepps.h> + +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); + +__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); +} + +__inline int +time_pps_destroy(pps_handle_t handle) +{ + return (ioctl(handle, PPS_IOC_DESTROY, 0)); +} + +__inline int +time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams) +{ + return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams)); +} + +__inline int +time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams) +{ + return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams)); +} + +__inline int +time_pps_getcap(pps_handle_t handle, int *mode) +{ + return (ioctl(handle, PPS_IOC_GETCAP, mode)); +} + +__inline int +time_pps_fetch(pps_handle_t handle, pps_info_t *ppsinfobuf) +{ + return (ioctl(handle, PPS_IOC_FETCH, ppsinfobuf)); +} + +__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 /* !_TIME_PPS_H_ */ |