Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jul 1997 19:57:11 PDT
From:      Craig Leres <leres@ee.lbl.gov>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/4112: Re: PPSCLOCK kernel diffs
Message-ID:  <199707180257.TAA17361@hot.ee.lbl.gov>
Resent-Message-ID: <199707180300.UAA23001@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         4112
>Category:       kern
>Synopsis:       PPSCLOCK kernel diffs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 17 20:00:01 PDT 1997
>Last-Modified:
>Originator:     Craig Leres
>Organization:
Lawrence Berkeley National Laboratory
>Release:        FreeBSD 2.2.2-RELEASE i386
>Environment:

	

>Description:

	Appended are context diffs to the 2.2.2-RELEASE kernel that
	add the PPSCLOCK option. Although the system already has
	the ability to capture DCD timestamps, the existing code
	suffers from several problems. First, the timestamp is not
	taken as soon as possible; measurements show that 2-3
	microseconds are lost on a really fast system like a 200
	MHz pentium pro. 2nd, the lack of a event serial number
	makes it impossible to detect extra or missing pulses.

	In addition to the standard PPSCLOCK functionality provided
	by the original LBL ppsclock package, the new code included
	in this patch gives the user the ability to capture on the
	leading or trailing edge.

	The current layout has a new include file, sys/ppsclock.h.
	It might be a better idea to move the contents of this file
	into sys/ttycom.h and rename the two new ioctls so they
	fit in with the other TIO* ioctls.

>How-To-Repeat:

	

>Fix:
	
	


------ i386/isa/sio.c diffs

RCS file: RCS/sio.c,v
retrieving revision 1.1
diff -c -r1.1 sio.c
*** /tmp/,RCSt1005653	Thu Jul 17 18:54:38 1997
--- sio.c	Fri Jul 11 22:30:05 1997
***************
*** 64,69 ****
--- 64,72 ----
  #ifdef DEVFS
  #include <sys/devfsext.h>
  #endif
+ #ifdef PPSCLOCK
+ #include <sys/ppsclock.h>
+ #endif
  
  #include <machine/clock.h>
  
***************
*** 245,252 ****
--- 248,262 ----
  
  	bool_t	do_timestamp;
  	bool_t	do_dcd_timestamp;
+ #ifdef PPSCLOCK
+ 	bool_t	do_pps_timestamp;
+ 	bool_t	pps_tet;	/* trailing edge trigger */
+ #endif
  	struct timeval	timestamp;
  	struct timeval	dcd_timestamp;
+ #ifdef PPSCLOCK
+ 	struct ppsclockev ppsclock;
+ #endif
  
  	u_long	bytes_in;	/* statistics */
  	u_long	bytes_out;
***************
*** 1298,1303 ****
--- 1308,1317 ----
  	com->poll_output = FALSE;
  	com->do_timestamp = FALSE;
  	com->do_dcd_timestamp = FALSE;
+ #ifdef PPSCLOCK
+ 	com->do_pps_timestamp = FALSE;
+ 	com->pps_tet = FALSE;
+ #endif
  	outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
  	{
  		outb(iobase + com_ier, 0);
***************
*** 1468,1473 ****
--- 1482,1505 ----
  	u_char	recv_data;
  
  	while (TRUE) {
+ #ifdef PPSCLOCK
+ 		/*
+ 		 * Check the modem status now so we get a better
+ 		 * timestamp (On a 200 MHZ Pentium Pro this makes
+ 		 * a difference of about 2 or 3 microseconds...)
+ 		 *
+ 		 * If data carrier detect changed and it was the
+ 		 * one we are waiting for (either leading or trailing
+ 		 * edge) then grab the timestamp.
+ 		 */
+ 		modem_status = inb(com->modem_status_port);
+ 		if (com->do_pps_timestamp &&
+ 		    ((modem_status ^ com->last_modem_status) & MSR_DCD) != 0 &&
+ 		    com->pps_tet ^ ((modem_status & MSR_DCD) != 0)) {
+ 			microtime(&com->ppsclock.tv);
+ 			++com->ppsclock.serial;
+ 		}
+ #endif
  		line_status = inb(com->line_status_port);
  
  #if NCRD > 0
***************
*** 1559,1565 ****
--- 1591,1600 ----
  		}
  
  		/* modem status change? (always check before doing output) */
+ #ifndef PPSCLOCK
+ 		/* If PPSCLOCK, we already did this */
  		modem_status = inb(com->modem_status_port);
+ #endif
  		if (modem_status != com->last_modem_status) {
  			if (com->do_dcd_timestamp
  			    && !(com->last_modem_status & MSR_DCD)
***************
*** 1813,1818 ****
--- 1848,1864 ----
  		com->do_dcd_timestamp = TRUE;
  		*(struct timeval *)data = com->dcd_timestamp;
  		break;
+ #ifdef PPSCLOCK
+ 	case CIOGETEV:
+ 		com->do_pps_timestamp = TRUE;
+ 		*(struct ppsclockev *)data = com->ppsclock;
+ 		break;
+ 
+ 	case CIOSETTET:
+ 		com->pps_tet = *(int *)data;
+ 		break;
+ #endif
+ 
  	default:
  		splx(s);
  		return (ENOTTY);


------ sys/ppsclock.h

/* @(#) $Header: ppsclock.h,v 1.2 97/07/11 22:29:42 leres Exp $ (LBL) */
/*
 * This software was developed by the Computer Systems Engineering group
 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66.
 *
 * Copyright (c) 1997 The Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Lawrence Berkeley Laboratory.
 * 4. The name of the University may not be used to endorse or promote
 *    products derived from this software without specific prior
 *    written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

struct ppsclockev {
	struct timeval tv;
	u_int serial;
};

#if defined(__STDC__)
#define CIOGETEV _IOR('t', 244, struct ppsclockev)	/* get last pps event *
/
#define CIOSETTET _IOW('t', 245, int)			/* trailing edge trig *
/
#else
#define CIOGETEV _IOR(t, 244, struct ppsclockev)	/* get last pps event *
/
#define CIOSETTET _IOW(t, 245, int)			/* trailing edge trig *
/
#endif

------- End of Forwarded Message

>Audit-Trail:
>Unformatted:
------- Forwarded Message

Date: Thu, 17 Jul 1997 18:57:25 -0700 (PDT)
From: leres@ee.lbl.gov (Craig Leres)
Subject: PPSCLOCK kernel diffs
To: FreeBSD-gnats-submit@freebsd.org
Cc: leres@ee.lbl.gov
Reply-To: leres@ee.lbl.gov
X-send-pr-version: 3.2





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707180257.TAA17361>