head	1.1;
branch	1.1.1;
access;
symbols
	RELENG_9_1_0_RELEASE:1.1.1.2
	RELENG_9_1:1.1.1.2.0.54
	RELENG_9_1_BP:1.1.1.2
	RELENG_8_3_0_RELEASE:1.1.1.2
	RELENG_8_3:1.1.1.2.0.52
	RELENG_8_3_BP:1.1.1.2
	RELENG_9_0_0_RELEASE:1.1.1.2
	RELENG_9_0:1.1.1.2.0.50
	RELENG_9_0_BP:1.1.1.2
	RELENG_9:1.1.1.2.0.48
	RELENG_9_BP:1.1.1.2
	RELENG_7_4_0_RELEASE:1.1.1.2
	RELENG_8_2_0_RELEASE:1.1.1.2
	RELENG_7_4:1.1.1.2.0.46
	RELENG_7_4_BP:1.1.1.2
	RELENG_8_2:1.1.1.2.0.44
	RELENG_8_2_BP:1.1.1.2
	RELENG_8_1_0_RELEASE:1.1.1.2
	RELENG_8_1:1.1.1.2.0.42
	RELENG_8_1_BP:1.1.1.2
	RELENG_7_3_0_RELEASE:1.1.1.2
	RELENG_7_3:1.1.1.2.0.40
	RELENG_7_3_BP:1.1.1.2
	RELENG_8_0_0_RELEASE:1.1.1.2
	RELENG_8_0:1.1.1.2.0.38
	RELENG_8_0_BP:1.1.1.2
	RELENG_8:1.1.1.2.0.36
	RELENG_8_BP:1.1.1.2
	RELENG_7_2_0_RELEASE:1.1.1.2
	RELENG_7_2:1.1.1.2.0.34
	RELENG_7_2_BP:1.1.1.2
	RELENG_7_1_0_RELEASE:1.1.1.2
	RELENG_6_4_0_RELEASE:1.1.1.2
	RELENG_7_1:1.1.1.2.0.32
	RELENG_7_1_BP:1.1.1.2
	RELENG_6_4:1.1.1.2.0.30
	RELENG_6_4_BP:1.1.1.2
	RELENG_7_0_0_RELEASE:1.1.1.2
	RELENG_6_3_0_RELEASE:1.1.1.2
	RELENG_7_0:1.1.1.2.0.28
	RELENG_7_0_BP:1.1.1.2
	RELENG_6_3:1.1.1.2.0.26
	RELENG_6_3_BP:1.1.1.2
	RELENG_7:1.1.1.2.0.24
	RELENG_7_BP:1.1.1.2
	RELENG_6_2_0_RELEASE:1.1.1.2
	RELENG_6_2:1.1.1.2.0.22
	RELENG_6_2_BP:1.1.1.2
	RELENG_5_5_0_RELEASE:1.1.1.2
	RELENG_5_5:1.1.1.2.0.20
	RELENG_5_5_BP:1.1.1.2
	RELENG_6_1_0_RELEASE:1.1.1.2
	RELENG_6_1:1.1.1.2.0.18
	RELENG_6_1_BP:1.1.1.2
	RELENG_6_0_0_RELEASE:1.1.1.2
	RELENG_6_0:1.1.1.2.0.16
	RELENG_6_0_BP:1.1.1.2
	RELENG_6:1.1.1.2.0.14
	RELENG_6_BP:1.1.1.2
	RELENG_5_4_0_RELEASE:1.1.1.2
	RELENG_5_4:1.1.1.2.0.12
	RELENG_5_4_BP:1.1.1.2
	RELENG_4_11_0_RELEASE:1.1.1.1
	RELENG_4_11:1.1.1.1.0.20
	RELENG_4_11_BP:1.1.1.1
	RELENG_5_3_0_RELEASE:1.1.1.2
	RELENG_5_3:1.1.1.2.0.10
	RELENG_5_3_BP:1.1.1.2
	RELENG_5:1.1.1.2.0.8
	RELENG_5_BP:1.1.1.2
	RELENG_4_10_0_RELEASE:1.1.1.1
	RELENG_4_10:1.1.1.1.0.18
	RELENG_4_10_BP:1.1.1.1
	RELENG_5_2_1_RELEASE:1.1.1.2
	RELENG_5_2_0_RELEASE:1.1.1.2
	RELENG_5_2:1.1.1.2.0.6
	RELENG_5_2_BP:1.1.1.2
	RELENG_4_9_0_RELEASE:1.1.1.1
	RELENG_4_9:1.1.1.1.0.16
	RELENG_4_9_BP:1.1.1.1
	RELENG_5_1_0_RELEASE:1.1.1.2
	RELENG_5_1:1.1.1.2.0.4
	RELENG_5_1_BP:1.1.1.2
	RELENG_4_8_0_RELEASE:1.1.1.1
	RELENG_4_8:1.1.1.1.0.14
	RELENG_4_8_BP:1.1.1.1
	RELENG_5_0_0_RELEASE:1.1.1.2
	RELENG_5_0:1.1.1.2.0.2
	RELENG_5_0_BP:1.1.1.2
	RELENG_4_7_0_RELEASE:1.1.1.1
	RELENG_4_7:1.1.1.1.0.12
	RELENG_4_7_BP:1.1.1.1
	RELENG_4_6_2_RELEASE:1.1.1.1
	RELENG_4_6_1_RELEASE:1.1.1.1
	RELENG_4_6_0_RELEASE:1.1.1.1
	RELENG_4_6:1.1.1.1.0.10
	RELENG_4_6_BP:1.1.1.1
	RELENG_4_5_0_RELEASE:1.1.1.1
	RELENG_4_5:1.1.1.1.0.8
	RELENG_4_5_BP:1.1.1.1
	RELENG_4_4_0_RELEASE:1.1.1.1
	RELENG_4_4:1.1.1.1.0.6
	RELENG_4_4_BP:1.1.1.1
	RELENG_4_3_0_RELEASE:1.1.1.1
	RELENG_4_3:1.1.1.1.0.4
	RELENG_4_3_BP:1.1.1.1
	RELENG_4_2_0_RELEASE:1.1.1.1
	RELENG_4_1_1_RELEASE:1.1.1.1
	PRE_SMPNG:1.1.1.1
	RELENG_4_1_0_RELEASE:1.1.1.1
	RELENG_4_0_0_RELEASE:1.1.1.1
	RELENG_4:1.1.1.1.0.2
	RELENG_4_BP:1.1.1.1
	v4_0_99b:1.1.1.1
	DMILLS:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2000.01.28.14.51.01;	author roberto;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.01.28.14.51.01;	author roberto;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2002.10.29.20.11.45;	author roberto;	state dead;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#! /usr/bin/perl -w

die "perl5 needed\n" unless ($] > 5);

use Getopt::Std;
use vars qw($opt_n);

getopts('d:nt:');

#chop($ncpu = `sysctl -n hw.ncpu`);
#die "Found $ncpu CPUs; can only be run on systems with 1 CPU.\n" if ($ncpu > 1);

$driftfile = "/etc/ntp.drift";
$driftfile = $opt_d if defined($opt_d);

chop($timer = `sysctl -n kern.timecounter.hardware 2> /dev/null`);

$timer =~ tr/\U/\L/;

if ($timer eq '') {
  open(DM, "/var/run/dmesg.boot");
  while(<DM>) {
    # Timecounter "i8254"  frequency 1193182 Hz
    if (/^Timecounter "(\w+)"\s+/) {
      $timer = $1;
      last;
    }
  }
  close(DM);
}

$opt_t = $timer if !defined($opt_t);

if ($timer ne '') {		# $timer found...
  if ($opt_t ne  '') {		# - and $opt_t found
    if ($timer ne $opt_t) {	# - - and they differ
      warn "You specified a $opt_t timer but I detected a $timer timer.\n";
      usage();
      exit 1;
    } else {			# - - and they are the same
      ;
    }
  } else {			# - but no $opt_t specified; this is OK
    ;
  }
} else {			# No $timer found...
  if ($opt_t ne '') {		# - but $opt_t was specified
    $timer = $opt_t;		# - - so use it.
  } else {			# - and neither was $opt_t
    warn "I can't tell what timer you have.  Please specify one.\n";
    usage();
    exit 1;
  }
}

open(DF, $driftfile) || die "Can't open driftfile ($driftfile): $!\n";
while(<DF>) {
    chop;
    if (/^(-?\d+\.\d+)(\s\d)?$/) {
	$drift = $1;
    } else {
	die "Bogus value in driftfile $driftfile: <$_>\n";
    }
}
close(DF);

print "NTP drift is <$drift>\n";

# Convert from NTP's idea of PPM to a decimal equivalent
$freq_adj = int ( $drift * ( 10 ** 6 / 2 ** 20) );
print "normalized freq_adj  is <$freq_adj>\n";

$freq_adj = int ( ( $freq_adj - 1 ) / 2 );
print "Applying freq_adj of <".-$freq_adj.">\n";

$sysctl = "machdep.".$timer."_freq";

chop($mach_freq = `sysctl -n $sysctl`);

print "$sysctl is <$mach_freq>\n";

$n_mach_freq = $mach_freq - $freq_adj;

if (defined($opt_n)) {
  print "$sysctl $mach_freq -> $n_mach_freq\n";
} else {
  print "i8254: ".`sysctl -w $sysctl=$n_mach_freq`;
}

sub usage {
  print STDERR <<EOUsage
Usage: $0 [-d drift_file] [-n] [-t timer]
where "drift_file" defaults to /etc/ntp.drift
and "timer" is usually "tsc" or "i8254"
and "-n" says "don't really change anything, just say what would happen".
EOUsage
}
@


1.1.1.1
log
@Virgin import of ntpd 4.0.99b
@
text
@@


1.1.1.2
log
@Remove files not present in 4.1.1a import.
@
text
@@

