Port-vax archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Timecounter patch for testing
Hi all,
please test this patch and report back. Diff is against netbsd-4 for
simplier testing, but it should almost directly apply to HEAD.
Joerg
Index: include/types.h
===================================================================
RCS file: /data/repo/netbsd/src/sys/arch/vax/include/types.h,v
retrieving revision 1.32
diff -u -p -r1.32 types.h
--- include/types.h 5 Sep 2006 19:33:55 -0000 1.32
+++ include/types.h 5 Jan 2008 02:07:04 -0000
@@ -67,5 +67,6 @@ typedef volatile int __cpu_simple_lock_
#define __HAVE_GENERIC_TODR
#define __HAVE_MD_RUNQUEUE
#define __HAVE_SYSCALL_INTERN
+#define __HAVE_TIMECOUNTER
#endif /* _MACHTYPES_H_ */
Index: vax/clock.c
===================================================================
RCS file: /data/repo/netbsd/src/sys/arch/vax/vax/clock.c,v
retrieving revision 1.46
diff -u -p -r1.46 clock.c
--- vax/clock.c 16 Sep 2006 00:50:52 -0000 1.46
+++ vax/clock.c 5 Jan 2008 02:07:04 -0000
@@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/timetc.h>
#include <sys/device.h>
#include <machine/mtpr.h>
@@ -58,61 +59,59 @@ static struct todr_chip_handle todr_hand
.todr_settime = vax_settime,
};
+static u_int
+vax_diag_get_counter(struct timecounter *tc)
+{
+ extern struct vs_cpu *ka46_cpu;
+ int cur_hardclock;
+ u_int counter;
-/*
- * microtime() should return number of usecs in struct timeval.
- * We may get wrap-arounds, but that will be fixed with lasttime
- * check. This may fault within 10 msecs.
- */
-void
-microtime(struct timeval *tvp)
+ do {
+ cur_hardclock = hardclock_ticks;
+ counter = *(volatile u_int *)&ka46_cpu->vc_diagtimu;
+ } while (cur_hardclock == hardclock_ticks);
+
+ counter = (counter & 0x3ff) + (counter >> 16) * 1024;
+
+ return counter + hardclock_ticks * tick;
+}
+
+static u_int
+vax_mfpr_get_counter(struct timecounter *tc)
{
- int s, i;
- static struct timeval lasttime;
+ int cur_hardclock;
+ u_int counter;
- s = splhigh();
- *tvp = time;
+ do {
+ cur_hardclock = hardclock_ticks;
+ counter = mfpr(PR_ICR);
+ } while (cur_hardclock == hardclock_ticks);
- switch (vax_boardtype) {
-#if VAX46 || VAXANY
- case VAX_BTYP_46: {
- extern struct vs_cpu *ka46_cpu;
- i = *(volatile int *)(&ka46_cpu->vc_diagtimu);
- i = (i >> 16) * 1024 + (i & 0x3ff);
- break;
- }
-#endif
-#if VAX48 || VAXANY
- case VAX_BTYP_48: {
- /*
- * PR_ICR doesn't exist. We could use the vc_diagtimu
- * counter, saving the value on the timer interrupt and
- * subtracting that from the current value.
- */
- i = 0;
- break;
- }
-#endif
- default:
- i = mfpr(PR_ICR);
- break;
- }
- i += tick; /* Get current interval count */
- tvp->tv_usec += i;
- while (tvp->tv_usec >= 1000000) {
- tvp->tv_sec++;
- tvp->tv_usec -= 1000000;
- }
- if (tvp->tv_sec == lasttime.tv_sec &&
- tvp->tv_usec <= lasttime.tv_usec &&
- (tvp->tv_usec = lasttime.tv_usec + 1) >= 1000000) {
- tvp->tv_sec++;
- tvp->tv_usec -= 1000000;
- }
- lasttime = *tvp;
- splx(s);
+ return counter + hardclock_ticks * tick;
}
+static struct timecounter vax_diag_tc = {
+ vax_diag_get_counter, /* get_timecount */
+ 0, /* no poll_pps */
+ ~0u, /* counter_mask */
+ 1000000, /* frequency */
+ "diagtimer", /* name */
+ 100, /* quality */
+ NULL, /* prev */
+ NULL, /* next */
+};
+
+static struct timecounter vax_mfpr_tc = {
+ vax_mfpr_get_counter, /* get_timecount */
+ 0, /* no poll_pps */
+ ~0u, /* counter_mask */
+ 1000000, /* frequency */
+ "mfpr", /* name */
+ 100, /* quality */
+ NULL, /* prev */
+ NULL, /* next */
+};
+
/*
* A delayloop that delays about the number of milliseconds that is
* given as argument.
@@ -135,6 +134,11 @@ cpu_initclocks(void)
mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */
todr_attach(&todr_handle);
+
+ if (vax_boardtype == VAX_BTYP_46)
+ tc_init(&vax_diag_tc);
+ else if (vax_boardtype != VAX_BTYP_48)
+ tc_init(&vax_mfpr_tc);
}
int
Home |
Main Index |
Thread Index |
Old Index