diff options
-rw-r--r-- | sys/arch/i386/i386/microtime.s | 30 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 17 | ||||
-rw-r--r-- | sys/kern/kern_clock.c | 6 |
3 files changed, 36 insertions, 17 deletions
diff --git a/sys/arch/i386/i386/microtime.s b/sys/arch/i386/i386/microtime.s index 22ad3b82224..8ec301e0dc6 100644 --- a/sys/arch/i386/i386/microtime.s +++ b/sys/arch/i386/i386/microtime.s @@ -1,4 +1,4 @@ -/* $OpenBSD: microtime.s,v 1.15 2002/07/06 19:14:20 nordin Exp $ */ +/* $OpenBSD: microtime.s,v 1.16 2002/09/24 00:06:22 nordin Exp $ */ /* $NetBSD: microtime.s,v 1.16 1995/04/17 12:06:47 cgd Exp $ */ /*- @@ -48,7 +48,13 @@ #ifndef HZ ENTRY(microtime) +#if defined(I586_CPU) || defined(I686_CPU) + movl _pentium_mhz, %ecx + testl %ecx, %ecx + jne pentium_microtime +#else xorl %ecx,%ecx +#endif movb $(TIMER_SEL0|TIMER_LATCH),%al pushfl @@ -134,12 +140,30 @@ common_microtime: ret #if defined(I586_CPU) || defined(I686_CPU) - # XXX: Move to machdep.c? - .data .globl _pentium_base_tsc .comm _pentium_base_tsc,8 .text + + .align 2, 0x90 +pentium_microtime: + pushfl + cli + .byte 0x0f, 0x31 # RDTSC + subl _pentium_base_tsc,%eax + sbbl _pentium_base_tsc+4,%edx + /* + * correct the high word first so we won't + * receive a result overflow aka div/0 fault + */ + pushl %eax + movl %edx, %eax + shll $16, %edx + divw %cx + movzwl %dx, %edx + popl %eax + divl %ecx + jmp common_microtime #endif #endif diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 7c73020e71f..4e6f61855b2 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.42 2002/06/07 21:33:43 nordin Exp $ */ +/* $OpenBSD: cpu.h,v 1.43 2002/09/24 00:06:23 nordin Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -101,23 +101,14 @@ void delay(int); void calibrate_cyclecounter(void); #ifndef HZ extern u_quad_t pentium_base_tsc; -#define CPU_CLOCKUPDATE(otime, ntime) \ +#define CPU_CLOCKUPDATE() \ do { \ if (pentium_mhz) { \ __asm __volatile("cli\n" \ - "movl (%3), %%eax\n" \ - "movl %%eax, (%2)\n" \ - "movl 4(%3), %%eax\n" \ - "movl %%eax, 4(%2)\n" \ ".byte 0xf, 0x31\n" \ "sti\n" \ - "#%0 %1 %2 %3" \ - : "=m" (*otime), \ - "=A" (pentium_base_tsc) \ - : "c" (otime), "b" (ntime)); \ - } \ - else { \ - *(otime) = *(ntime); \ + : "=A" (pentium_base_tsc) \ + : ); \ } \ } while (0) #endif diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 9683ffeea48..05eaad94e34 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.39 2002/07/06 19:14:20 nordin Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.40 2002/09/24 00:06:23 nordin Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -224,6 +224,10 @@ hardclock(frame) BUMPTIME(&time, delta); BUMPTIME(&mono_time, delta); +#ifdef CPU_CLOCKUPDATE + CPU_CLOCKUPDATE(); +#endif + /* * Update real-time timeout queue. * Process callouts at a very low cpu priority, so we don't keep the |