The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/include/asm-mips64/delay.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * This file is subject to the terms and conditions of the GNU General Public
    3  * License.  See the file "COPYING" in the main directory of this archive
    4  * for more details.
    5  *
    6  * Copyright (C) 1994 by Waldorf Electronics
    7  * Copyright (C) 1995 - 2000 by Ralf Baechle
    8  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
    9  */
   10 #ifndef _ASM_DELAY_H
   11 #define _ASM_DELAY_H
   12 
   13 #include <linux/config.h>
   14 #include <linux/param.h>
   15 
   16 extern unsigned long loops_per_jiffy;
   17 
   18 static __inline__ void
   19 __delay(unsigned long loops)
   20 {
   21         __asm__ __volatile__ (
   22                 ".set\tnoreorder\n"
   23                 "1:\tbnez\t%0,1b\n\t"
   24                 "dsubu\t%0,1\n\t"
   25                 ".set\treorder"
   26                 :"=r" (loops)
   27                 :"" (loops));
   28 }
   29 
   30 /*
   31  * Division by multiplication: you don't have to worry about
   32  * loss of precision.
   33  *
   34  * Use only for very small delays ( < 1 msec).  Should probably use a
   35  * lookup table, really, as the multiplications take much too long with
   36  * short delays.  This is a "reasonable" implementation, though (and the
   37  * first constant multiplications gets optimized away if the delay is
   38  * a constant)
   39  */
   40 static inline void __udelay(unsigned long usecs, unsigned long lpj)
   41 {
   42         unsigned long lo;
   43 
   44         /*
   45          * The common rates of 1000 and 128 are rounded wrongly by the
   46          * catchall case.  Excessive precission?  Probably ...
   47          */
   48 #if (HZ == 128)
   49         usecs *= 0x0008637bd05af6c7UL;          /* 2**64 / (1000000 / HZ) */
   50 #elif (HZ == 1000)
   51         usecs *= 0x004189374BC6A7f0UL;          /* 2**64 / (1000000 / HZ) */
   52 #else
   53         usecs *= (0x8000000000000000UL / (500000 / HZ));
   54 #endif
   55         __asm__("dmultu\t%2,%3"
   56                 :"=h" (usecs), "=l" (lo)
   57                 :"r" (usecs),"r" (lpj));
   58         __delay(usecs);
   59 }
   60 
   61 static inline void __ndelay(unsigned long nsecs, unsigned long lpj)
   62 {
   63         unsigned long lo;
   64 
   65         /*
   66          * The common rates of 1000 and 128 are rounded wrongly by the
   67          * catchall case.  Excessive precission?  Probably ...
   68          */
   69 #if (HZ == 128)
   70         nsecs *= 0x000001ad7f29abcbUL;          /* 2**64 / (1000000000 / HZ) */
   71 #elif (HZ == 1000)
   72         nsecs *= 0x0010c6f7a0b5eeUL;            /* 2**64 / (1000000000 / HZ) */
   73 #else
   74         nsecs *= (0x8000000000000000UL / (500000000 / HZ));
   75 #endif
   76         __asm__("dmultu\t%2,%3"
   77                 :"=h" (nsecs), "=l" (lo)
   78                 :"r" (nsecs),"r" (lpj));
   79         __delay(nsecs);
   80 }
   81 
   82 #ifdef CONFIG_SMP
   83 #define __udelay_val cpu_data[smp_processor_id()].udelay_val
   84 #else
   85 #define __udelay_val loops_per_jiffy
   86 #endif
   87 
   88 #define udelay(usecs) __udelay((usecs),__udelay_val)
   89 #define ndelay(nsecs) __ndelay((nsecs),__udelay_val)
   90 
   91 #endif /* _ASM_DELAY_H */

Cache object: 0ad6be69d743d0e06019c72995143f96


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.