root/include/asm-alpha/delay.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __delay
  2. udelay
  3. muldiv

   1 #ifndef __ALPHA_DELAY_H
   2 #define __ALPHA_DELAY_H
   3 
   4 extern unsigned long loops_per_sec;
   5 
   6 /*
   7  * Copyright (C) 1993 Linus Torvalds
   8  *
   9  * Delay routines, using a pre-computed "loops_per_second" value.
  10  */
  11 
  12 extern __inline__ void __delay(unsigned long loops)
     /* [previous][next][first][last][top][bottom][index][help] */
  13 {
  14         __asm__ __volatile__(".align 3\n"
  15                 "1:\tsubq %0,1,%0\n\t"
  16                 "bge %0,1b": "=r" (loops) : "0" (loops));
  17 }
  18 
  19 /*
  20  * division by multiplication: you don't have to worry about
  21  * loss of precision.
  22  *
  23  * Use only for very small delays ( < 1 msec).  Should probably use a
  24  * lookup table, really, as the multiplications take much too long with
  25  * short delays.  This is a "reasonable" implementation, though (and the
  26  * first constant multiplications gets optimized away if the delay is
  27  * a constant)
  28  */
  29 extern __inline__ void udelay(unsigned long usecs)
     /* [previous][next][first][last][top][bottom][index][help] */
  30 {
  31         usecs *= 0x000010c6f7a0b5edUL;          /* 2**64 / 1000000 */
  32         __asm__("umulh %1,%2,%0"
  33                 :"=r" (usecs)
  34                 :"r" (usecs),"r" (loops_per_sec));
  35         __delay(usecs);
  36 }
  37 
  38 /*
  39  * 64-bit integers means we don't have to worry about overflow as
  40  * on some other architectures..
  41  */
  42 extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
     /* [previous][next][first][last][top][bottom][index][help] */
  43 {
  44         return (a*b)/c;
  45 }
  46 
  47 #endif /* defined(__ALPHA_DELAY_H) */

/* [previous][next][first][last][top][bottom][index][help] */