home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / KERNEL-S / V1.2 / LINUX-1.2 / LINUX-1 / linux / include / asm-i386 / delay.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-14  |  1.1 KB  |  47 lines

  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. extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
  36. {
  37.     __asm__("mull %1 ; divl %2"
  38.         :"=a" (a)
  39.         :"d" (b),
  40.          "r" (c),
  41.          "0" (a)
  42.         :"dx");
  43.     return a;
  44. }
  45.  
  46. #endif /* defined(_I386_DELAY_H) */
  47.