aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/cpu/amd_64.c17
-rw-r--r--arch/x86/kernel/cpu/centaur_64.c16
-rw-r--r--arch/x86/kernel/cpu/cpu.h6
-rw-r--r--arch/x86/kernel/cpu/intel_64.c15
-rw-r--r--arch/x86/kernel/setup_64.c96
5 files changed, 95 insertions, 55 deletions
diff --git a/arch/x86/kernel/cpu/amd_64.c b/arch/x86/kernel/cpu/amd_64.c
index 250bfe6064af..30b7557c9641 100644
--- a/arch/x86/kernel/cpu/amd_64.c
+++ b/arch/x86/kernel/cpu/amd_64.c
@@ -7,8 +7,7 @@
7 7
8#include <mach_apic.h> 8#include <mach_apic.h>
9 9
10extern int __cpuinit get_model_name(struct cpuinfo_x86 *c); 10#include "cpu.h"
11extern void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c);
12 11
13int force_mwait __cpuinitdata; 12int force_mwait __cpuinitdata;
14 13
@@ -109,7 +108,7 @@ static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
109#endif 108#endif
110} 109}
111 110
112void __cpuinit early_init_amd(struct cpuinfo_x86 *c) 111static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
113{ 112{
114 early_init_amd_mc(c); 113 early_init_amd_mc(c);
115 114
@@ -118,7 +117,7 @@ void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
118 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 117 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
119} 118}
120 119
121void __cpuinit init_amd(struct cpuinfo_x86 *c) 120static void __cpuinit init_amd(struct cpuinfo_x86 *c)
122{ 121{
123 unsigned level; 122 unsigned level;
124 123
@@ -200,3 +199,13 @@ void __cpuinit init_amd(struct cpuinfo_x86 *c)
200 set_memory_4k((unsigned long)__va(tseg), 1); 199 set_memory_4k((unsigned long)__va(tseg), 1);
201 } 200 }
202} 201}
202
203static struct cpu_dev amd_cpu_dev __cpuinitdata = {
204 .c_vendor = "AMD",
205 .c_ident = { "AuthenticAMD" },
206 .c_early_init = early_init_amd,
207 .c_init = init_amd,
208};
209
210cpu_vendor_dev_register(X86_VENDOR_AMD, &amd_cpu_dev);
211
diff --git a/arch/x86/kernel/cpu/centaur_64.c b/arch/x86/kernel/cpu/centaur_64.c
index bac96d187d05..13526fd5cce1 100644
--- a/arch/x86/kernel/cpu/centaur_64.c
+++ b/arch/x86/kernel/cpu/centaur_64.c
@@ -4,13 +4,15 @@
4#include <asm/cpufeature.h> 4#include <asm/cpufeature.h>
5#include <asm/processor.h> 5#include <asm/processor.h>
6 6
7void __cpuinit early_init_centaur(struct cpuinfo_x86 *c) 7#include "cpu.h"
8
9static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
8{ 10{
9 if (c->x86 == 0x6 && c->x86_model >= 0xf) 11 if (c->x86 == 0x6 && c->x86_model >= 0xf)
10 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 12 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
11} 13}
12 14
13void __cpuinit init_centaur(struct cpuinfo_x86 *c) 15static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
14{ 16{
15 /* Cache sizes */ 17 /* Cache sizes */
16 unsigned n; 18 unsigned n;
@@ -29,3 +31,13 @@ void __cpuinit init_centaur(struct cpuinfo_x86 *c)
29 } 31 }
30 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC); 32 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
31} 33}
34
35static struct cpu_dev centaur_cpu_dev __cpuinitdata = {
36 .c_vendor = "Centaur",
37 .c_ident = { "CentaurHauls" },
38 .c_early_init = early_init_centaur,
39 .c_init = init_centaur,
40};
41
42cpu_vendor_dev_register(X86_VENDOR_CENTAUR, &centaur_cpu_dev);
43
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index 40ad1893fe87..4d894e8565fe 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -1,4 +1,6 @@
1#ifdef CONFIG_X86_32 1#ifndef ARCH_X86_CPU_H
2
3#define ARCH_X86_CPU_H
2 4
3struct cpu_model_info { 5struct cpu_model_info {
4 int vendor; 6 int vendor;
@@ -38,4 +40,4 @@ extern struct cpu_vendor_dev __x86cpuvendor_start[], __x86cpuvendor_end[];
38extern int get_model_name(struct cpuinfo_x86 *c); 40extern int get_model_name(struct cpuinfo_x86 *c);
39extern void display_cacheinfo(struct cpuinfo_x86 *c); 41extern void display_cacheinfo(struct cpuinfo_x86 *c);
40 42
41#endif /* CONFIG_X86_32 */ 43#endif
diff --git a/arch/x86/kernel/cpu/intel_64.c b/arch/x86/kernel/cpu/intel_64.c
index b33912199484..fcb1cc9d75ca 100644
--- a/arch/x86/kernel/cpu/intel_64.c
+++ b/arch/x86/kernel/cpu/intel_64.c
@@ -5,7 +5,9 @@
5#include <asm/topology.h> 5#include <asm/topology.h>
6#include <asm/numa_64.h> 6#include <asm/numa_64.h>
7 7
8void __cpuinit early_init_intel(struct cpuinfo_x86 *c) 8#include "cpu.h"
9
10static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
9{ 11{
10 if ((c->x86 == 0xf && c->x86_model >= 0x03) || 12 if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
11 (c->x86 == 0x6 && c->x86_model >= 0x0e)) 13 (c->x86 == 0x6 && c->x86_model >= 0x0e))
@@ -48,7 +50,7 @@ static void __cpuinit srat_detect_node(void)
48#endif 50#endif
49} 51}
50 52
51void __cpuinit init_intel(struct cpuinfo_x86 *c) 53static void __cpuinit init_intel(struct cpuinfo_x86 *c)
52{ 54{
53 /* Cache sizes */ 55 /* Cache sizes */
54 unsigned n; 56 unsigned n;
@@ -90,3 +92,12 @@ void __cpuinit init_intel(struct cpuinfo_x86 *c)
90 92
91 srat_detect_node(); 93 srat_detect_node();
92} 94}
95
96static struct cpu_dev intel_cpu_dev __cpuinitdata = {
97 .c_vendor = "Intel",
98 .c_ident = { "GenuineIntel" },
99 .c_early_init = early_init_intel,
100 .c_init = init_intel,
101};
102cpu_vendor_dev_register(X86_VENDOR_INTEL, &intel_cpu_dev);
103
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 25afdd80a3cf..0cebf953c25a 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -80,6 +80,8 @@
80#define ARCH_SETUP 80#define ARCH_SETUP
81#endif 81#endif
82 82
83#include "cpu/cpu.h"
84
83/* 85/*
84 * Machine setup.. 86 * Machine setup..
85 */ 87 */
@@ -163,6 +165,7 @@ static struct resource bss_resource = {
163 .flags = IORESOURCE_RAM, 165 .flags = IORESOURCE_RAM,
164}; 166};
165 167
168static void __init early_cpu_init(void);
166static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c); 169static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c);
167 170
168#ifdef CONFIG_PROC_VMCORE 171#ifdef CONFIG_PROC_VMCORE
@@ -339,6 +342,7 @@ void __init setup_arch(char **cmdline_p)
339 bss_resource.start = virt_to_phys(&__bss_start); 342 bss_resource.start = virt_to_phys(&__bss_start);
340 bss_resource.end = virt_to_phys(&__bss_stop)-1; 343 bss_resource.end = virt_to_phys(&__bss_stop)-1;
341 344
345 early_cpu_init();
342 early_identify_cpu(&boot_cpu_data); 346 early_identify_cpu(&boot_cpu_data);
343 347
344 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); 348 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
@@ -524,6 +528,19 @@ void __init setup_arch(char **cmdline_p)
524 check_enable_amd_mmconf_dmi(); 528 check_enable_amd_mmconf_dmi();
525} 529}
526 530
531struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
532
533static void __cpuinit default_init(struct cpuinfo_x86 *c)
534{
535 display_cacheinfo(c);
536}
537
538static struct cpu_dev __cpuinitdata default_cpu = {
539 .c_init = default_init,
540 .c_vendor = "Unknown",
541};
542static struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
543
527int __cpuinit get_model_name(struct cpuinfo_x86 *c) 544int __cpuinit get_model_name(struct cpuinfo_x86 *c)
528{ 545{
529 unsigned int *v; 546 unsigned int *v;
@@ -625,24 +642,37 @@ out:
625static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) 642static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
626{ 643{
627 char *v = c->x86_vendor_id; 644 char *v = c->x86_vendor_id;
628 645 int i;
629 if (!strcmp(v, "AuthenticAMD")) 646 static int printed;
630 c->x86_vendor = X86_VENDOR_AMD; 647
631 else if (!strcmp(v, "GenuineIntel")) 648 for (i = 0; i < X86_VENDOR_NUM; i++) {
632 c->x86_vendor = X86_VENDOR_INTEL; 649 if (cpu_devs[i]) {
633 else if (!strcmp(v, "CentaurHauls")) 650 if (!strcmp(v, cpu_devs[i]->c_ident[0]) ||
634 c->x86_vendor = X86_VENDOR_CENTAUR; 651 (cpu_devs[i]->c_ident[1] &&
635 else 652 !strcmp(v, cpu_devs[i]->c_ident[1]))) {
636 c->x86_vendor = X86_VENDOR_UNKNOWN; 653 c->x86_vendor = i;
654 this_cpu = cpu_devs[i];
655 return;
656 }
657 }
658 }
659 if (!printed) {
660 printed++;
661 printk(KERN_ERR "CPU: Vendor unknown, using generic init.\n");
662 printk(KERN_ERR "CPU: Your system may be unstable.\n");
663 }
664 c->x86_vendor = X86_VENDOR_UNKNOWN;
637} 665}
638 666
639// FIXME: Needs to use cpu_vendor_dev_register 667static void __init early_cpu_init(void)
640extern void __cpuinit early_init_amd(struct cpuinfo_x86 *c); 668{
641extern void __cpuinit init_amd(struct cpuinfo_x86 *c); 669 struct cpu_vendor_dev *cvdev;
642extern void __cpuinit early_init_intel(struct cpuinfo_x86 *c); 670
643extern void __cpuinit init_intel(struct cpuinfo_x86 *c); 671 for (cvdev = __x86cpuvendor_start ;
644extern void __cpuinit early_init_centaur(struct cpuinfo_x86 *c); 672 cvdev < __x86cpuvendor_end ;
645extern void __cpuinit init_centaur(struct cpuinfo_x86 *c); 673 cvdev++)
674 cpu_devs[cvdev->vendor] = cvdev->cpu_dev;
675}
646 676
647/* Do some early cpuid on the boot CPU to get some parameter that are 677/* Do some early cpuid on the boot CPU to get some parameter that are
648 needed before check_bugs. Everything advanced is in identify_cpu 678 needed before check_bugs. Everything advanced is in identify_cpu
@@ -722,17 +752,9 @@ static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
722 if (c->extended_cpuid_level >= 0x80000007) 752 if (c->extended_cpuid_level >= 0x80000007)
723 c->x86_power = cpuid_edx(0x80000007); 753 c->x86_power = cpuid_edx(0x80000007);
724 754
725 switch (c->x86_vendor) { 755 if (c->x86_vendor != X86_VENDOR_UNKNOWN &&
726 case X86_VENDOR_AMD: 756 cpu_devs[c->x86_vendor]->c_early_init)
727 early_init_amd(c); 757 cpu_devs[c->x86_vendor]->c_early_init(c);
728 break;
729 case X86_VENDOR_INTEL:
730 early_init_intel(c);
731 break;
732 case X86_VENDOR_CENTAUR:
733 early_init_centaur(c);
734 break;
735 }
736 758
737 validate_pat_support(c); 759 validate_pat_support(c);
738} 760}
@@ -760,24 +782,8 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
760 * At the end of this section, c->x86_capability better 782 * At the end of this section, c->x86_capability better
761 * indicate the features this CPU genuinely supports! 783 * indicate the features this CPU genuinely supports!
762 */ 784 */
763 switch (c->x86_vendor) { 785 if (this_cpu->c_init)
764 case X86_VENDOR_AMD: 786 this_cpu->c_init(c);
765 init_amd(c);
766 break;
767
768 case X86_VENDOR_INTEL:
769 init_intel(c);
770 break;
771
772 case X86_VENDOR_CENTAUR:
773 init_centaur(c);
774 break;
775
776 case X86_VENDOR_UNKNOWN:
777 default:
778 display_cacheinfo(c);
779 break;
780 }
781 787
782 detect_ht(c); 788 detect_ht(c);
783 789