Timecounters for hp700 from Garrett. Tested by me.

This commit is contained in:
skrll 2006-09-16 15:43:24 +00:00
parent dfef23e0d0
commit 05f8bc59e4
3 changed files with 35 additions and 39 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/time.h>
#include <sys/timetc.h>
#include <machine/pdc.h>
#include <machine/iomod.h>
@ -56,26 +57,54 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.5 2006/09/15 07:51:17 skrll Exp $");
#include <ddb/db_extern.h>
#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);

View File

@ -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 <hppa/hppa/trap.S>

View File

@ -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_ */