diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-07-22 19:24:46 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-07-22 19:24:46 +0000 |
commit | f4c93c3b2abfe5aa60705dfb1da7c381f74455b1 (patch) | |
tree | 52a9074997dfb8a04f0245802f61d6b605073eab /sys/arch/hppa/dev | |
parent | 6fb5eeac56c68b1fe0e9a10fc1f83dc50b021e53 (diff) |
Move hppa to __HAVE_TIMECOUNTERS.
Diffstat (limited to 'sys/arch/hppa/dev')
-rw-r--r-- | sys/arch/hppa/dev/clock.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/sys/arch/hppa/dev/clock.c b/sys/arch/hppa/dev/clock.c index 239c19dfe88..1d3aa2a3bd9 100644 --- a/sys/arch/hppa/dev/clock.c +++ b/sys/arch/hppa/dev/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.21 2004/04/07 18:24:19 mickey Exp $ */ +/* $OpenBSD: clock.c,v 1.22 2007/07/22 19:24:45 kettenis Exp $ */ /* * Copyright (c) 1998-2003 Michael Shalayeff @@ -29,7 +29,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> -#include <sys/time.h> +#include <sys/timetc.h> #include <dev/clock_subr.h> @@ -48,6 +48,12 @@ #include <ddb/db_extern.h> #endif +u_int itmr_get_timecount(struct timecounter *); + +struct timecounter itmr_timecounter = { + itmr_get_timecount, NULL, 0xffffffff, 0, "itmr", 0, NULL +}; + void cpu_initclocks() { @@ -55,6 +61,9 @@ cpu_initclocks() extern u_long cpu_hzticks; u_long __itmr; + itmr_timecounter.tc_frequency = PAGE0->mem_10msec * 100; + tc_init(&itmr_timecounter); + mfctl(CR_ITMR, __itmr); cpu_itmr = __itmr; __itmr += cpu_hzticks; @@ -70,6 +79,7 @@ inittodr(t) { struct pdc_tod tod PDC_ALIGNMENT; int error, tbad = 0; + struct timespec ts; if (t < 12*SECYR) { printf ("WARNING: preposterous time in file system"); @@ -81,18 +91,19 @@ inittodr(t) 1, PDC_TOD, PDC_TOD_READ, &tod, 0, 0, 0, 0, 0))) printf("clock: failed to fetch (%d)\n", error); - time.tv_sec = tod.sec; - time.tv_usec = tod.usec; + ts.tv_sec = tod.sec; + ts.tv_nsec = tod.usec * 1000; + tc_setclock(&ts); if (!tbad) { u_long dt; - dt = (time.tv_sec < t)? t - time.tv_sec : time.tv_sec - t; + dt = (tod.sec < t)? t - tod.sec : tod.sec - t; if (dt < 2 * SECDAY) return; printf("WARNING: clock %s %ld days", - time.tv_sec < t? "lost" : "gained", dt / SECDAY); + tod.sec < t? "lost" : "gained", dt / SECDAY); } printf (" -- CHECK AND RESET THE DATE!\n"); @@ -104,10 +115,13 @@ inittodr(t) void resettodr() { + struct timeval tv; int error; + microtime(&tv); + if ((error = pdc_call((iodcio_t)pdc, 1, PDC_TOD, PDC_TOD_WRITE, - time.tv_sec, time.tv_usec))) + tv.tv_sec, tv.tv_usec))) printf("clock: failed to save (%d)\n", error); } @@ -117,3 +131,12 @@ setstatclockrate(newhz) { /* nothing we can do */ } + +u_int +itmr_get_timecount(struct timecounter *tc) +{ + u_long __itmr; + + mfctl(CR_ITMR, __itmr); + return (__itmr); +} |