netlib.narod.ru< Назад | Оглавление | Далее >

arch/i386/lib/delay.c

 6845 /*
 6846  *      Precise Delay Loops for i386
 6847  *
 6848  *      Copyright (C) 1993 Linus Torvalds
 6849  *      Copyright (C) 1997 Martin Mares
 6850  *                         <mj@atrey.karlin.mff.cuni.cz>
 6851  *
 6852  * The __delay function must _NOT_ be inlined as its
 6853  * execution time depends wildly on alignment on many x86
 6854  * processors. The additional jump magic is needed to get
 6855  * the timing stable on all the CPU's we have to worry
 6856  * about.
 6857  */
 6858 
 6859 #include <linux/sched.h>
 6860 #include <linux/delay.h>
 6861 
 6862 #ifdef __SMP__
 6863 #include <asm/smp.h>
 6864 #endif
 6865 
 6866 void __delay(unsigned long loops)
 6867 {
 6868   int d0;
 6869   __asm__ __volatile__(
 6870     "\tjmp 1f\n"
 6871     ".align 16\n"
 6872     "1:\tjmp 2f\n"
 6873     ".align 16\n"
 6874     "2:\tdecl %0\n\tjns 2b"
 6875     :"=&a" (d0)
 6876     :"0" (loops));
 6877 }
 6878 
 6879 inline void __const_udelay(unsigned long xloops)
 6880 {
 6881   int d0;
 6882   __asm__("mull %0"
 6883     :"=d" (xloops), "=&a" (d0)
 6884     :"1" (xloops),"0" (current_cpu_data.loops_per_sec));
 6885   __delay(xloops);
 6886 }
 6887 
 6888 void __udelay(unsigned long usecs)
 6889 {
 6890   __const_udelay(usecs * 0x000010c6); /* 2**32/1000000 */
 6891 }

netlib.narod.ru< Назад | Оглавление | Далее >

Сайт управляется системой uCoz