diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2006-12-06 20:14:08 -0500 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-12-06 20:14:08 -0500 |
commit | d7cd56111f30259e1b532a12e06f59f8e0a20355 (patch) | |
tree | 760e9548511ba30cf095f1873bcc9e301a89fa92 | |
parent | 139ec7c416248b9ea227d21839235344edfee1e0 (diff) |
[PATCH] i386: cpu_detect extraction
Both lhype and Xen want to call the core of the x86 cpu detect code before
calling start_kernel.
(extracted from larger patch)
AK: folded in start_kernel header patch
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
-rw-r--r-- | arch/i386/kernel/cpu/common.c | 37 | ||||
-rw-r--r-- | include/asm-i386/processor.h | 3 | ||||
-rw-r--r-- | include/linux/start_kernel.h | 12 | ||||
-rw-r--r-- | init/main.c | 1 |
4 files changed, 37 insertions, 16 deletions
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index cda41aef79ad..68bcb687019a 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c | |||
@@ -236,29 +236,14 @@ static int __cpuinit have_cpuid_p(void) | |||
236 | return flag_is_changeable_p(X86_EFLAGS_ID); | 236 | return flag_is_changeable_p(X86_EFLAGS_ID); |
237 | } | 237 | } |
238 | 238 | ||
239 | /* Do minimum CPU detection early. | 239 | void __init cpu_detect(struct cpuinfo_x86 *c) |
240 | Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment. | ||
241 | The others are not touched to avoid unwanted side effects. | ||
242 | |||
243 | WARNING: this function is only called on the BP. Don't add code here | ||
244 | that is supposed to run on all CPUs. */ | ||
245 | static void __init early_cpu_detect(void) | ||
246 | { | 240 | { |
247 | struct cpuinfo_x86 *c = &boot_cpu_data; | ||
248 | |||
249 | c->x86_cache_alignment = 32; | ||
250 | |||
251 | if (!have_cpuid_p()) | ||
252 | return; | ||
253 | |||
254 | /* Get vendor name */ | 241 | /* Get vendor name */ |
255 | cpuid(0x00000000, &c->cpuid_level, | 242 | cpuid(0x00000000, &c->cpuid_level, |
256 | (int *)&c->x86_vendor_id[0], | 243 | (int *)&c->x86_vendor_id[0], |
257 | (int *)&c->x86_vendor_id[8], | 244 | (int *)&c->x86_vendor_id[8], |
258 | (int *)&c->x86_vendor_id[4]); | 245 | (int *)&c->x86_vendor_id[4]); |
259 | 246 | ||
260 | get_cpu_vendor(c, 1); | ||
261 | |||
262 | c->x86 = 4; | 247 | c->x86 = 4; |
263 | if (c->cpuid_level >= 0x00000001) { | 248 | if (c->cpuid_level >= 0x00000001) { |
264 | u32 junk, tfms, cap0, misc; | 249 | u32 junk, tfms, cap0, misc; |
@@ -275,6 +260,26 @@ static void __init early_cpu_detect(void) | |||
275 | } | 260 | } |
276 | } | 261 | } |
277 | 262 | ||
263 | /* Do minimum CPU detection early. | ||
264 | Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment. | ||
265 | The others are not touched to avoid unwanted side effects. | ||
266 | |||
267 | WARNING: this function is only called on the BP. Don't add code here | ||
268 | that is supposed to run on all CPUs. */ | ||
269 | static void __init early_cpu_detect(void) | ||
270 | { | ||
271 | struct cpuinfo_x86 *c = &boot_cpu_data; | ||
272 | |||
273 | c->x86_cache_alignment = 32; | ||
274 | |||
275 | if (!have_cpuid_p()) | ||
276 | return; | ||
277 | |||
278 | cpu_detect(c); | ||
279 | |||
280 | get_cpu_vendor(c, 1); | ||
281 | } | ||
282 | |||
278 | static void __cpuinit generic_identify(struct cpuinfo_x86 * c) | 283 | static void __cpuinit generic_identify(struct cpuinfo_x86 * c) |
279 | { | 284 | { |
280 | u32 tfms, xlvl; | 285 | u32 tfms, xlvl; |
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h index 5f0418d0078c..a52d65440429 100644 --- a/include/asm-i386/processor.h +++ b/include/asm-i386/processor.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/threads.h> | 20 | #include <linux/threads.h> |
21 | #include <asm/percpu.h> | 21 | #include <asm/percpu.h> |
22 | #include <linux/cpumask.h> | 22 | #include <linux/cpumask.h> |
23 | #include <linux/init.h> | ||
23 | 24 | ||
24 | /* flag for disabling the tsc */ | 25 | /* flag for disabling the tsc */ |
25 | extern int tsc_disable; | 26 | extern int tsc_disable; |
@@ -112,6 +113,8 @@ extern struct cpuinfo_x86 cpu_data[]; | |||
112 | extern int cpu_llc_id[NR_CPUS]; | 113 | extern int cpu_llc_id[NR_CPUS]; |
113 | extern char ignore_fpu_irq; | 114 | extern char ignore_fpu_irq; |
114 | 115 | ||
116 | void __init cpu_detect(struct cpuinfo_x86 *c); | ||
117 | |||
115 | extern void identify_cpu(struct cpuinfo_x86 *); | 118 | extern void identify_cpu(struct cpuinfo_x86 *); |
116 | extern void print_cpu_info(struct cpuinfo_x86 *); | 119 | extern void print_cpu_info(struct cpuinfo_x86 *); |
117 | extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); | 120 | extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); |
diff --git a/include/linux/start_kernel.h b/include/linux/start_kernel.h new file mode 100644 index 000000000000..d3e5f2756545 --- /dev/null +++ b/include/linux/start_kernel.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _LINUX_START_KERNEL_H | ||
2 | #define _LINUX_START_KERNEL_H | ||
3 | |||
4 | #include <linux/linkage.h> | ||
5 | #include <linux/init.h> | ||
6 | |||
7 | /* Define the prototype for start_kernel here, rather than cluttering | ||
8 | up something else. */ | ||
9 | |||
10 | extern asmlinkage void __init start_kernel(void); | ||
11 | |||
12 | #endif /* _LINUX_START_KERNEL_H */ | ||
diff --git a/init/main.c b/init/main.c index 36f608a7cfba..985c9ed86050 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/percpu.h> | 29 | #include <linux/percpu.h> |
30 | #include <linux/kmod.h> | 30 | #include <linux/kmod.h> |
31 | #include <linux/kernel_stat.h> | 31 | #include <linux/kernel_stat.h> |
32 | #include <linux/start_kernel.h> | ||
32 | #include <linux/security.h> | 33 | #include <linux/security.h> |
33 | #include <linux/workqueue.h> | 34 | #include <linux/workqueue.h> |
34 | #include <linux/profile.h> | 35 | #include <linux/profile.h> |