clock.h revision 3307
1/* 2 * Kernel interface to machine-dependent clock driver. 3 * Garrett Wollman, September 1994. 4 * This file is in the public domain. 5 */ 6 7#ifndef _MACHINE_CLOCK_H_ 8#define _MACHINE_CLOCK_H_ 1 9 10void inittodr(time_t base); 11 12extern int pentium_mhz; 13 14#ifdef I586_CPU 15 /* 16 * This resets the CPU cycle counter to zero, to make our 17 * job easier in microtime(). Some fancy ifdefs could speed 18 * this up for Pentium-only kernels. 19 * We want this to be done as close as possible to the actual 20 * timer incrementing in hardclock(), because there is a window 21 * between the two where the value is no longer valid. Experimentation 22 * may reveal a good precompensation to apply in microtime(). 23 */ 24#define CPU_CLOCKUPDATE(otime, ntime) \ 25 do { \ 26 if(pentium_mhz) { \ 27 __asm __volatile("cli\n" \ 28 "movl (%2),%%eax\n" \ 29 "movl %%eax,(%1)\n" \ 30 "movl 4(%2),%%eax\n" \ 31 "movl %%eax,4(%1)\n" \ 32 "movl $0x10,%%ecx\n" \ 33 "xorl %%eax,%%eax\n" \ 34 "movl %%eax,%%edx\n" \ 35 ".byte 0x0f, 0x30\n" \ 36 "sti\n" \ 37 "#%0%1%2" \ 38 : "=m"(*otime) /* no outputs */ \ 39 : "c"(otime), "b"(ntime) /* fake input */ \ 40 : "ax", "cx", "dx"); \ 41 } else { \ 42 *(otime) = *(ntime); \ 43 } \ 44 } while(0) 45 46#else 47#define CPU_CLOCKUPDATE(otime, ntime) \ 48 (*(otime) = *(ntime)) 49#endif 50 51#endif /* _MACHINE_CLOCK_H_ */ 52