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-m68k / delay.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-28  |  976 b   |  41 lines

  1. #ifndef _M68K_DELAY_H
  2. #define _M68K_DELAY_H
  3.  
  4. /*
  5.  * Copyright (C) 1994 Hamish Macdonald
  6.  *
  7.  * Delay routines, using a pre-computed "loops_per_second" value.
  8.  */
  9.  
  10. extern __inline__ void __delay(int loops)
  11. {
  12.     __asm__("\n\tmovel %0,d0\n1:\tsubql #1,d0\n\tbpls 1b\n"
  13.         : /* no outputs */
  14.         : "g" (loops)
  15.         : "d0");
  16. }
  17.  
  18. /*
  19.  * division by multiplication: you don't have to worry about
  20.  * loss of precision.
  21.  *
  22.  * Use only for very small delays ( < 1 msec).  Should probably use a
  23.  * lookup table, really, as the multiplications take much too long with
  24.  * short delays.  This is a "reasonable" implementation, though (and the
  25.  * first constant multiplications gets optimized away if the delay is
  26.  * a constant)  
  27.  */
  28. extern __inline__ void udelay(unsigned long usecs)
  29. {
  30.     asm ("mulul %1,d0,%0\n\t"
  31.          "divul  %2,d0,%0"
  32.          : "=d" (usecs)
  33.          : "d" (usecs),
  34.            "i" (1000000),
  35.            "0" (loops_per_sec)
  36.          : "d0");
  37.     __delay(usecs);
  38. }
  39.  
  40. #endif /* defined(_M68K_DELAY_H) */
  41.