[ntp:questions] like a kid with a new toy (PPS jitter)

Dave Hart davehart at gmail.com
Tue Feb 10 21:53:48 UTC 2009

On Feb 10, 12:58 pm, Chris <givemeafckingacctyoudou... at gmail.com>
> While I only have Windows 2003 DDK installed at the moment, they do
> include a complete serial device driver source project.
> I've only done very minor Windows driver programming, but I may try to
> download the newest DDK and give it a whirl.

You might as well be up-to-date, but my hunch is the serial code in
the DDK hasn't changed in a while.  It's great the serial.sys source
is there as a baseline.

> // This bit is the delta data carrier detect.  It is used to indicate
> // that the data carrier bit (in this register) has *changed*
> // since this register was last read by the CPU.
> //
> #define SERIAL_MSR_DDCD     0x08
> and
>  if (ModemStatus & (SERIAL_MSR_DCTS |
>                            SERIAL_MSR_DDSR |
>                            SERIAL_MSR_TERI |
>                            SERIAL_MSR_DDCD)) {
> I think the change would/could be done in modmflow.c or isr.c, but I'd
> really have to do some reading to get comfortable with driver
> programming. I'm not really sure how'd I'd signal an event to the ATOM
> driver (perhaps through DeviceIoCtrl?)- Hide quoted text -

It sounds like you're on the right track.  I believe the typical
approach on Unix does use ioctls, but it's an implementation choice as
long as you provide a matching ppsapi.h.  ntpd calls a ppsapi
interface to get the timestamp of the last PPS, which could use
DeviceIoControl to retrieve it.  However, there is a complicaton.
Unlike most modern unix platforms, Windows doesn't have a high-
resolution system clock with which to provide a reasonable timestamp
from the serial driver.  I think you can overcome this by returning a
KeQueryPerformanceCounter (or whatever drivers call it) "timestamp"
and then hook your ppsapi implementation into the ntpd Windows
interpolation code to translate the performance counter value to a
timestamp.  You might also run up against divergent QPC counters on
each processor, though most machines keep them at least roughly

It's a project :)

Dave Hart

More information about the questions mailing list