aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/lib/delay.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/x86_64/lib/delay.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/x86_64/lib/delay.c')
-rw-r--r--arch/x86_64/lib/delay.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c
new file mode 100644
index 000000000000..6e2d66472eb1
--- /dev/null
+++ b/arch/x86_64/lib/delay.c
@@ -0,0 +1,48 @@
1/*
2 * Precise Delay Loops for x86-64
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.
9 */
10
11#include <linux/config.h>
12#include <linux/sched.h>
13#include <linux/delay.h>
14#include <asm/delay.h>
15
16#ifdef CONFIG_SMP
17#include <asm/smp.h>
18#endif
19
20int x86_udelay_tsc = 0; /* Delay via TSC */
21
22void __delay(unsigned long loops)
23{
24 unsigned bclock, now;
25
26 rdtscl(bclock);
27 do
28 {
29 rep_nop();
30 rdtscl(now);
31 }
32 while((now-bclock) < loops);
33}
34
35inline void __const_udelay(unsigned long xloops)
36{
37 __delay(((xloops * cpu_data[_smp_processor_id()].loops_per_jiffy) >> 32) * HZ);
38}
39
40void __udelay(unsigned long usecs)
41{
42 __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */
43}
44
45void __ndelay(unsigned long nsecs)
46{
47 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
48}