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 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)
*/
11 {
12 __asm__(".align 2,0x90\n1:\tdecl %0\n\tjns 1b": :"a" (loops):"ax");
13 }
14
15 /*
16 * division by multiplication: you don't have to worry about
17 * loss of precision.
18 *
19 * Use only for very small delays ( < 1 msec). Should probably use a
20 * lookup table, really, as the multiplications take much too long with
21 * short delays. This is a "reasonable" implementation, though (and the
22 * first constant multiplications gets optimized away if the delay is
23 * a constant)
24 */
25 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)
*/
26 {
27 usecs *= 0x000010c6; /* 2**32 / 1000000 */
28 __asm__("mull %0"
29 :"=d" (usecs)
30 :"a" (usecs),"0" (loops_per_sec)
31 :"ax");
32 __delay(usecs);
33 }
34
35 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)
*/
36 {
37 __asm__("mull %1 ; divl %2"
38 :"=a" (a)
39 :"d" (b),
40 "r" (c),
41 "0" (a)
42 :"dx");
43 return a;
44 }
45
46 #endif /* defined(_I386_DELAY_H) */