|
80 | 80 | #define ARCH_SETUP |
81 | 81 | #endif |
82 | 82 |
|
| 83 | +#include "cpu/cpu.h" |
| 84 | + |
83 | 85 | /* |
84 | 86 | * Machine setup.. |
85 | 87 | */ |
@@ -163,6 +165,7 @@ static struct resource bss_resource = { |
163 | 165 | .flags = IORESOURCE_RAM, |
164 | 166 | }; |
165 | 167 |
|
| 168 | +static void __init early_cpu_init(void); |
166 | 169 | static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c); |
167 | 170 |
|
168 | 171 | #ifdef CONFIG_PROC_VMCORE |
@@ -339,6 +342,7 @@ void __init setup_arch(char **cmdline_p) |
339 | 342 | bss_resource.start = virt_to_phys(&__bss_start); |
340 | 343 | bss_resource.end = virt_to_phys(&__bss_stop)-1; |
341 | 344 |
|
| 345 | + early_cpu_init(); |
342 | 346 | early_identify_cpu(&boot_cpu_data); |
343 | 347 |
|
344 | 348 | strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); |
@@ -524,6 +528,19 @@ void __init setup_arch(char **cmdline_p) |
524 | 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 | 544 | int __cpuinit get_model_name(struct cpuinfo_x86 *c) |
528 | 545 | { |
529 | 546 | unsigned int *v; |
@@ -625,24 +642,37 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) |
625 | 642 | static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) |
626 | 643 | { |
627 | 644 | char *v = c->x86_vendor_id; |
628 | | - |
629 | | - if (!strcmp(v, "AuthenticAMD")) |
630 | | - c->x86_vendor = X86_VENDOR_AMD; |
631 | | - else if (!strcmp(v, "GenuineIntel")) |
632 | | - c->x86_vendor = X86_VENDOR_INTEL; |
633 | | - else if (!strcmp(v, "CentaurHauls")) |
634 | | - c->x86_vendor = X86_VENDOR_CENTAUR; |
635 | | - else |
636 | | - c->x86_vendor = X86_VENDOR_UNKNOWN; |
| 645 | + int i; |
| 646 | + static int printed; |
| 647 | + |
| 648 | + for (i = 0; i < X86_VENDOR_NUM; i++) { |
| 649 | + if (cpu_devs[i]) { |
| 650 | + if (!strcmp(v, cpu_devs[i]->c_ident[0]) || |
| 651 | + (cpu_devs[i]->c_ident[1] && |
| 652 | + !strcmp(v, cpu_devs[i]->c_ident[1]))) { |
| 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 |
640 | | -extern void __cpuinit early_init_amd(struct cpuinfo_x86 *c); |
641 | | -extern void __cpuinit init_amd(struct cpuinfo_x86 *c); |
642 | | -extern void __cpuinit early_init_intel(struct cpuinfo_x86 *c); |
643 | | -extern void __cpuinit init_intel(struct cpuinfo_x86 *c); |
644 | | -extern void __cpuinit early_init_centaur(struct cpuinfo_x86 *c); |
645 | | -extern void __cpuinit init_centaur(struct cpuinfo_x86 *c); |
| 667 | +static void __init early_cpu_init(void) |
| 668 | +{ |
| 669 | + struct cpu_vendor_dev *cvdev; |
| 670 | + |
| 671 | + for (cvdev = __x86cpuvendor_start ; |
| 672 | + cvdev < __x86cpuvendor_end ; |
| 673 | + cvdev++) |
| 674 | + cpu_devs[cvdev->vendor] = cvdev->cpu_dev; |
| 675 | +} |
646 | 676 |
|
647 | 677 | /* Do some early cpuid on the boot CPU to get some parameter that are |
648 | 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 | 752 | if (c->extended_cpuid_level >= 0x80000007) |
723 | 753 | c->x86_power = cpuid_edx(0x80000007); |
724 | 754 |
|
725 | | - switch (c->x86_vendor) { |
726 | | - case X86_VENDOR_AMD: |
727 | | - early_init_amd(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 | | - } |
| 755 | + if (c->x86_vendor != X86_VENDOR_UNKNOWN && |
| 756 | + cpu_devs[c->x86_vendor]->c_early_init) |
| 757 | + cpu_devs[c->x86_vendor]->c_early_init(c); |
736 | 758 |
|
737 | 759 | validate_pat_support(c); |
738 | 760 | } |
@@ -760,24 +782,8 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c) |
760 | 782 | * At the end of this section, c->x86_capability better |
761 | 783 | * indicate the features this CPU genuinely supports! |
762 | 784 | */ |
763 | | - switch (c->x86_vendor) { |
764 | | - case X86_VENDOR_AMD: |
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 | | - } |
| 785 | + if (this_cpu->c_init) |
| 786 | + this_cpu->c_init(c); |
781 | 787 |
|
782 | 788 | detect_ht(c); |
783 | 789 |
|
|
0 commit comments