~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/arch/i386/delay.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *      Precise Delay Loops for i386
3
 
 *
4
 
 *      Copyright (C) 1993 Linus Torvalds
5
 
 *      Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6
 
 *
7
 
 *      The __delay function must _NOT_ be inlined as its execution time
8
 
 *      depends wildly on alignment on many x86 processors. The additional
9
 
 *      jump magic is needed to get the timing stable on all the CPU's
10
 
 *      we have to worry about.
11
 
 */
12
 
 
13
 
#include <xeno/config.h>
14
 
#include <xeno/delay.h>
15
 
#include <asm/msr.h>
16
 
#include <asm/processor.h>
17
 
 
18
 
void __udelay(unsigned long usecs)
19
 
{
20
 
    unsigned long ticks = usecs * ticks_per_usec;
21
 
    unsigned long s, e;
22
 
 
23
 
    rdtscl(s);
24
 
    do
25
 
    {
26
 
        rep_nop();
27
 
        rdtscl(e);
28
 
    } while ((e-s) < ticks);
29
 
}