diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /init/calibrate.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 'init/calibrate.c')
-rw-r--r-- | init/calibrate.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/init/calibrate.c b/init/calibrate.c new file mode 100644 index 000000000000..c698e04a3dbe --- /dev/null +++ b/init/calibrate.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* calibrate.c: default delay calibration | ||
2 | * | ||
3 | * Excised from init/main.c | ||
4 | * Copyright (C) 1991, 1992 Linus Torvalds | ||
5 | */ | ||
6 | |||
7 | #include <linux/sched.h> | ||
8 | #include <linux/delay.h> | ||
9 | #include <linux/init.h> | ||
10 | |||
11 | static unsigned long preset_lpj; | ||
12 | static int __init lpj_setup(char *str) | ||
13 | { | ||
14 | preset_lpj = simple_strtoul(str,NULL,0); | ||
15 | return 1; | ||
16 | } | ||
17 | |||
18 | __setup("lpj=", lpj_setup); | ||
19 | |||
20 | /* | ||
21 | * This is the number of bits of precision for the loops_per_jiffy. Each | ||
22 | * bit takes on average 1.5/HZ seconds. This (like the original) is a little | ||
23 | * better than 1% | ||
24 | */ | ||
25 | #define LPS_PREC 8 | ||
26 | |||
27 | void __devinit calibrate_delay(void) | ||
28 | { | ||
29 | unsigned long ticks, loopbit; | ||
30 | int lps_precision = LPS_PREC; | ||
31 | |||
32 | if (preset_lpj) { | ||
33 | loops_per_jiffy = preset_lpj; | ||
34 | printk("Calibrating delay loop (skipped)... " | ||
35 | "%lu.%02lu BogoMIPS preset\n", | ||
36 | loops_per_jiffy/(500000/HZ), | ||
37 | (loops_per_jiffy/(5000/HZ)) % 100); | ||
38 | } else { | ||
39 | loops_per_jiffy = (1<<12); | ||
40 | |||
41 | printk(KERN_DEBUG "Calibrating delay loop... "); | ||
42 | while ((loops_per_jiffy <<= 1) != 0) { | ||
43 | /* wait for "start of" clock tick */ | ||
44 | ticks = jiffies; | ||
45 | while (ticks == jiffies) | ||
46 | /* nothing */; | ||
47 | /* Go .. */ | ||
48 | ticks = jiffies; | ||
49 | __delay(loops_per_jiffy); | ||
50 | ticks = jiffies - ticks; | ||
51 | if (ticks) | ||
52 | break; | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * Do a binary approximation to get loops_per_jiffy set to | ||
57 | * equal one clock (up to lps_precision bits) | ||
58 | */ | ||
59 | loops_per_jiffy >>= 1; | ||
60 | loopbit = loops_per_jiffy; | ||
61 | while (lps_precision-- && (loopbit >>= 1)) { | ||
62 | loops_per_jiffy |= loopbit; | ||
63 | ticks = jiffies; | ||
64 | while (ticks == jiffies) | ||
65 | /* nothing */; | ||
66 | ticks = jiffies; | ||
67 | __delay(loops_per_jiffy); | ||
68 | if (jiffies != ticks) /* longer than 1 tick */ | ||
69 | loops_per_jiffy &= ~loopbit; | ||
70 | } | ||
71 | |||
72 | /* Round the value and print it */ | ||
73 | printk("%lu.%02lu BogoMIPS (lpj=%lu)\n", | ||
74 | loops_per_jiffy/(500000/HZ), | ||
75 | (loops_per_jiffy/(5000/HZ)) % 100, | ||
76 | loops_per_jiffy); | ||
77 | } | ||
78 | |||
79 | } | ||