2 * Precise Delay Loops for i386
4 * Copyright (C) 1993 Linus Torvalds
5 * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
7 * The __delay function must _NOT_ be inlined as its execution time
8 * depends wildly on alignment on many x86 processors. The additional
9 * jump magic is needed to get the timing stable on all the CPU's
10 * we have to worry about.
13 #include <linux/sched.h>
14 #include <linux/delay.h>
15 #include <asm/delay.h>
21 int x86_udelay_tsc
= 0; /* Delay via TSC */
25 * Do a udelay using the TSC for any CPU that happens
26 * to have one that we trust. This could be optimised to avoid
27 * the multiply per loop but its a delay loop so who are we kidding...
30 static void __rdtsc_delay(unsigned long loops
)
32 unsigned long bclock
, now
;
39 while((now
-bclock
) < loops
);
43 * Non TSC based delay loop for 386, 486, MediaGX
46 static void __loop_delay(unsigned long loops
)
54 "2:\tdecl %0\n\tjns 2b"
59 void __delay(unsigned long loops
)
67 inline void __const_udelay(unsigned long xloops
)
71 :"=d" (xloops
), "=&a" (d0
)
72 :"1" (xloops
),"0" (current_cpu_data
.loops_per_sec
));
76 void __udelay(unsigned long usecs
)
78 __const_udelay(usecs
* 0x000010c6); /* 2**32 / 1000000 */