1 #ifndef _I386_DELAY_H
2 #define _I386_DELAY_H
3
4 /*
5 * Copyright (C) 1993 Linus Torvalds
6 *
7 * Delay routines, using a pre-computed "loops_per_second" value.
8 */
9
10 #ifdef __SMP__
11 #include <asm/smp.h>
12 #endif
13
14 extern __inline__ void __delay(int loops)
/* ![[previous]](../icons/n_left.png)
![[next]](../icons/right.png)
![[first]](../icons/n_first.png)
![[last]](../icons/last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
15 {
16 __asm__(".align 2,0x90\n1:\tdecl %0\n\tjns 1b": :"a" (loops):"ax");
17 }
18
19 /*
20 * division by multiplication: you don't have to worry about
21 * loss of precision.
22 *
23 * Use only for very small delays ( < 1 msec). Should probably use a
24 * lookup table, really, as the multiplications take much too long with
25 * short delays. This is a "reasonable" implementation, though (and the
26 * first constant multiplications gets optimized away if the delay is
27 * a constant)
28 */
29 extern __inline__ void udelay(unsigned long usecs)
/* ![[previous]](../icons/left.png)
![[next]](../icons/right.png)
![[first]](../icons/first.png)
![[last]](../icons/last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
30 {
31 usecs *= 0x000010c6; /* 2**32 / 1000000 */
32 __asm__("mull %0"
33 :"=d" (usecs)
34 #ifdef __SMP__
35 :"a" (usecs),"0" (cpu_data[smp_processor_id()].udelay_val)
36 #else
37 :"a" (usecs),"0" (loops_per_sec)
38 #endif
39 :"ax");
40
41 __delay(usecs);
42 }
43
44 extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
/* ![[previous]](../icons/left.png)
![[next]](../icons/n_right.png)
![[first]](../icons/first.png)
![[last]](../icons/n_last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
45 {
46 __asm__("mull %1 ; divl %2"
47 :"=a" (a)
48 :"d" (b),
49 "r" (c),
50 "0" (a)
51 :"dx");
52 return a;
53 }
54
55 #endif /* defined(_I386_DELAY_H) */