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-sparc / delay.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-20  |  1002 b   |  41 lines

  1. #ifndef __SPARC_DELAY_H
  2. #define __SPARC_DELAY_H
  3.  
  4. extern unsigned long loops_per_sec;
  5.  
  6. /*
  7.  * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu).
  8.  *
  9.  * Delay quick inlined code using 'loops_per_second' which is
  10.  * calculated in calibrate_delay() in main.c (ie. BogoMIPS :-)
  11.  */
  12.  
  13. extern __inline__ void __delay(unsigned int loops)
  14. {
  15.   __asm__ __volatile__("\n1:\tcmp %0, 0\n\t"
  16.                "bne,a 1b\n\t"
  17.                "sub %0, 1, %0\n": "=&r" (loops) : "0" (loops));
  18. }
  19.  
  20. /* udelay(usecs) is used for very short delays up to 1 millisecond. */
  21.  
  22. extern __inline__ void udelay(unsigned int usecs)
  23. {
  24.   usecs *= 0x000010c6;         /* Sparc is 32-bit just like ix86 */
  25.  
  26.   __asm__("sethi %hi(_loops_per_sec), %o1\n\t"
  27.       "ld [%o1 + %lo(_loops_per_sec)], %o1\n\t"
  28.       "call ___delay\n\t"
  29.       "umul %o1, %o0, %o0\n\t");
  30. }
  31.  
  32. /* calibrate_delay() wants this... */
  33.  
  34. extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
  35. {
  36.     return ((a*b)/c);
  37. }
  38.  
  39. #endif /* defined(__SPARC_DELAY_H) */
  40.  
  41.