summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1997-03-06 07:07:43 +0000
committertholo <tholo@openbsd.org>1997-03-06 07:07:43 +0000
commit5b199ab27dad00eb4a8dbdb0bb850ca51f9cf7ce (patch)
tree2385afada0c8af1842c5ee33f38468c75679b646
parentAdd control flag to call hardpps() on carrier change (diff)
downloadwireguard-openbsd-5b199ab27dad00eb4a8dbdb0bb850ca51f9cf7ce.tar.xz
wireguard-openbsd-5b199ab27dad00eb4a8dbdb0bb850ca51f9cf7ce.zip
Initial implementation of support for calling hardpps() on carrier enable
-rw-r--r--sys/dev/ic/com.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 48cf142bbea..32a15ae741d 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com.c,v 1.30 1996/12/10 22:28:28 deraadt Exp $ */
+/* $OpenBSD: com.c,v 1.31 1997/03/06 07:07:43 tholo Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*-
@@ -882,6 +882,8 @@ comioctl(dev, cmd, data, flag, p)
SET(userbits, TIOCFLAG_CRTSCTS);
if (ISSET(driverbits, COM_SW_MDMBUF))
SET(userbits, TIOCFLAG_MDMBUF);
+ if (ISSET(driverbits, COM_SW_PPS))
+ SET(userbits, TIOCFLAG_PPS);
*(int *)data = userbits;
break;
@@ -903,6 +905,8 @@ comioctl(dev, cmd, data, flag, p)
SET(driverbits, COM_SW_CRTSCTS);
if (ISSET(userbits, TIOCFLAG_MDMBUF))
SET(driverbits, COM_SW_MDMBUF);
+ if (ISSET(userbits, TIOCFLAG_PPS))
+ SET(driverbits, COM_SW_PPS);
sc->sc_swflags = driverbits;
break;
@@ -1271,6 +1275,10 @@ comintr(arg)
bus_space_handle_t ioh = sc->sc_ioh;
struct tty *tp;
u_char lsr, data, msr, delta;
+#ifdef PPS_SYNC
+ struct timeval tv;
+ long usec;
+#endif /* PPS_SYNC */
#ifdef COM_DEBUG
int n;
struct {
@@ -1360,11 +1368,25 @@ comintr(arg)
if (msr != sc->sc_msr) {
delta = msr ^ sc->sc_msr;
sc->sc_msr = msr;
- if (ISSET(delta, MSR_DCD) &&
- !ISSET(sc->sc_swflags, COM_SW_SOFTCAR) &&
- (*linesw[tp->t_line].l_modem)(tp, ISSET(msr, MSR_DCD)) == 0) {
- CLR(sc->sc_mcr, sc->sc_dtr);
- bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr);
+ if (ISSET(delta, MSR_DCD)) {
+#ifdef PPS_SYNC
+ if (ISSET(sc->sc_swflags, COM_SW_PPS)) {
+ if (ISSET(msr, MSR_DCD)) {
+ usec = time.tv_usec;
+ microtime(&tv);
+ usec = tv.tv_usec - usec;
+ if (usec < 0)
+ usec += 1000000;
+ hardpps(&tv, usec);
+ }
+ }
+ else
+#endif /* PPS_SYNC */
+ if (!ISSET(sc->sc_swflags, COM_SW_SOFTCAR) &&
+ (*linesw[tp->t_line].l_modem)(tp, ISSET(msr, MSR_DCD)) == 0) {
+ CLR(sc->sc_mcr, sc->sc_dtr);
+ bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr);
+ }
}
if (ISSET(delta & msr, MSR_CTS) &&
ISSET(tp->t_cflag, CRTSCTS)) {