Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/sys/arch/sparc64/sparc64 Pull up revision 1.55 (request...
details: https://anonhg.NetBSD.org/src/rev/0773b2d308bc
branches: netbsd-1-6
changeset: 530427:0773b2d308bc
user: grant <grant%NetBSD.org@localhost>
date: Tue Jun 24 09:32:16 2003 +0000
description:
Pull up revision 1.55 (requested by nakayama in ticket #1329):
Switch to use cycle counter (%tick) based microtime().
This is derived from alpha/microtime.c and i386/tsc_microtime.c,
and will share with both ports.
diffstat:
sys/arch/sparc64/sparc64/clock.c | 61 ++++++++++++++++++++++++++++++++-------
1 files changed, 50 insertions(+), 11 deletions(-)
diffs (163 lines):
diff -r e36844b7d654 -r 0773b2d308bc sys/arch/sparc64/sparc64/clock.c
--- a/sys/arch/sparc64/sparc64/clock.c Tue Jun 24 09:31:35 2003 +0000
+++ b/sys/arch/sparc64/sparc64/clock.c Tue Jun 24 09:32:16 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.49.6.1 2002/12/01 22:02:58 he Exp $ */
+/* $NetBSD: clock.c,v 1.49.6.2 2003/06/24 09:32:16 grant Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -93,8 +93,6 @@
#include <dev/ebus/ebusreg.h>
#include <dev/ebus/ebusvar.h>
-extern u_int64_t cpu_clockrate;
-
struct rtc_info {
bus_space_tag_t rtc_bt; /* bus tag & handle */
bus_space_handle_t rtc_bh; /* */
@@ -635,9 +633,11 @@
}
/* Make sure we have a sane cpu_clockrate -- we'll need it */
- if (!cpu_clockrate)
+ if (!cpu_clockrate[0]) {
/* Default to 200MHz clock XXXXX */
- cpu_clockrate = 200000000;
+ cpu_clockrate[0] = 200000000;
+ cpu_clockrate[1] = 200000000 / 1000000;
+ }
/*
* Calculate the starting %tick value. We set that to the same
@@ -645,9 +645,9 @@
* we can handle it. time.tv_usec is in microseconds.
* cpu_clockrate is in MHz.
*/
- start_time = time.tv_sec * cpu_clockrate;
+ start_time = time.tv_sec * cpu_clockrate[0];
/* Now fine tune the usecs */
- start_time += cpu_clockrate / 1000000 * time.tv_usec;
+ start_time += time.tv_usec * cpu_clockrate[1];
/* Initialize the %tick register */
#ifdef __arch64__
@@ -669,7 +669,7 @@
if (!timerreg_4u.t_timer || !timerreg_4u.t_clrintr) {
printf("No counter-timer -- using %%tick at %ldMHz as system clock.\n",
- (long)(cpu_clockrate/1000000));
+ (long)cpu_clockrate[1]);
/* We don't have a counter-timer -- use %tick */
level0.ih_clr = 0;
/*
@@ -684,7 +684,7 @@
stathz = 0;
/* set the next interrupt time */
- tick_increment = cpu_clockrate / hz;
+ tick_increment = cpu_clockrate[0] / hz;
#ifdef DEBUG
printf("Using %%tick -- intr in %ld cycles...", tick_increment);
#endif
@@ -768,19 +768,21 @@
clockintr(cap)
void *cap;
{
+ static int microset_iter; /* call cc_microset once/sec */
+ struct cpu_info *ci = curcpu();
#ifdef DEBUG
static int64_t tick_base = 0;
int64_t t = (u_int64_t)tick();
if (!tick_base) {
tick_base = (time.tv_sec * 1000000LL + time.tv_usec)
- * 1000000LL / cpu_clockrate;
+ / cpu_clockrate[1];
tick_base -= t;
} else if (clockcheck) {
int64_t tk = t;
int64_t clk = (time.tv_sec * 1000000LL + time.tv_usec);
t -= tick_base;
- t = t * 1000000LL / cpu_clockrate;
+ t = t / cpu_clockrate[1];
if (t - clk > hz) {
printf("Clock lost an interrupt!\n");
printf("Actual: %llx Expected: %llx tick %llx tick_base %llx\n",
@@ -790,6 +792,19 @@
}
}
#endif
+ if (
+#ifdef MULTIPROCESSOR
+ CPU_IS_PRIMARY(ci) &&
+#endif
+ (microset_iter--) == 0) {
+ microset_iter = hz - 1;
+ cc_microset_time = time;
+#ifdef MULTIPROCESSOR
+ /* XXX broadcast IPI_MICROSET code here */
+#endif
+ cc_microset(ci);
+ }
+
/* Let locore.s clear the interrupt for us. */
hardclock((struct clockframe *)cap);
return (1);
@@ -809,6 +824,8 @@
tickintr(cap)
void *cap;
{
+ static int microset_iter; /* call cc_microset once/sec */
+ struct cpu_info *ci = curcpu();
int s;
#if NKBD > 0
@@ -816,6 +833,19 @@
extern int rom_console_input;
#endif
+ if (
+#ifdef MULTIPROCESSOR
+ CPU_IS_PRIMARY(ci) &&
+#endif
+ (microset_iter--) == 0) {
+ microset_iter = hz - 1;
+ cc_microset_time = time;
+#ifdef MULTIPROCESSOR
+ /* XXX broadcast IPI_MICROSET code here */
+#endif
+ cc_microset(ci);
+ }
+
hardclock((struct clockframe *)cap);
if (poll_console)
setsoftint();
@@ -916,11 +946,15 @@
* anything better, resetting the clock.
*/
time.tv_sec = base;
+ cc_microset_time = time;
+ cc_microset(curcpu());
if (!badbase)
resettodr();
} else {
int deltat = time.tv_sec - base;
+ cc_microset_time = time;
+ cc_microset(curcpu());
sparc_clock_time_is_ok = 1;
if (deltat < 0)
@@ -946,6 +980,11 @@
if (time.tv_sec == 0)
return;
+ cc_microset_time = time;
+#ifdef MULTIPROCESSOR
+ /* XXX broadcast IPI_MICROSET code here */
+#endif
+ cc_microset(curcpu());
sparc_clock_time_is_ok = 1;
if (todr_handle == 0 ||
todr_settime(todr_handle, (struct timeval *)&time) != 0)
Home |
Main Index |
Thread Index |
Old Index