1 #ifndef__ALPHA_DELAY_H 2 #define__ALPHA_DELAY_H 3
4 externunsignedlongloops_per_sec;
5
6 /* 7 * Copyright (C) 1993 Linus Torvalds 8 * 9 * Delay routines, using a pre-computed "loops_per_second" value. 10 */ 11
12 extern__inline__void__delay(unsignedlongloops)
/* */ 13 { 14 __asm____volatile__(".align 3\n"
15 "1:\tsubq %0,1,%0\n\t"
16 "bge %0,1b": "=r" (loops) : "0" (loops));
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__voidudelay(unsignedlongusecs)
/* */ 30 { 31 usecs *= 0x000010c6f7a0b5edUL; /* 2**64 / 1000000 */ 32 __asm__("umulh %1,%2,%0"
33 :"=r" (usecs)
34 :"r" (usecs),"r" (loops_per_sec));
35 __delay(usecs);
36 } 37
38 /* 39 * 64-bit integers means we don't have to worry about overflow as 40 * on some other architectures.. 41 */ 42 extern__inline__unsignedlongmuldiv(unsignedlonga, unsignedlongb, unsignedlongc)
/* */ 43 { 44 return (a*b)/c;
45 } 46
47 #endif/* defined(__ALPHA_DELAY_H) */