diff options
| author | joerg <joerg@NetBSD.org> | 2008-01-07 17:27:12 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2008-01-07 17:27:12 +0000 |
| commit | e47a5502a7832c7f00a75dc061831d9e6df375c1 (patch) | |
| tree | 95fa4055343b15d8452c122e1735bad8ffbef94e /sys/arch/usermode/dev/clock.c | |
| parent | 0a53bb0b5b340bdafda042710e32daefc96ed321 (diff) | |
Use gettimeofday as timecounter.
Diffstat (limited to 'sys/arch/usermode/dev/clock.c')
| -rw-r--r-- | sys/arch/usermode/dev/clock.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/sys/arch/usermode/dev/clock.c b/sys/arch/usermode/dev/clock.c index 227ce0eb502..d54468855c7 100644 --- a/sys/arch/usermode/dev/clock.c +++ b/sys/arch/usermode/dev/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.1 2007/12/29 14:38:31 jmcneill Exp $ */ +/* $NetBSD: clock.c,v 1.2 2008/01/07 17:27:12 joerg Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> @@ -33,13 +33,14 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.1 2007/12/29 14:38:31 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.2 2008/01/07 17:27:12 joerg Exp $"); #include <sys/param.h> #include <sys/proc.h> #include <sys/user.h> #include <sys/systm.h> #include <sys/device.h> +#include <sys/timetc.h> #include <machine/mainbus.h> @@ -47,6 +48,7 @@ static int clock_match(device_t, cfdata_t, void *); static void clock_attach(device_t, device_t, void *); static void clock_intr(int); +static u_int clock_getcounter(struct timecounter *); typedef struct clock_softc { device_t sc_dev; @@ -54,6 +56,17 @@ typedef struct clock_softc { extern int setitimer(int, const struct itimerval *, struct itimerval *); +static struct timecounter clock_timecounter = { + clock_getcounter, /* get_timecount */ + 0, /* no poll_pps */ + ~0u, /* counter_mask */ + 1000000, /* frequency */ + "gettimeofday", /* name */ + 100, /* quality */ + NULL, /* prev */ + NULL, /* next */ +}; + CFATTACH_DECL_NEW(clock, sizeof(clock_softc_t), clock_match, clock_attach, NULL, NULL); @@ -85,6 +98,8 @@ clock_attach(device_t parent, device_t self, void *opaque) itimer.it_interval.tv_usec = 10000; itimer.it_value = itimer.it_interval; (void)setitimer(ITIMER_REAL, &itimer, NULL); + + tc_init(&clock_timecounter); } static void @@ -101,3 +116,13 @@ clock_intr(int notused) hardclock(&cf); } + +static u_int +clock_getcounter(struct timecounter *tc) +{ + extern int gettimeofday(struct timeval *, void *); + struct timeval tv; + + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000 + tv.tv_usec; +} |
