summaryrefslogtreecommitdiffstats
path: root/cpukit/include/sys/timex.h
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2017-12-23 18:18:56 +1100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-01-25 08:45:26 +0100
commit2afb22b7e1ebcbe40373ff7e0efae7d207c655a9 (patch)
tree44759efe9374f13200a97e96d91bd9a2b7e5ce2a /cpukit/include/sys/timex.h
parentMAINTAINERS: Add myself to Write After Approval. (diff)
downloadrtems-2afb22b7e1ebcbe40373ff7e0efae7d207c655a9.tar.bz2
Remove make preinstall
A speciality of the RTEMS build system was the make preinstall step. It copied header files from arbitrary locations into the build tree. The header files were included via the -Bsome/build/tree/path GCC command line option. This has at least seven problems: * The make preinstall step itself needs time and disk space. * Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error. * There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult. * The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit. * An introduction of a new build system is difficult. * Include paths specified by the -B option are system headers. This may suppress warnings. * The parallel build had sporadic failures on some hosts. This patch removes the make preinstall step. All installed header files are moved to dedicated include directories in the source tree. Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc, etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g. erc32, imx, qoriq, etc. The new cpukit include directories are: * cpukit/include * cpukit/score/cpu/@RTEMS_CPU@/include * cpukit/libnetworking The new BSP include directories are: * bsps/include * bsps/@RTEMS_CPU@/include * bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include There are build tree include directories for generated files. The include directory order favours the most general header file, e.g. it is not possible to override general header files via the include path order. The "bootstrap -p" option was removed. The new "bootstrap -H" option should be used to regenerate the "headers.am" files. Update #3254.
Diffstat (limited to 'cpukit/include/sys/timex.h')
-rw-r--r--cpukit/include/sys/timex.h171
1 files changed, 171 insertions, 0 deletions
diff --git a/cpukit/include/sys/timex.h b/cpukit/include/sys/timex.h
new file mode 100644
index 0000000000..d2d2012ff5
--- /dev/null
+++ b/cpukit/include/sys/timex.h
@@ -0,0 +1,171 @@
+/*-
+ ***********************************************************************
+ * *
+ * Copyright (c) David L. Mills 1993-2001 *
+ * Copyright (c) Poul-Henning Kamp 2000-2001 *
+ * *
+ * Permission to use, copy, modify, and distribute this software and *
+ * its documentation for any purpose and without fee is hereby *
+ * granted, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission *
+ * notice appear in supporting documentation, and that the name *
+ * University of Delaware not be used in advertising or publicity *
+ * pertaining to distribution of the software without specific, *
+ * written prior permission. The University of Delaware makes no *
+ * representations about the suitability this software for any *
+ * purpose. It is provided "as is" without express or implied *
+ * warranty. *
+ * *
+ ***********************************************************************
+ *
+ * $FreeBSD: head/sys/sys/timex.h 298981 2016-05-03 15:14:17Z pfg $
+ *
+ * This header file defines the Network Time Protocol (NTP) interfaces
+ * for user and daemon application programs.
+ *
+ * This file was originally created 17 Sep 93 by David L. Mills, Professor
+ * of University of Delaware, building on work which had already been ongoing
+ * for a decade and a half at that point in time.
+ *
+ * In 2000 the APIs got a upgrade from microseconds to nanoseconds,
+ * a joint work between Poul-Henning Kamp and David L. Mills.
+ *
+ */
+
+#ifndef _SYS_TIMEX_H_
+#define _SYS_TIMEX_H_ 1
+
+#define NTP_API 4 /* NTP API version */
+
+#ifdef __FreeBSD__
+#include <sys/_timespec.h>
+#endif /* __FreeBSD__ */
+
+/*
+ * The following defines establish the performance envelope of the
+ * kernel discipline loop. Phase or frequency errors greater than
+ * NAXPHASE or MAXFREQ are clamped to these maxima. For update intervals
+ * less than MINSEC, the loop always operates in PLL mode; while, for
+ * update intervals greater than MAXSEC, the loop always operates in FLL
+ * mode. Between these two limits the operating mode is selected by the
+ * STA_FLL bit in the status word.
+ */
+
+#define MAXPHASE 500000000L /* max phase error (ns) */
+#define MAXFREQ 500000L /* max freq error (ns/s) */
+#define MINSEC 256 /* min FLL update interval (s) */
+#define MAXSEC 2048 /* max PLL update interval (s) */
+#define NANOSECOND 1000000000L /* nanoseconds in one second */
+#define SCALE_PPM (65536 / 1000) /* crude ns/s to scaled PPM */
+#define MAXTC 10 /* max time constant */
+
+/*
+ * Control mode codes (timex.modes)
+ */
+#define MOD_OFFSET 0x0001 /* set time offset */
+#define MOD_FREQUENCY 0x0002 /* set frequency offset */
+#define MOD_MAXERROR 0x0004 /* set maximum time error */
+#define MOD_ESTERROR 0x0008 /* set estimated time error */
+#define MOD_STATUS 0x0010 /* set clock status bits */
+#define MOD_TIMECONST 0x0020 /* set PLL time constant */
+#define MOD_PPSMAX 0x0040 /* set PPS maximum averaging time */
+#define MOD_TAI 0x0080 /* set TAI offset */
+#define MOD_MICRO 0x1000 /* select microsecond resolution */
+#define MOD_NANO 0x2000 /* select nanosecond resolution */
+#define MOD_CLKB 0x4000 /* select clock B */
+#define MOD_CLKA 0x8000 /* select clock A */
+
+/*
+ * Status codes (timex.status)
+ */
+#define STA_PLL 0x0001 /* enable PLL updates (rw) */
+#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
+#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
+#define STA_FLL 0x0008 /* enable FLL mode (rw) */
+#define STA_INS 0x0010 /* insert leap (rw) */
+#define STA_DEL 0x0020 /* delete leap (rw) */
+#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
+#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
+#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
+#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
+#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
+#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
+#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
+#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
+#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
+#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
+
+#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
+ STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
+
+/*
+ * Clock states (ntptimeval.time_state)
+ */
+#define TIME_OK 0 /* no leap second warning */
+#define TIME_INS 1 /* insert leap second warning */
+#define TIME_DEL 2 /* delete leap second warning */
+#define TIME_OOP 3 /* leap second in progress */
+#define TIME_WAIT 4 /* leap second has occurred */
+#define TIME_ERROR 5 /* error (see status word) */
+
+/*
+ * NTP user interface -- ntp_gettime(2) - used to read kernel clock values
+ */
+struct ntptimeval {
+ struct timespec time; /* current time (ns) (ro) */
+ long maxerror; /* maximum error (us) (ro) */
+ long esterror; /* estimated error (us) (ro) */
+ long tai; /* TAI offset */
+ int time_state; /* time status */
+};
+
+/*
+ * NTP daemon interface -- ntp_adjtime(2) -- used to discipline CPU clock
+ * oscillator and control/determine status.
+ *
+ * Note: The offset, precision and jitter members are in microseconds if
+ * STA_NANO is zero and nanoseconds if not.
+ */
+struct timex {
+ unsigned int modes; /* clock mode bits (wo) */
+ long offset; /* time offset (ns/us) (rw) */
+ long freq; /* frequency offset (scaled PPM) (rw) */
+ long maxerror; /* maximum error (us) (rw) */
+ long esterror; /* estimated error (us) (rw) */
+ int status; /* clock status bits (rw) */
+ long constant; /* poll interval (log2 s) (rw) */
+ long precision; /* clock precision (ns/us) (ro) */
+ long tolerance; /* clock frequency tolerance (scaled
+ * PPM) (ro) */
+ /*
+ * The following read-only structure members are implemented
+ * only if the PPS signal discipline is configured in the
+ * kernel. They are included in all configurations to insure
+ * portability.
+ */
+ long ppsfreq; /* PPS frequency (scaled PPM) (ro) */
+ long jitter; /* PPS jitter (ns/us) (ro) */
+ int shift; /* interval duration (s) (shift) (ro) */
+ long stabil; /* PPS stability (scaled PPM) (ro) */
+ long jitcnt; /* jitter limit exceeded (ro) */
+ long calcnt; /* calibration intervals (ro) */
+ long errcnt; /* calibration errors (ro) */
+ long stbcnt; /* stability limit exceeded (ro) */
+};
+
+#ifdef __FreeBSD__
+
+#ifdef _KERNEL
+void ntp_update_second(int64_t *adjustment, time_t *newsec);
+#else /* !_KERNEL */
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int ntp_adjtime(struct timex *);
+int ntp_gettime(struct ntptimeval *);
+__END_DECLS
+#endif /* _KERNEL */
+
+#endif /* __FreeBSD__ */
+
+#endif /* !_SYS_TIMEX_H_ */