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