|
|
1.1 root 1: /*
2: * Precise Delay Loops for i386
3: *
4: * Copyright (C) 1993 Linus Torvalds
5: * Copyright (C) 1997 Martin Mares <[email protected]>
6: *
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.
11: */
12:
13: #include <linux/sched.h>
14: #include <linux/delay.h>
15:
16: #ifdef __SMP__
17: #include <asm/smp.h>
18: #endif
19:
20: void __delay(unsigned long loops)
21: {
22: int d0;
23: __asm__ __volatile__(
24: "\tjmp 1f\n"
25: ".align 16\n"
26: "1:\tjmp 2f\n"
27: ".align 16\n"
28: "2:\tdecl %0\n\tjns 2b"
29: :"=&a" (d0)
30: :"0" (loops));
31: }
32:
33: inline void __const_udelay(unsigned long xloops)
34: {
35: int d0;
36: __asm__("mull %0"
37: :"=d" (xloops), "=&a" (d0)
38: :"1" (xloops),"0" (loops_per_sec));
39: __delay(xloops);
40: }
41:
42: void __udelay(unsigned long usecs)
43: {
44: __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */
45: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.