diff options
author | Thomas Nordin <nordin@cvs.openbsd.org> | 2002-09-24 00:06:24 +0000 |
---|---|---|
committer | Thomas Nordin <nordin@cvs.openbsd.org> | 2002-09-24 00:06:24 +0000 |
commit | ab4b95ffcece79129777c12ef6f57359cad0ac57 (patch) | |
tree | b668d32e880f909117fb0b77520f400df7e72f1e /sys/arch/i386 | |
parent | bd4cd4bc31f25cda237420e9652344299167b4cf (diff) |
Restore pentium_microtime, testing by henning@, millert@. ok deraadt@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/microtime.s | 30 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 17 |
2 files changed, 31 insertions, 16 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 |