aboutsummaryrefslogtreecommitdiffstats
path: root/netbsd-2.0-xen-sparse
diff options
context:
space:
mode:
authorcl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>2004-09-22 12:47:22 +0000
committercl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>2004-09-22 12:47:22 +0000
commitca6844e34594e7d671675cae464c4f8da1c80fa4 (patch)
treefeed4b7df1d4c83cd47c86e2259adae19b63a3ef /netbsd-2.0-xen-sparse
parentf3a93d856b8acb74c05ee15d6db4294ecc2a80f0 (diff)
downloadxen-ca6844e34594e7d671675cae464c4f8da1c80fa4.tar.gz
xen-ca6844e34594e7d671675cae464c4f8da1c80fa4.tar.bz2
xen-ca6844e34594e7d671675cae464c4f8da1c80fa4.zip
bitkeeper revision 1.1159.79.13 (4151745aQFYQyiyDcwHh4KsbytECJg)
Fix time.
Diffstat (limited to 'netbsd-2.0-xen-sparse')
-rw-r--r--netbsd-2.0-xen-sparse/sys/arch/xen/conf/XEN1
-rw-r--r--netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c31
2 files changed, 28 insertions, 4 deletions
diff --git a/netbsd-2.0-xen-sparse/sys/arch/xen/conf/XEN b/netbsd-2.0-xen-sparse/sys/arch/xen/conf/XEN
index 2fbb9998ac..e54802263f 100644
--- a/netbsd-2.0-xen-sparse/sys/arch/xen/conf/XEN
+++ b/netbsd-2.0-xen-sparse/sys/arch/xen/conf/XEN
@@ -13,7 +13,6 @@ maxusers 32 # estimated number of users
#
options XEN
#options DOM0OPS
-options HZ=50
#options I586_CPU
options I686_CPU
diff --git a/netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c b/netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c
index 6783f69363..fa7d986eb9 100644
--- a/netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c
+++ b/netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c
@@ -54,13 +54,17 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.1.2.2 2004/07/17 16:43:56 he Exp $");
static int xen_timer_handler(void *, struct trapframe *);
/* These are peridically updated in shared_info, and then copied here. */
-static unsigned long shadow_tsc_stamp;
-static u_int64_t shadow_system_time;
+static uint64_t shadow_tsc_stamp;
+static uint64_t shadow_system_time;
static unsigned long shadow_time_version;
static struct timeval shadow_tv;
static int timeset;
+static uint64_t processed_system_time;
+
+#define NS_PER_TICK (1000000000ULL/hz)
+
/*
* Reads a consistent set of time-base values from Xen, into a shadow data
* area. Must be called at splclock.
@@ -79,6 +83,16 @@ get_time_values_from_xen(void)
} while (shadow_time_version != HYPERVISOR_shared_info->time_version1);
}
+static uint64_t
+get_tsc_offset_ns(void)
+{
+ uint32_t tsc_delta;
+ struct cpu_info *ci = curcpu();
+
+ tsc_delta = cpu_counter32() - shadow_tsc_stamp;
+ return tsc_delta * 1000000000 / cpu_frequency(ci);
+}
+
void
inittodr(time_t base)
{
@@ -190,6 +204,9 @@ xen_initclocks()
{
int irq = bind_virq_to_irq(VIRQ_TIMER);
+ get_time_values_from_xen();
+ processed_system_time = shadow_system_time;
+
event_set_handler(irq, (int (*)(void *))xen_timer_handler,
NULL, IPL_CLOCK);
hypervisor_enable_irq(irq);
@@ -198,6 +215,8 @@ xen_initclocks()
static int
xen_timer_handler(void *arg, struct trapframe *regs)
{
+ int64_t delta;
+
#if defined(I586_CPU) || defined(I686_CPU)
static int microset_iter; /* call cc_microset once/sec */
struct cpu_info *ci = curcpu();
@@ -223,7 +242,13 @@ xen_timer_handler(void *arg, struct trapframe *regs)
get_time_values_from_xen();
- hardclock((struct clockframe *)regs);
+ delta = (int64_t)(shadow_system_time + get_tsc_offset_ns() -
+ processed_system_time);
+ while (delta >= NS_PER_TICK) {
+ hardclock((struct clockframe *)regs);
+ delta -= NS_PER_TICK;
+ processed_system_time += NS_PER_TICK;
+ }
return 0;
}