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) /**/ 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) /*
*/ 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 #endif /* defined(_I386_DELAY_H) */