diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-06-20 02:18:09 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-08 01:47:39 -0400 |
commit | dcd32b6a1ffe6c040f8346f7fbaf4318bb8ae41c (patch) | |
tree | 51b06c0bf8bc80dd2a6f9155a4a295f5b0ccdccb /arch/x86/kernel/setup_64.c | |
parent | 3a27dd1ce5de08e21e0266ddf00e6f1f843bfe8b (diff) |
x86: make 64-bit identify_cpu use cpu_dev
we may need to move some functions to common.c later
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/setup_64.c')
-rw-r--r-- | arch/x86/kernel/setup_64.c | 96 |
1 files changed, 51 insertions, 45 deletions
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 | ||
168 | static void __init early_cpu_init(void); | ||
166 | static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c); | 169 | static 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 | ||
531 | struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {}; | ||
532 | |||
533 | static void __cpuinit default_init(struct cpuinfo_x86 *c) | ||
534 | { | ||
535 | display_cacheinfo(c); | ||
536 | } | ||
537 | |||
538 | static struct cpu_dev __cpuinitdata default_cpu = { | ||
539 | .c_init = default_init, | ||
540 | .c_vendor = "Unknown", | ||
541 | }; | ||
542 | static struct cpu_dev *this_cpu __cpuinitdata = &default_cpu; | ||
543 | |||
527 | int __cpuinit get_model_name(struct cpuinfo_x86 *c) | 544 | int __cpuinit get_model_name(struct cpuinfo_x86 *c) |
528 | { | 545 | { |
529 | unsigned int *v; | 546 | unsigned int *v; |
@@ -625,24 +642,37 @@ out: | |||
625 | static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) | 642 | static 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 | 667 | static void __init early_cpu_init(void) |
640 | extern void __cpuinit early_init_amd(struct cpuinfo_x86 *c); | 668 | { |
641 | extern void __cpuinit init_amd(struct cpuinfo_x86 *c); | 669 | struct cpu_vendor_dev *cvdev; |
642 | extern void __cpuinit early_init_intel(struct cpuinfo_x86 *c); | 670 | |
643 | extern void __cpuinit init_intel(struct cpuinfo_x86 *c); | 671 | for (cvdev = __x86cpuvendor_start ; |
644 | extern void __cpuinit early_init_centaur(struct cpuinfo_x86 *c); | 672 | cvdev < __x86cpuvendor_end ; |
645 | extern 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 | ||