diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-11-27 21:47:15 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-11-27 21:47:15 +0000 |
commit | cfd792315d36da5bd25ea7553f1b8ff07c32569f (patch) | |
tree | 0b3e1b6d67062dc9c1a07c9bf37114d8561f4db6 /sys/arch/hppa | |
parent | d89097e161bdceaa7d8366237301a50ee9b885b4 (diff) |
no wrapper arounf hardclock(), use CPU_CLOCKUPDATE, real microtime; miod ok
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r-- | sys/arch/hppa/dev/clock.c | 43 | ||||
-rw-r--r-- | sys/arch/hppa/dev/cpu.c | 4 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/locore.S | 37 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/machdep.c | 27 | ||||
-rw-r--r-- | sys/arch/hppa/include/cpu.h | 11 |
5 files changed, 39 insertions, 83 deletions
diff --git a/sys/arch/hppa/dev/clock.c b/sys/arch/hppa/dev/clock.c index aadf3e6b9d4..e9b6ec902ec 100644 --- a/sys/arch/hppa/dev/clock.c +++ b/sys/arch/hppa/dev/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.16 2002/09/15 09:45:15 mickey Exp $ */ +/* $OpenBSD: clock.c,v 1.17 2002/11/27 21:47:14 mickey Exp $ */ /* * Copyright (c) 1998,1999 Michael Shalayeff @@ -52,50 +52,12 @@ #include <ddb/db_extern.h> #endif -struct timeval time; -int cpu_clockok; - -void startrtclock(void); - void cpu_initclocks() { - extern u_int cpu_hzticks; - u_int time_inval; - - /* Start the interval timer. */ - mfctl(CR_ITMR, time_inval); - mtctl(time_inval + cpu_hzticks, CR_ITMR); - - cpu_clockok = 1; -} - -int -clock_intr (v) - void *v; -{ - struct trapframe *frame = v; - - /* printf ("clock int 0x%x @ 0x%x for %p\n", t, - frame->tf_iioq_head, curproc); */ - - if (!cpu_clockok) - return (1); - - cpu_initclocks(); - hardclock(frame); - -#if 0 - ddb_regs = *frame; - db_show_regs(NULL, 0, 0, NULL); -#endif - - /* printf ("clock out 0x%x\n", t); */ - - return 1; + CPU_CLOCKUPDATE(); } - /* * initialize the system time from the time of day clock */ @@ -152,4 +114,3 @@ setstatclockrate(newhz) { /* nothing we can do */ } - diff --git a/sys/arch/hppa/dev/cpu.c b/sys/arch/hppa/dev/cpu.c index 661741c3be6..966e6e43ee7 100644 --- a/sys/arch/hppa/dev/cpu.c +++ b/sys/arch/hppa/dev/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.18 2002/05/23 16:03:39 mickey Exp $ */ +/* $OpenBSD: cpu.c,v 1.19 2002/11/27 21:47:14 mickey Exp $ */ /* * Copyright (c) 1998-2002 Michael Shalayeff @@ -186,7 +186,7 @@ cpuattach(parent, self, aux) /* sanity against lusers amongst config editors */ if (ca->ca_irq == 31) sc->sc_ih = cpu_intr_establish(IPL_CLOCK, ca->ca_irq, - clock_intr, NULL /*trapframe*/, &sc->sc_dev); + (int (*)(void *))hardclock, NULL /*frame*/, &sc->sc_dev); else printf ("%s: bad irq %d\n", sc->sc_dev.dv_xname, ca->ca_irq); } diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S index ab96aa15718..3c4f702c62e 100644 --- a/sys/arch/hppa/hppa/locore.S +++ b/sys/arch/hppa/hppa/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.96 2002/11/14 01:41:55 mickey Exp $ */ +/* $OpenBSD: locore.S,v 1.97 2002/11/27 21:47:14 mickey Exp $ */ /* * Copyright (c) 1998-2002 Michael Shalayeff @@ -2433,41 +2433,6 @@ $spstrcpy_exit copy r0, ret0 EXIT(spstrcpy) -/* - * adjust the time value - * XXX: do it the easy way, later we will calculate actual fuzz from itmr - */ -LEAF_ENTRY(microtime) - - /* t4 = splhigh() */ - mfctl eiem, t4 - mtctl r0, eiem - - .import time, data - ldil L%time, t3 - ldo R%time(t3), t3 - ldw 0(t3), t1 - ldw 4(t3), t2 - - /* splx(t4) */ - mtctl t4, eiem - - ldil L%-1000000, t3 - ldo R%-1000000(t3), t3 - - 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) - .import whichqs, data .import qs, data /* diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c index 41364dcd856..3302475881a 100644 --- a/sys/arch/hppa/hppa/machdep.c +++ b/sys/arch/hppa/hppa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.89 2002/11/08 01:59:53 mickey Exp $ */ +/* $OpenBSD: machdep.c,v 1.90 2002/11/27 21:47:14 mickey Exp $ */ /* * Copyright (c) 1999-2002 Michael Shalayeff @@ -139,7 +139,7 @@ struct pdc_cache pdc_cache PDC_ALIGNMENT; struct pdc_btlb pdc_btlb PDC_ALIGNMENT; /* w/ a little deviation should be the same for all installed cpus */ -u_int cpu_ticksnum, cpu_ticksdenom, cpu_hzticks; +u_int cpu_itmr, cpu_ticksnum, cpu_ticksdenom, cpu_hzticks; /* exported info */ char machine[] = MACHINE_ARCH; @@ -744,10 +744,31 @@ delay(us) while (start < end); us -= n; - mfctl(CR_ITMR, start); } } +void +microtime(struct timeval *tv) +{ + u_int itmr; + int s; + + s = splhigh(); + tv->tv_sec = time.tv_sec; + tv->tv_usec = time.tv_usec; + + mfctl(CR_ITMR, itmr); + itmr -= cpu_itmr; + splx(s); + + tv->tv_usec += itmr * cpu_ticksdenom / cpu_ticksnum; + if (tv->tv_usec > 1000000) { + tv->tv_usec -= 1000000; + tv->tv_sec++; + } +} + + static __inline void fall(c_base, c_count, c_loop, c_stride, data) int c_base, c_count, c_loop, c_stride, data; diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h index c741544f3d9..87a64c9734d 100644 --- a/sys/arch/hppa/include/cpu.h +++ b/sys/arch/hppa/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.35 2002/11/08 21:42:12 mickey Exp $ */ +/* $OpenBSD: cpu.h,v 1.36 2002/11/27 21:47:14 mickey Exp $ */ /* * Copyright (c) 2000-2002 Michael Shalayeff @@ -120,6 +120,14 @@ extern const char *cpu_typename; #define HPPA_SPA_ENABLE 0x00000020 #define HPPA_NMODSPBUS 64 +#define CPU_CLOCKUPDATE() do { \ + register_t __itmr; \ + __asm __volatile("mfctl %%cr16, %0" : "=r" (__itmr)); \ + cpu_itmr = __itmr; \ + __itmr += cpu_hzticks; \ + __asm __volatile("mtctl %0, %%cr16" :: "r" (__itmr)); \ +} while (0) + #define clockframe trapframe #define CLKF_PC(framep) ((framep)->tf_iioq_head) #define CLKF_INTR(framep) ((framep)->tf_flags & TFF_INTR) @@ -138,6 +146,7 @@ extern const char *cpu_typename; (((t)? pdcache : fdcache) (HPPA_SID_KERNEL,(vaddr_t)(a),(s))) extern int want_resched; +extern u_int cpu_itmr, cpu_hzticks; #define DELAY(x) delay(x) |