From 05f8bc59e4aa7860cb6da59259c5b36c4fe86c53 Mon Sep 17 00:00:00 2001 From: skrll Date: Sat, 16 Sep 2006 15:43:24 +0000 Subject: [PATCH] Timecounters for hp700 from Garrett. Tested by me. --- sys/arch/hp700/dev/clock.c | 35 ++++++++++++++++++++++++++++++--- sys/arch/hp700/hp700/locore.S | 36 +--------------------------------- sys/arch/hp700/include/types.h | 3 ++- 3 files changed, 35 insertions(+), 39 deletions(-) diff --git a/sys/arch/hp700/dev/clock.c b/sys/arch/hp700/dev/clock.c index 4a2b846ca62f..f16c23264527 100644 --- a/sys/arch/hp700/dev/clock.c +++ b/sys/arch/hp700/dev/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.5 2006/09/15 07:51:17 skrll Exp $ */ +/* $NetBSD: clock.c,v 1.6 2006/09/16 15:43:24 skrll Exp $ */ /* $OpenBSD: clock.c,v 1.10 2001/08/31 03:13:42 mickey Exp $ */ @@ -33,12 +33,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.5 2006/09/15 07:51:17 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.6 2006/09/16 15:43:24 skrll Exp $"); #include #include #include #include +#include #include #include @@ -56,26 +57,54 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.5 2006/09/15 07:51:17 skrll Exp $"); #include #endif +static unsigned get_itimer_count(struct timecounter *); + void cpu_initclocks(void) { + static struct timecounter tc = { + .tc_get_timecount = get_itimer_count, + .tc_name = "itimer", + .tc_counter_mask = ~0, + .tc_quality = 100, + }; + extern u_int cpu_hzticks; u_int time_inval; + tc.tc_frequency = cpu_hzticks * hz; + /* Start the interval timer. */ mfctl(CR_ITMR, time_inval); mtctl(time_inval + cpu_hzticks, CR_ITMR); + + tc_init(&tc); +} + +unsigned +get_itimer_count(struct timecounter *tc) +{ + uint32_t val; + + mfctl(CR_ITMR, val); + + return val; } int clock_intr(void *v) { struct clockframe *frame = v; + extern u_int cpu_hzticks; + u_int time_inval; + + /* Restart the interval timer. */ + mfctl(CR_ITMR, time_inval); + mtctl(time_inval + cpu_hzticks, CR_ITMR); /* printf ("clock int 0x%x @ 0x%x for %p\n", t, CLKF_PC(frame), curproc); */ - cpu_initclocks(); if (!cold) hardclock(frame); diff --git a/sys/arch/hp700/hp700/locore.S b/sys/arch/hp700/hp700/locore.S index 7930f501a92f..3fedf2b430d0 100644 --- a/sys/arch/hp700/hp700/locore.S +++ b/sys/arch/hp700/hp700/locore.S @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.14 2005/12/11 12:17:24 christos Exp $ */ +/* $NetBSD: locore.S,v 1.15 2006/09/16 15:43:24 skrll Exp $ */ /* $OpenBSD: locore.S,v 1.46 2001/09/20 18:33:03 mickey Exp $ */ @@ -701,40 +701,6 @@ forever: ; Loop until bus reset takes effect. nop EXIT(cpu_die) -/* - * adjust the time value - * XXX: do it the easy way, later we will calculate actual fuzz from itr - */ -LEAF_ENTRY(microtime) - - .import time, data - ldil L%-1000000, %t3 - ldil L%time, %t1 - ldo R%-1000000(%t3), %t3 - - /* t4 = splhigh() */ - mfctl %eiem, %t4 - mtctl %r0, %eiem - - ldw R%time+4(%t1), %t2 - ldw R%time(%t1), %t1 - - /* splx(%t4) */ - mtctl %t4, %eiem - - addi 1, %t2, %t2 - addb,<,n %t2, %t3, microtime_no - addi 1, %t1, %t1 - - copy %t3, %t2 - -microtime_no: - stwm %t1, 4(%arg0) - bv (%rp) - stw %t2, 0(%arg0) - -EXIT(microtime) - /* Include the system call and trap handling. */ #include diff --git a/sys/arch/hp700/include/types.h b/sys/arch/hp700/include/types.h index 6f764525b0e9..96a6462a6e7d 100644 --- a/sys/arch/hp700/include/types.h +++ b/sys/arch/hp700/include/types.h @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.6 2006/09/15 07:51:17 skrll Exp $ */ +/* $NetBSD: types.h,v 1.7 2006/09/16 15:43:24 skrll Exp $ */ #ifndef _HP700_TYPES_H_ #define _HP700_TYPES_H_ @@ -8,5 +8,6 @@ #define __HAVE_GENERIC_SOFT_INTERRUPTS #define __HAVE_DEVICE_REGISTER #define __HAVE_GENERIC_TODR +#define __HAVE_TIMECOUNTER #endif /* _HP700_TYPES_H_ */