-/* $OpenBSD: clock.c,v 1.1 2005/04/01 10:40:47 mickey Exp $ */
+/* $OpenBSD: clock.c,v 1.2 2010/07/24 21:27:57 kettenis Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/time.h>
+#include <sys/timetc.h>
+
+#include <machine/iomod.h>
+#include <machine/reg.h>
#include <dev/clock_subr.h>
+u_long cpu_hzticks;
+
+u_int itmr_get_timecount(struct timecounter *);
+
+struct timecounter itmr_timecounter = {
+ itmr_get_timecount, NULL, 0xffffffff, 0, "itmr", 0, NULL
+};
+
void
cpu_initclocks()
{
+ struct cpu_info *ci = curcpu();
+ u_long __itmr;
+
+ cpu_hzticks = (PAGE0->mem_10msec * 100) / hz;
+ itmr_timecounter.tc_frequency = PAGE0->mem_10msec * 100;
+ tc_init(&itmr_timecounter);
+
+ __itmr = mfctl(CR_ITMR);
+ ci->ci_itmr = __itmr;
+ __itmr += cpu_hzticks;
+ mtctl(__itmr, CR_ITMR);
}
void
setstatclockrate(int newhz)
{
-
+ /* nothing we can do */
}
-void
-microtime(struct timeval *tv)
+u_int
+itmr_get_timecount(struct timecounter *tc)
{
-
+ return (mfctl(CR_ITMR));
}
-/* $OpenBSD: machdep.c,v 1.25 2010/07/01 05:09:27 jsing Exp $ */
+/* $OpenBSD: machdep.c,v 1.26 2010/07/24 21:27:57 kettenis Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
#include <sys/core.h>
#include <sys/kcore.h>
#include <sys/extent.h>
+#include <sys/timetc.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
{
struct pdc_tod tod PDC_ALIGNMENT;
int error, tbad = 0;
+ struct timespec ts;
if (t < 12*SECYR) {
printf ("WARNING: preposterous time in file system");
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");
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);
}
-/* $OpenBSD: _types.h,v 1.4 2008/07/21 20:50:54 martynas Exp $ */
+/* $OpenBSD: _types.h,v 1.5 2010/07/24 21:27:57 kettenis Exp $ */
/*-
* Copyright (c) 1990, 1993
typedef void * __wctrans_t;
typedef void * __wctype_t;
+/* Feature test macros */
+#define __HAVE_TIMECOUNTER
+
#endif /* _HPPA64__TYPES_H_ */
-/* $OpenBSD: cpu.h,v 1.16 2009/11/25 23:18:14 jsing Exp $ */
+/* $OpenBSD: cpu.h,v 1.17 2010/07/24 21:27:57 kettenis Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
/* Spinning up the CPU */
void (*ci_spinup)(void); /* spinup routine */
void *ci_initstack;
+
+ u_long ci_itmr;
};
struct cpu_info *curcpu(void);