1 #ifndef __ALPHA_DELAY_H
2 #define __ALPHA_DELAY_H
3
4 extern unsigned long loops_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(unsigned long 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__ __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__ 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)
*/
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__ 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)
*/
43 {
44 return (a*b)/c;
45 }
46
47 #endif /* defined(__ALPHA_DELAY_H) */