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 externunsignedlongloops_per_sec;
11
12 extern__inline__void__delay(intloops)
/* */ 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__voidudelay(unsignedlongusecs)
/* */ 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