delay.h

Go to the documentation of this file.
00001 #ifndef _LINUX_DELAY_H
00002 #define _LINUX_DELAY_H
00003 
00004 /**
00005 *
00006 
00007  * Copyright (C) 1993 Linus Torvalds
00008  *
00009  * Delay routines, using a pre-computed "loops_per_second" value.
00010 
00011 
00012 */
00013 
00014 extern unsigned long loops_per_sec;
00015 
00016 extern __inline__ void __delay(int loops)
00017 {
00018         __asm__(".align 2,0x90\n1:\tdecl %0\n\tjns 1b": :"a" (loops):"ax");
00019 }
00020 
00021 /**
00022 *
00023 
00024  * division by multiplication: you don't have to worry about
00025  * loss of precision.
00026  *
00027  * Use only for very small delays ( < 1 msec).  Should probably use a
00028  * lookup table, really, as the multiplications take much too long with
00029  * short delays.  This is a "reasonable" implementation, though (and the
00030  * first constant multiplications gets optimized away if the delay is
00031  * a constant)
00032 
00033 
00034 */
00035 extern __inline__ void udelay(unsigned long usecs)
00036 {
00037         usecs *= 0x000010c6;            ///< 2**32 / 1000000 
00038         __asm__("mull %0"
00039                 :"=d" (usecs)
00040                 :"a" (usecs),"0" (loops_per_sec)
00041                 :"ax");
00042         __delay(usecs);
00043 }
00044 
00045 #endif

Generated on Mon May 1 21:47:00 2006 for KernelAPI by  doxygen 1.4.6-5