|
|
1.1 ! root 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: #include <linux/linkage.h> ! 11: ! 12: #ifdef __SMP__ ! 13: #include <asm/smp.h> ! 14: #endif ! 15: ! 16: extern void __do_delay(void); /* Special register call calling convention */ ! 17: ! 18: extern __inline__ void __delay(int loops) ! 19: { ! 20: __asm__ __volatile__( ! 21: "call " SYMBOL_NAME_STR(__do_delay) ! 22: :/* no outputs */ ! 23: :"a" (loops) ! 24: :"ax"); ! 25: } ! 26: ! 27: /* ! 28: * division by multiplication: you don't have to worry about ! 29: * loss of precision. ! 30: * ! 31: * Use only for very small delays ( < 1 msec). Should probably use a ! 32: * lookup table, really, as the multiplications take much too long with ! 33: * short delays. This is a "reasonable" implementation, though (and the ! 34: * first constant multiplications gets optimized away if the delay is ! 35: * a constant) ! 36: */ ! 37: extern __inline__ void udelay(unsigned long usecs) ! 38: { ! 39: usecs *= 0x000010c6; /* 2**32 / 1000000 */ ! 40: __asm__("mull %0" ! 41: :"=d" (usecs) ! 42: #ifdef __SMP__ ! 43: :"a" (usecs),"0" (cpu_data[smp_processor_id()].udelay_val) ! 44: #else ! 45: :"a" (usecs),"0" (loops_per_sec) ! 46: #endif ! 47: :"ax"); ! 48: ! 49: __delay(usecs); ! 50: } ! 51: ! 52: extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c) ! 53: { ! 54: __asm__("mull %1 ; divl %2" ! 55: :"=a" (a) ! 56: :"d" (b), ! 57: "r" (c), ! 58: "0" (a) ! 59: :"dx"); ! 60: return a; ! 61: } ! 62: ! 63: #endif /* defined(_I386_DELAY_H) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.