[Midnightbsd-cvs] src [9910] trunk/sys/sys: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri May 25 08:22:18 EDT 2018


Revision: 9910
          http://svnweb.midnightbsd.org/src/?rev=9910
Author:   laffer1
Date:     2018-05-25 08:22:17 -0400 (Fri, 25 May 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/sys/sys/_callout.h
    trunk/sys/sys/_cpuset.h
    trunk/sys/sys/syscall.h
    trunk/sys/sys/taskqueue.h
    trunk/sys/sys/termios.h
    trunk/sys/sys/time.h
    trunk/sys/sys/timeet.h
    trunk/sys/sys/timepps.h
    trunk/sys/sys/timetc.h

Modified: trunk/sys/sys/_callout.h
===================================================================
--- trunk/sys/sys/_callout.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/_callout.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1990, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -32,7 +33,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)callout.h	8.2 (Berkeley) 1/21/94
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/sys/_callout.h 281657 2015-04-17 15:39:42Z rrs $
  */
 
 #ifndef _SYS__CALLOUT_H
@@ -42,19 +43,23 @@
 
 struct lock_object;
 
-SLIST_HEAD(callout_list, callout);
+LIST_HEAD(callout_list, callout);
+SLIST_HEAD(callout_slist, callout);
 TAILQ_HEAD(callout_tailq, callout);
 
 struct callout {
 	union {
+		LIST_ENTRY(callout) le;
 		SLIST_ENTRY(callout) sle;
 		TAILQ_ENTRY(callout) tqe;
 	} c_links;
-	int	c_time;				/* ticks to the event */
+	sbintime_t c_time;			/* ticks to the event */
+	sbintime_t c_precision;			/* delta allowed wrt opt */
 	void	*c_arg;				/* function argument */
 	void	(*c_func)(void *);		/* function to call */
 	struct lock_object *c_lock;		/* lock to handle */
-	int	c_flags;			/* state of this entry */
+	short	c_flags;			/* User State */
+	short	c_iflags;			/* Internal State */
 	volatile int c_cpu;			/* CPU we're scheduled on */
 };
 

Modified: trunk/sys/sys/_cpuset.h
===================================================================
--- trunk/sys/sys/_cpuset.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/_cpuset.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008,	Jeffrey Roberson <jeff at freebsd.org>
  * All rights reserved.
@@ -26,27 +27,31 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/sys/_cpuset.h 271172 2014-09-05 15:45:20Z jhb $
  */
 
 #ifndef _SYS__CPUSET_H_
 #define	_SYS__CPUSET_H_
 
+#include <sys/_bitset.h>
+
 #ifdef _KERNEL
 #define	CPU_SETSIZE	MAXCPU
 #endif
 
-#define	CPU_MAXSIZE	128
+#define	CPU_MAXSIZE	256
 
 #ifndef	CPU_SETSIZE
 #define	CPU_SETSIZE	CPU_MAXSIZE
 #endif
 
-#define	_NCPUBITS	(sizeof(long) * NBBY)	/* bits per mask */
-#define	_NCPUWORDS	howmany(CPU_SETSIZE, _NCPUBITS)
+#define	_NCPUBITS	_BITSET_BITS
+#define	_NCPUWORDS	__bitset_words(CPU_SETSIZE)
 
-typedef	struct _cpuset {
-	long	__bits[howmany(CPU_SETSIZE, _NCPUBITS)];
-} cpuset_t;
+BITSET_DEFINE(_cpuset, CPU_SETSIZE);
+typedef struct _cpuset cpuset_t;
 
+#define	CPUSET_FSET		BITSET_FSET(_NCPUWORDS)
+#define	CPUSET_T_INITIALIZER	BITSET_T_INITIALIZER
+
 #endif /* !_SYS__CPUSET_H_ */

Modified: trunk/sys/sys/syscall.h
===================================================================
--- trunk/sys/sys/syscall.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/syscall.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,9 +1,9 @@
+/* $MidnightBSD$ */
 /*
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * $MidnightBSD$
- * created from MidnightBSD
+ * $FreeBSD: stable/10/sys/sys/syscall.h 318164 2017-05-10 23:09:17Z jhb $
  */
 
 #define	SYS_syscall	0
@@ -216,6 +216,10 @@
 #define	SYS_ktimer_gettime	238
 #define	SYS_ktimer_getoverrun	239
 #define	SYS_nanosleep	240
+#define	SYS_ffclock_getcounter	241
+#define	SYS_ffclock_setestimate	242
+#define	SYS_ffclock_getestimate	243
+#define	SYS_clock_getcpuclockid2	247
 #define	SYS_ntp_gettime	248
 #define	SYS_minherit	250
 #define	SYS_rfork	251
@@ -430,8 +434,8 @@
 #define	SYS_msgctl	511
 #define	SYS_shmctl	512
 #define	SYS_lpathconf	513
-#define	SYS_cap_new	514
-#define	SYS_cap_getrights	515
+				/* 514 is obsolete cap_new */
+#define	SYS___cap_rights_get	515
 #define	SYS_cap_enter	516
 #define	SYS_cap_getmode	517
 #define	SYS_pdfork	518
@@ -448,4 +452,19 @@
 #define	SYS_posix_fallocate	530
 #define	SYS_posix_fadvise	531
 #define	SYS_wait6	532
-#define	SYS_MAXSYSCALL	533
+#define	SYS_cap_rights_limit	533
+#define	SYS_cap_ioctls_limit	534
+#define	SYS_cap_ioctls_get	535
+#define	SYS_cap_fcntls_limit	536
+#define	SYS_cap_fcntls_get	537
+#define	SYS_bindat	538
+#define	SYS_connectat	539
+#define	SYS_chflagsat	540
+#define	SYS_accept4	541
+#define	SYS_pipe2	542
+#define	SYS_aio_mlock	543
+#define	SYS_procctl	544
+#define	SYS_ppoll	545
+#define	SYS_futimens	546
+#define	SYS_utimensat	547
+#define	SYS_MAXSYSCALL	548

Modified: trunk/sys/sys/taskqueue.h
===================================================================
--- trunk/sys/sys/taskqueue.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/taskqueue.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Doug Rabson
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/sys/taskqueue.h 315268 2017-03-14 16:00:33Z hselasky $
  */
 
 #ifndef _SYS_TASKQUEUE_H_
@@ -47,6 +48,16 @@
 	int    f;
 };
 
+enum taskqueue_callback_type {
+	TASKQUEUE_CALLBACK_TYPE_INIT,
+	TASKQUEUE_CALLBACK_TYPE_SHUTDOWN,
+};
+#define	TASKQUEUE_CALLBACK_TYPE_MIN	TASKQUEUE_CALLBACK_TYPE_INIT
+#define	TASKQUEUE_CALLBACK_TYPE_MAX	TASKQUEUE_CALLBACK_TYPE_SHUTDOWN
+#define	TASKQUEUE_NUM_CALLBACKS		TASKQUEUE_CALLBACK_TYPE_MAX + 1
+
+typedef void (*taskqueue_callback_fn)(void *context);
+
 /*
  * A notification callback function which is called from
  * taskqueue_enqueue().  The context argument is given in the call to
@@ -64,6 +75,7 @@
 int	taskqueue_enqueue(struct taskqueue *queue, struct task *task);
 int	taskqueue_enqueue_timeout(struct taskqueue *queue,
 	    struct timeout_task *timeout_task, int ticks);
+int	taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task);
 int	taskqueue_cancel(struct taskqueue *queue, struct task *task,
 	    u_int *pendp);
 int	taskqueue_cancel_timeout(struct taskqueue *queue,
@@ -71,11 +83,15 @@
 void	taskqueue_drain(struct taskqueue *queue, struct task *task);
 void	taskqueue_drain_timeout(struct taskqueue *queue,
 	    struct timeout_task *timeout_task);
+void	taskqueue_drain_all(struct taskqueue *queue);
 void	taskqueue_free(struct taskqueue *queue);
 void	taskqueue_run(struct taskqueue *queue);
 void	taskqueue_block(struct taskqueue *queue);
 void	taskqueue_unblock(struct taskqueue *queue);
 int	taskqueue_member(struct taskqueue *queue, struct thread *td);
+void	taskqueue_set_callback(struct taskqueue *queue,
+	    enum taskqueue_callback_type cb_type,
+	    taskqueue_callback_fn callback, void *context);
 
 #define TASK_INITIALIZER(priority, func, context)	\
 	{ .ta_pending = 0,				\

Modified: trunk/sys/sys/termios.h
===================================================================
--- trunk/sys/sys/termios.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/termios.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/sys/termios.h 199898 2009-11-28 23:50:48Z ed $ */
 #ifdef __GNUC__
 #warning "this file includes <sys/termios.h> which is deprecated, use <termios.h> instead"
 #endif

Modified: trunk/sys/sys/time.h
===================================================================
--- trunk/sys/sys/time.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/time.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1982, 1986, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -27,11 +28,11 @@
  * SUCH DAMAGE.
  *
  *	@(#)time.h	8.5 (Berkeley) 5/4/95
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/sys/time.h 304894 2016-08-27 10:56:04Z kib $
  */
 
 #ifndef _SYS_TIME_H_
-#define _SYS_TIME_H_
+#define	_SYS_TIME_H_
 
 #include <sys/_timeval.h>
 #include <sys/types.h>
@@ -56,52 +57,67 @@
 };
 
 static __inline void
-bintime_addx(struct bintime *bt, uint64_t x)
+bintime_addx(struct bintime *_bt, uint64_t _x)
 {
-	uint64_t u;
+	uint64_t _u;
 
-	u = bt->frac;
-	bt->frac += x;
-	if (u > bt->frac)
-		bt->sec++;
+	_u = _bt->frac;
+	_bt->frac += _x;
+	if (_u > _bt->frac)
+		_bt->sec++;
 }
 
 static __inline void
-bintime_add(struct bintime *bt, const struct bintime *bt2)
+bintime_add(struct bintime *_bt, const struct bintime *_bt2)
 {
-	uint64_t u;
+	uint64_t _u;
 
-	u = bt->frac;
-	bt->frac += bt2->frac;
-	if (u > bt->frac)
-		bt->sec++;
-	bt->sec += bt2->sec;
+	_u = _bt->frac;
+	_bt->frac += _bt2->frac;
+	if (_u > _bt->frac)
+		_bt->sec++;
+	_bt->sec += _bt2->sec;
 }
 
 static __inline void
-bintime_sub(struct bintime *bt, const struct bintime *bt2)
+bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
 {
-	uint64_t u;
+	uint64_t _u;
 
-	u = bt->frac;
-	bt->frac -= bt2->frac;
-	if (u < bt->frac)
-		bt->sec--;
-	bt->sec -= bt2->sec;
+	_u = _bt->frac;
+	_bt->frac -= _bt2->frac;
+	if (_u < _bt->frac)
+		_bt->sec--;
+	_bt->sec -= _bt2->sec;
 }
 
 static __inline void
-bintime_mul(struct bintime *bt, u_int x)
+bintime_mul(struct bintime *_bt, u_int _x)
 {
-	uint64_t p1, p2;
+	uint64_t _p1, _p2;
 
-	p1 = (bt->frac & 0xffffffffull) * x;
-	p2 = (bt->frac >> 32) * x + (p1 >> 32);
-	bt->sec *= x;
-	bt->sec += (p2 >> 32);
-	bt->frac = (p2 << 32) | (p1 & 0xffffffffull);
+	_p1 = (_bt->frac & 0xffffffffull) * _x;
+	_p2 = (_bt->frac >> 32) * _x + (_p1 >> 32);
+	_bt->sec *= _x;
+	_bt->sec += (_p2 >> 32);
+	_bt->frac = (_p2 << 32) | (_p1 & 0xffffffffull);
 }
 
+static __inline void
+bintime_shift(struct bintime *_bt, int _exp)
+{
+
+	if (_exp > 0) {
+		_bt->sec <<= _exp;
+		_bt->sec |= _bt->frac >> (64 - _exp);
+		_bt->frac <<= _exp;
+	} else if (_exp < 0) {
+		_bt->frac >>= -_exp;
+		_bt->frac |= (uint64_t)_bt->sec << (64 + _exp);
+		_bt->sec >>= -_exp;
+	}
+}
+
 #define	bintime_clear(a)	((a)->sec = (a)->frac = 0)
 #define	bintime_isset(a)	((a)->sec || (a)->frac)
 #define	bintime_cmp(a, b, cmp)						\
@@ -109,6 +125,37 @@
 	    ((a)->frac cmp (b)->frac) :					\
 	    ((a)->sec cmp (b)->sec))
 
+#define	SBT_1S	((sbintime_t)1 << 32)
+#define	SBT_1M	(SBT_1S * 60)
+#define	SBT_1MS	(SBT_1S / 1000)
+#define	SBT_1US	(SBT_1S / 1000000)
+#define	SBT_1NS	(SBT_1S / 1000000000)
+#define	SBT_MAX	0x7fffffffffffffffLL
+
+static __inline int
+sbintime_getsec(sbintime_t _sbt)
+{
+
+	return (_sbt >> 32);
+}
+
+static __inline sbintime_t
+bttosbt(const struct bintime _bt)
+{
+
+	return (((sbintime_t)_bt.sec << 32) + (_bt.frac >> 32));
+}
+
+static __inline struct bintime
+sbttobt(sbintime_t _sbt)
+{
+	struct bintime _bt;
+
+	_bt.sec = _sbt >> 32;
+	_bt.frac = _sbt << 32;
+	return (_bt);
+}
+
 /*-
  * Background information:
  *
@@ -124,38 +171,75 @@
  */
 
 static __inline void
-bintime2timespec(const struct bintime *bt, struct timespec *ts)
+bintime2timespec(const struct bintime *_bt, struct timespec *_ts)
 {
 
-	ts->tv_sec = bt->sec;
-	ts->tv_nsec = ((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32;
+	_ts->tv_sec = _bt->sec;
+	_ts->tv_nsec = ((uint64_t)1000000000 *
+	    (uint32_t)(_bt->frac >> 32)) >> 32;
 }
 
 static __inline void
-timespec2bintime(const struct timespec *ts, struct bintime *bt)
+timespec2bintime(const struct timespec *_ts, struct bintime *_bt)
 {
 
-	bt->sec = ts->tv_sec;
+	_bt->sec = _ts->tv_sec;
 	/* 18446744073 = int(2^64 / 1000000000) */
-	bt->frac = ts->tv_nsec * (uint64_t)18446744073LL; 
+	_bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL;
 }
 
 static __inline void
-bintime2timeval(const struct bintime *bt, struct timeval *tv)
+bintime2timeval(const struct bintime *_bt, struct timeval *_tv)
 {
 
-	tv->tv_sec = bt->sec;
-	tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32;
+	_tv->tv_sec = _bt->sec;
+	_tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32;
 }
 
 static __inline void
-timeval2bintime(const struct timeval *tv, struct bintime *bt)
+timeval2bintime(const struct timeval *_tv, struct bintime *_bt)
 {
 
-	bt->sec = tv->tv_sec;
+	_bt->sec = _tv->tv_sec;
 	/* 18446744073709 = int(2^64 / 1000000) */
-	bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
+	_bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL;
 }
+
+static __inline struct timespec
+sbttots(sbintime_t _sbt)
+{
+	struct timespec _ts;
+
+	_ts.tv_sec = _sbt >> 32;
+	_ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32;
+	return (_ts);
+}
+
+static __inline sbintime_t
+tstosbt(struct timespec _ts)
+{
+
+	return (((sbintime_t)_ts.tv_sec << 32) +
+	    (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32));
+}
+
+static __inline struct timeval
+sbttotv(sbintime_t _sbt)
+{
+	struct timeval _tv;
+
+	_tv.tv_sec = _sbt >> 32;
+	_tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32;
+	return (_tv);
+}
+
+static __inline sbintime_t
+tvtosbt(struct timeval _tv)
+{
+
+	return (((sbintime_t)_tv.tv_sec << 32) +
+	    (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32));
+}
 #endif /* __BSD_VISIBLE */
 
 #ifdef _KERNEL
@@ -167,7 +251,7 @@
 	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
 	    ((tvp)->tv_nsec cmp (uvp)->tv_nsec) :			\
 	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
-#define timespecadd(vvp, uvp)						\
+#define	timespecadd(vvp, uvp)						\
 	do {								\
 		(vvp)->tv_sec += (uvp)->tv_sec;				\
 		(vvp)->tv_nsec += (uvp)->tv_nsec;			\
@@ -176,7 +260,7 @@
 			(vvp)->tv_nsec -= 1000000000;			\
 		}							\
 	} while (0)
-#define timespecsub(vvp, uvp)						\
+#define	timespecsub(vvp, uvp)						\
 	do {								\
 		(vvp)->tv_sec -= (uvp)->tv_sec;				\
 		(vvp)->tv_nsec -= (uvp)->tv_nsec;			\
@@ -207,7 +291,7 @@
 	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
 	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
 	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
-#define timeradd(tvp, uvp, vvp)						\
+#define	timeradd(tvp, uvp, vvp)						\
 	do {								\
 		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
 		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
@@ -216,7 +300,7 @@
 			(vvp)->tv_usec -= 1000000;			\
 		}							\
 	} while (0)
-#define timersub(tvp, uvp, vvp)						\
+#define	timersub(tvp, uvp, vvp)						\
 	do {								\
 		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
 		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
@@ -253,26 +337,32 @@
 
 /* These macros are also in time.h. */
 #ifndef CLOCK_REALTIME
-#define CLOCK_REALTIME	0
-#define CLOCK_VIRTUAL	1
-#define CLOCK_PROF	2
-#define CLOCK_MONOTONIC	4
-#define CLOCK_UPTIME	5		/* FreeBSD-specific. */
-#define CLOCK_UPTIME_PRECISE	7	/* FreeBSD-specific. */
-#define CLOCK_UPTIME_FAST	8	/* FreeBSD-specific. */
-#define CLOCK_REALTIME_PRECISE	9	/* FreeBSD-specific. */
-#define CLOCK_REALTIME_FAST	10	/* FreeBSD-specific. */
-#define CLOCK_MONOTONIC_PRECISE	11	/* FreeBSD-specific. */
-#define CLOCK_MONOTONIC_FAST	12	/* FreeBSD-specific. */
-#define CLOCK_SECOND	13		/* FreeBSD-specific. */
-#define CLOCK_THREAD_CPUTIME_ID	14
+#define	CLOCK_REALTIME	0
+#define	CLOCK_VIRTUAL	1
+#define	CLOCK_PROF	2
+#define	CLOCK_MONOTONIC	4
+#define	CLOCK_UPTIME	5		/* FreeBSD-specific. */
+#define	CLOCK_UPTIME_PRECISE	7	/* FreeBSD-specific. */
+#define	CLOCK_UPTIME_FAST	8	/* FreeBSD-specific. */
+#define	CLOCK_REALTIME_PRECISE	9	/* FreeBSD-specific. */
+#define	CLOCK_REALTIME_FAST	10	/* FreeBSD-specific. */
+#define	CLOCK_MONOTONIC_PRECISE	11	/* FreeBSD-specific. */
+#define	CLOCK_MONOTONIC_FAST	12	/* FreeBSD-specific. */
+#define	CLOCK_SECOND	13		/* FreeBSD-specific. */
+#define	CLOCK_THREAD_CPUTIME_ID	14
+#define	CLOCK_PROCESS_CPUTIME_ID	15
 #endif
 
 #ifndef TIMER_ABSTIME
-#define TIMER_RELTIME	0x0	/* relative timer */
-#define TIMER_ABSTIME	0x1	/* absolute timer */
+#define	TIMER_RELTIME	0x0	/* relative timer */
+#define	TIMER_ABSTIME	0x1	/* absolute timer */
 #endif
 
+#if __BSD_VISIBLE
+#define	CPUCLOCK_WHICH_PID	0
+#define	CPUCLOCK_WHICH_TID	1
+#endif
+
 #ifdef _KERNEL
 
 /*
@@ -285,6 +375,16 @@
 extern volatile time_t	time_uptime;
 extern struct bintime boottimebin;
 extern struct timeval boottime;
+extern struct bintime tc_tick_bt;
+extern sbintime_t tc_tick_sbt;
+extern struct bintime tick_bt;
+extern sbintime_t tick_sbt;
+extern int tc_precexp;
+extern int tc_timepercentage;
+extern struct bintime bt_timethreshold;
+extern struct bintime bt_tickthreshold;
+extern sbintime_t sbt_timethreshold;
+extern sbintime_t sbt_tickthreshold;
 
 /*
  * Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
@@ -295,7 +395,7 @@
  * "bin"   == struct bintime  == seconds + 64 bit fraction of seconds.
  * "nano"  == struct timespec == seconds + nanoseconds.
  * "micro" == struct timeval  == seconds + microseconds.
- *              
+ *
  * Functions containing "up" returns time relative to boot and
  * should be used for calculating time intervals.
  *
@@ -304,8 +404,7 @@
  * Functions with the "get" prefix returns a less precise result
  * much faster than the functions without "get" prefix and should
  * be used where a precision of 1/hz seconds is acceptable or where
- * performance is priority. (NB: "precision", _not_ "resolution" !) 
- * 
+ * performance is priority. (NB: "precision", _not_ "resolution" !)
  */
 
 void	binuptime(struct bintime *bt);
@@ -312,6 +411,15 @@
 void	nanouptime(struct timespec *tsp);
 void	microuptime(struct timeval *tvp);
 
+static __inline sbintime_t
+sbinuptime(void)
+{
+	struct bintime _bt;
+
+	binuptime(&_bt);
+	return (bttosbt(_bt));
+}
+
 void	bintime(struct bintime *bt);
 void	nanotime(struct timespec *tsp);
 void	microtime(struct timeval *tvp);
@@ -320,6 +428,15 @@
 void	getnanouptime(struct timespec *tsp);
 void	getmicrouptime(struct timeval *tvp);
 
+static __inline sbintime_t
+getsbinuptime(void)
+{
+	struct bintime _bt;
+
+	getbinuptime(&_bt);
+	return (bttosbt(_bt));
+}
+
 void	getbintime(struct bintime *bt);
 void	getnanotime(struct timespec *tsp);
 void	getmicrotime(struct timeval *tvp);
@@ -332,6 +449,25 @@
 void	timevaladd(struct timeval *t1, const struct timeval *t2);
 void	timevalsub(struct timeval *t1, const struct timeval *t2);
 int	tvtohz(struct timeval *tv);
+
+#define	TC_DEFAULTPERC		5
+
+#define	BT2FREQ(bt)                                                     \
+	(((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) /           \
+	    ((bt)->frac >> 1))
+
+#define	SBT2FREQ(sbt)	((SBT_1S + ((sbt) >> 1)) / (sbt))
+
+#define	FREQ2BT(freq, bt)                                               \
+{									\
+	(bt)->sec = 0;                                                  \
+	(bt)->frac = ((uint64_t)0x8000000000000000  / (freq)) << 1;     \
+}
+
+#define	TIMESEL(sbt, sbt2)						\
+	(((sbt2) >= sbt_timethreshold) ?				\
+	    ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0))
+
 #else /* !_KERNEL */
 #include <time.h>
 
@@ -344,6 +480,7 @@
 
 #if __BSD_VISIBLE
 int	adjtime(const struct timeval *, struct timeval *);
+int	clock_getcpuclockid2(id_t, int, clockid_t *);
 int	futimes(int, const struct timeval *);
 int	futimesat(int, const char *, const struct timeval [2]);
 int	lutimes(const char *, const struct timeval *);

Modified: trunk/sys/sys/timeet.h
===================================================================
--- trunk/sys/sys/timeet.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/timeet.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*-
- * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
+ * Copyright (c) 2010-2013 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/sys/timeet.h 266347 2014-05-17 20:10:12Z ian $
  */
 
 #ifndef _SYS_TIMEEC_H_
@@ -45,7 +46,7 @@
 
 struct eventtimer;
 typedef int et_start_t(struct eventtimer *et,
-    struct bintime *first, struct bintime *period);
+    sbintime_t first, sbintime_t period);
 typedef int et_stop_t(struct eventtimer *et);
 typedef void et_event_cb_t(struct eventtimer *et, void *arg);
 typedef int et_deregister_cb_t(struct eventtimer *et, void *arg);
@@ -70,8 +71,8 @@
 	int			et_active;
 	u_int64_t		et_frequency;
 		/* Base frequency in Hz. */
-	struct bintime		et_min_period;
-	struct bintime		et_max_period;
+	sbintime_t		et_min_period;
+	sbintime_t		et_max_period;
 	et_start_t		*et_start;
 	et_stop_t		*et_stop;
 	et_event_cb_t		*et_event_cb;
@@ -89,12 +90,12 @@
 /* Driver API */
 int	et_register(struct eventtimer *et);
 int	et_deregister(struct eventtimer *et);
+void	et_change_frequency(struct eventtimer *et, uint64_t newfreq);
 /* Consumer API  */
 struct eventtimer *et_find(const char *name, int check, int want);
 int	et_init(struct eventtimer *et, et_event_cb_t *event,
     et_deregister_cb_t *deregister, void *arg);
-int	et_start(struct eventtimer *et,
-    struct bintime *first, struct bintime *period);
+int	et_start(struct eventtimer *et, sbintime_t first, sbintime_t period);
 int	et_stop(struct eventtimer *et);
 int	et_ban(struct eventtimer *et);
 int	et_free(struct eventtimer *et);

Modified: trunk/sys/sys/timepps.h
===================================================================
--- trunk/sys/sys/timepps.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/timepps.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * ----------------------------------------------------------------------------
  * "THE BEER-WARE LICENSE" (Revision 42):
@@ -6,8 +7,14 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $MidnightBSD$
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
  *
+ * Portions of this software were developed by Julien Ridoux at the University
+ * of Melbourne under sponsorship from the FreeBSD Foundation.
+ *
+ * $FreeBSD: stable/10/sys/sys/timepps.h 283341 2015-05-24 00:53:43Z ian $
+ *
  * The is a FreeBSD version of the RFC 2783 API for Pulse Per Second 
  * timing interfaces.  
  */
@@ -15,6 +22,7 @@
 #ifndef _SYS_TIMEPPS_H_
 #define _SYS_TIMEPPS_H_
 
+#include <sys/_ffcounter.h>
 #include <sys/ioccom.h>
 #include <sys/time.h>
 
@@ -43,6 +51,16 @@
 	int		current_mode;		/* current mode bits */
 } pps_info_t;
 
+typedef struct {
+	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;
+	ffcounter	assert_ffcount;		/* ffcounter on assert event */
+	ffcounter	clear_ffcount;		/* ffcounter on clear event */
+	int		current_mode;		/* current mode bits */
+} pps_info_ffc_t;
+
 #define assert_timestamp        assert_tu.tspec
 #define clear_timestamp         clear_tu.tspec
 
@@ -79,6 +97,10 @@
 #define PPS_TSFMT_TSPEC		0x1000
 #define PPS_TSFMT_NTPFP		0x2000
 
+#define	PPS_TSCLK_FBCK		0x10000
+#define	PPS_TSCLK_FFWD		0x20000
+#define	PPS_TSCLK_MASK		0x30000
+
 #define PPS_KC_HARDPPS		0
 #define PPS_KC_HARDPPS_PLL	1
 #define PPS_KC_HARDPPS_FLL	2
@@ -89,6 +111,12 @@
 	struct timespec	timeout;
 };
 
+struct pps_fetch_ffc_args {
+	int		tsformat;
+	pps_info_ffc_t	pps_info_buf_ffc;
+	struct timespec	timeout;
+};
+
 struct pps_kcbind_args {
 	int kernel_consumer;
 	int edge;
@@ -102,12 +130,23 @@
 #define PPS_IOC_GETCAP		_IOR('1', 5, int)
 #define PPS_IOC_FETCH		_IOWR('1', 6, struct pps_fetch_args)
 #define PPS_IOC_KCBIND		_IOW('1', 7, struct pps_kcbind_args)
+#define	PPS_IOC_FETCH_FFCOUNTER	_IOWR('1', 8, struct pps_fetch_ffc_args)
 
 #ifdef _KERNEL
 
+struct mtx;
+
+#define	KCMODE_EDGEMASK		0x03
+#define	KCMODE_ABIFLAG		0x80000000 /* Internal use: abi-aware driver. */
+
+#define	PPS_ABI_VERSION		1
+
+#define	PPSFLAG_MTX_SPIN	0x01	/* Driver mtx is MTX_SPIN type. */
+
 struct pps_state {
 	/* Capture information. */
 	struct timehands *capth;
+	struct fftimehands *capffth;
 	unsigned	capgen;
 	unsigned	capcount;
 
@@ -114,15 +153,24 @@
 	/* State information. */
 	pps_params_t	ppsparam;
 	pps_info_t	ppsinfo;
+	pps_info_ffc_t	ppsinfo_ffc;
 	int		kcmode;
 	int		ppscap;
 	struct timecounter *ppstc;
 	unsigned	ppscount[3];
+	/*
+	 * The following fields are valid if the driver calls pps_init_abi().
+	 */
+	uint16_t	driver_abi;	/* Driver sets before pps_init_abi(). */
+	uint16_t	kernel_abi;	/* Kernel sets during pps_init_abi(). */
+	struct mtx	*driver_mtx;	/* Optional, valid if non-NULL. */
+	uint32_t	flags;
 };
 
 void pps_capture(struct pps_state *pps);
 void pps_event(struct pps_state *pps, int event);
 void pps_init(struct pps_state *pps);
+void pps_init_abi(struct pps_state *pps);
 int pps_ioctl(unsigned long cmd, caddr_t data, struct pps_state *pps);
 void hardpps(struct timespec *tsp, long nsec);
 
@@ -184,6 +232,25 @@
 }
 
 static __inline int
+time_pps_fetch_ffc(pps_handle_t handle, const int tsformat,
+	pps_info_ffc_t *ppsinfobuf, const struct timespec *timeout)
+{
+	struct pps_fetch_ffc_args arg;
+	int error;
+
+	arg.tsformat = tsformat;
+	if (timeout == NULL) {
+		arg.timeout.tv_sec = -1;
+		arg.timeout.tv_nsec = -1;
+	} else {
+		arg.timeout = *timeout;
+	}
+	error = ioctl(handle, PPS_IOC_FETCH_FFCOUNTER, &arg);
+	*ppsinfobuf = arg.pps_info_buf_ffc;
+	return (error);
+}
+
+static __inline int
 time_pps_kcbind(pps_handle_t handle, const int kernel_consumer,
 	const int edge, const int tsformat)
 {

Modified: trunk/sys/sys/timetc.h
===================================================================
--- trunk/sys/sys/timetc.h	2018-05-25 12:20:50 UTC (rev 9909)
+++ trunk/sys/sys/timetc.h	2018-05-25 12:22:17 UTC (rev 9910)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * ----------------------------------------------------------------------------
  * "THE BEER-WARE LICENSE" (Revision 42):
@@ -6,7 +7,7 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/sys/timetc.h 280973 2015-04-02 01:02:42Z jhb $
  */
 
 #ifndef _SYS_TIMETC_H_
@@ -59,6 +60,10 @@
 		 */
 	u_int			tc_flags;
 #define	TC_FLAGS_C2STOP		1	/* Timer dies in C2+. */
+#define	TC_FLAGS_SUSPEND_SAFE	2	/*
+					 * Timer functional across
+					 * suspend/resume.
+					 */
 
 	void			*tc_priv;
 		/* Pointer to the timecounter's private parts. */



More information about the Midnightbsd-cvs mailing list