diff options
author | wollman <wollman@FreeBSD.org> | 1994-09-18 20:40:01 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1994-09-18 20:40:01 +0000 |
commit | 9028bd50ffd972e1a3b8145652ee9287ebd2f680 (patch) | |
tree | 0542820657279835e2be295c7ffed111332b0a03 /sys/i386 | |
parent | 5de9aa67de26f3a6ec87731670b4bd6c04d312c3 (diff) | |
download | FreeBSD-src-9028bd50ffd972e1a3b8145652ee9287ebd2f680.zip FreeBSD-src-9028bd50ffd972e1a3b8145652ee9287ebd2f680.tar.gz |
Redo Kernel NTP PLL support, kernel side.
This code is mostly taken from the 1.1 port (which was in turn taken from
Dave Mills's kern.tar.Z example). A few significant differences:
1) ntp_gettime() is now a MIB variable rather than a system call. A few
fiddles are done in libc to make it behave the same.
2) mono_time does not participate in the PLL adjustments.
3) A new interface has been defined (in <machine/clock.h>) for doing
possibly machine-dependent things around the time of the clock update.
This is used in Pentium kernels to disable interrupts, set `time', and
reset the CPU cycle counter as quickly as possible to avoid jitter in
microtime(). Measurements show an apparent resolution of a bit more than
8.14usec, which is reasonable given system-call overhead.
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/tsc.c | 23 | ||||
-rw-r--r-- | sys/i386/include/clock.h | 49 | ||||
-rw-r--r-- | sys/i386/isa/clock.c | 23 |
3 files changed, 51 insertions, 44 deletions
diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c index 88942db..b762442 100644 --- a/sys/i386/i386/tsc.c +++ b/sys/i386/i386/tsc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.16 1994/08/18 22:34:50 wollman Exp $ + * $Id: clock.c,v 1.17 1994/09/14 23:09:06 ache Exp $ */ /* @@ -79,27 +79,6 @@ void clkintr(frame) struct clockframe frame; { -#ifdef I586_CPU - /* - * This resets the CPU cycle counter to zero, to make our - * job easier in microtime(). Some fancy ifdefs could speed - * this up for Pentium-only kernels. - * We want this to be done as close as possible to the actual - * timer incrementing in hardclock(), because there is a window - * between the two where the value is no longer valid. Experimentation - * may reveal a good precompensation to apply in microtime(). - */ - if(pentium_mhz) { - __asm __volatile("movl $0x10,%%ecx\n" - "xorl %%eax,%%eax\n" - "movl %%eax,%%edx\n" - ".byte 0x0f, 0x30\n" - "#%0%1" - : "=m"(frame) /* no outputs */ - : "b"(&frame) /* fake input */ - : "ax", "cx", "dx"); - } -#endif hardclock(&frame); } diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h new file mode 100644 index 0000000..b7420e4 --- /dev/null +++ b/sys/i386/include/clock.h @@ -0,0 +1,49 @@ +/* + * Kernel interface to machine-dependent clock driver. + * Garrett Wollman, September 1994. + * This file is in the public domain. + */ + +#ifndef _MACHINE_CLOCK_H_ +#define _MACHINE_CLOCK_H_ 1 + +extern int pentium_mhz; + +#ifdef I586_CPU + /* + * This resets the CPU cycle counter to zero, to make our + * job easier in microtime(). Some fancy ifdefs could speed + * this up for Pentium-only kernels. + * We want this to be done as close as possible to the actual + * timer incrementing in hardclock(), because there is a window + * between the two where the value is no longer valid. Experimentation + * may reveal a good precompensation to apply in microtime(). + */ +#define CPU_CLOCKUPDATE(otime, ntime) \ + do { \ + if(pentium_mhz) { \ + __asm __volatile("cli\n" \ + "movl (%2),%%eax\n" \ + "movl %%eax,(%1)\n" \ + "movl 4(%2),%%eax\n" \ + "movl %%eax,4(%1)\n" \ + "movl $0x10,%%ecx\n" \ + "xorl %%eax,%%eax\n" \ + "movl %%eax,%%edx\n" \ + ".byte 0x0f, 0x30\n" \ + "sti\n" \ + "#%0%1%2" \ + : "=m"(*otime) /* no outputs */ \ + : "c"(otime), "b"(ntime) /* fake input */ \ + : "ax", "cx", "dx"); \ + } else { \ + *(otime) = *(ntime); \ + } \ + } while(0) + +#else +#define CPU_CLOCKUPDATE(otime, ntime) \ + (*(otime) = *(ntime)) +#endif + +#endif /* _MACHINE_CLOCK_H_ */ diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 88942db..b762442 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.16 1994/08/18 22:34:50 wollman Exp $ + * $Id: clock.c,v 1.17 1994/09/14 23:09:06 ache Exp $ */ /* @@ -79,27 +79,6 @@ void clkintr(frame) struct clockframe frame; { -#ifdef I586_CPU - /* - * This resets the CPU cycle counter to zero, to make our - * job easier in microtime(). Some fancy ifdefs could speed - * this up for Pentium-only kernels. - * We want this to be done as close as possible to the actual - * timer incrementing in hardclock(), because there is a window - * between the two where the value is no longer valid. Experimentation - * may reveal a good precompensation to apply in microtime(). - */ - if(pentium_mhz) { - __asm __volatile("movl $0x10,%%ecx\n" - "xorl %%eax,%%eax\n" - "movl %%eax,%%edx\n" - ".byte 0x0f, 0x30\n" - "#%0%1" - : "=m"(frame) /* no outputs */ - : "b"(&frame) /* fake input */ - : "ax", "cx", "dx"); - } -#endif hardclock(&frame); } |