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