Subject: NTP pulse-per-second timestamp diff
To: None <tech-kern@NetBSD.ORG>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: tech-kern
Date: 03/25/1998 18:54:37
I've just committed a definition of TIOCDCDTIMESTAMP to sys/sys/ttycom.h.
Future builds of xntpd on -current should compile in support for
userlevel PPS There are still no hooks for in-kernel PPS;
i want to get this debugged first.

The following patch to ic/com.c is completely untested, but I hope the
intent is clear.  Please point out the obvious boo-boos.  Then I'd
like to drop similar changes into the very loweset level of all serial
drivers.

Does anyone have access to a refclock with a PPS signal to test this?

Once this works, we can think about calling hardpps() from
the exact same spots that do TIOCDCDTIMESTAMP sampling.
(tho' parallel ports should be  even better, for ports that have them.)


Index: com.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/com.c,v
retrieving revision 1.143
diff -c -r1.143 com.c
*** com.c	1998/03/22 00:55:37	1.143
--- com.c	1998/03/26 02:47:39
***************
*** 603,608 ****
--- 603,609 ----
  		com_modem(sc, 0);
  		(void) tsleep(sc, TTIPRI, ttclos, hz);
  	}
+ 	sc->sc_dcd_timestamping = 0;
  
  	/* Turn off interrupts. */
  #ifdef DDB
***************
*** 933,938 ****
--- 934,943 ----
  		*(int *)data = bits;
  		break;
  	}
+ 	case TIOCDCDTIMESTAMP:
+ 		com->sc_dcd_timestamping = 1;
+ 		*(struct timeval *)data = com->dcd_timestamp;
+ 		break;
  	default:
  		error = ENOTTY;
  		break;
***************
*** 1749,1754 ****
--- 1754,1763 ----
  		sc->sc_msr = msr;
  		if (ISSET(delta, sc->sc_msr_mask)) {
  			SET(sc->sc_msr_delta, delta);
+ 
+ 			if (sc->sc_dcd_timestamping && ISSET(delta, MSR_DCD)) {
+ 				microtime(&sc->sc_dcd_timestamp);
+ 			}
  
  			/*
  			 * Stop output immediately if we lose the output
Index: comvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/comvar.h,v
retrieving revision 1.22
diff -c -r1.22 comvar.h
*** comvar.h	1998/02/02 23:01:05	1.22
--- comvar.h	1998/03/26 02:55:02
***************
*** 109,114 ****
--- 109,117 ----
  	void (*disable) __P((struct com_softc *));
  	int enabled;
  
+ 	int	sc_dcd_timestamping;		/* boolean flag */
+ 	struct timeval	sc_dcd_timestamp;
+ 
  #if NRND > 0 && defined(RND_COM)
  	rndsource_element_t  rnd_source;
  #endif