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>
This commit is contained in:
@@ -7,8 +7,7 @@
|
|||||||
|
|
||||||
#include <mach_apic.h>
|
#include <mach_apic.h>
|
||||||
|
|
||||||
extern int __cpuinit get_model_name(struct cpuinfo_x86 *c);
|
#include "cpu.h"
|
||||||
extern void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c);
|
|
||||||
|
|
||||||
int force_mwait __cpuinitdata;
|
int force_mwait __cpuinitdata;
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@ static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
|
static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
early_init_amd_mc(c);
|
early_init_amd_mc(c);
|
||||||
|
|
||||||
@@ -118,7 +117,7 @@ void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
|
|||||||
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cpuinit init_amd(struct cpuinfo_x86 *c)
|
static void __cpuinit init_amd(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
unsigned level;
|
unsigned level;
|
||||||
|
|
||||||
@@ -200,3 +199,13 @@ void __cpuinit init_amd(struct cpuinfo_x86 *c)
|
|||||||
set_memory_4k((unsigned long)__va(tseg), 1);
|
set_memory_4k((unsigned long)__va(tseg), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct cpu_dev amd_cpu_dev __cpuinitdata = {
|
||||||
|
.c_vendor = "AMD",
|
||||||
|
.c_ident = { "AuthenticAMD" },
|
||||||
|
.c_early_init = early_init_amd,
|
||||||
|
.c_init = init_amd,
|
||||||
|
};
|
||||||
|
|
||||||
|
cpu_vendor_dev_register(X86_VENDOR_AMD, &amd_cpu_dev);
|
||||||
|
|
||||||
|
@@ -4,13 +4,15 @@
|
|||||||
#include <asm/cpufeature.h>
|
#include <asm/cpufeature.h>
|
||||||
#include <asm/processor.h>
|
#include <asm/processor.h>
|
||||||
|
|
||||||
void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
|
#include "cpu.h"
|
||||||
|
|
||||||
|
static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
if (c->x86 == 0x6 && c->x86_model >= 0xf)
|
if (c->x86 == 0x6 && c->x86_model >= 0xf)
|
||||||
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cpuinit init_centaur(struct cpuinfo_x86 *c)
|
static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
/* Cache sizes */
|
/* Cache sizes */
|
||||||
unsigned n;
|
unsigned n;
|
||||||
@@ -29,3 +31,13 @@ void __cpuinit init_centaur(struct cpuinfo_x86 *c)
|
|||||||
}
|
}
|
||||||
set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
|
set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct cpu_dev centaur_cpu_dev __cpuinitdata = {
|
||||||
|
.c_vendor = "Centaur",
|
||||||
|
.c_ident = { "CentaurHauls" },
|
||||||
|
.c_early_init = early_init_centaur,
|
||||||
|
.c_init = init_centaur,
|
||||||
|
};
|
||||||
|
|
||||||
|
cpu_vendor_dev_register(X86_VENDOR_CENTAUR, ¢aur_cpu_dev);
|
||||||
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
#ifdef CONFIG_X86_32
|
#ifndef ARCH_X86_CPU_H
|
||||||
|
|
||||||
|
#define ARCH_X86_CPU_H
|
||||||
|
|
||||||
struct cpu_model_info {
|
struct cpu_model_info {
|
||||||
int vendor;
|
int vendor;
|
||||||
@@ -38,4 +40,4 @@ extern struct cpu_vendor_dev __x86cpuvendor_start[], __x86cpuvendor_end[];
|
|||||||
extern int get_model_name(struct cpuinfo_x86 *c);
|
extern int get_model_name(struct cpuinfo_x86 *c);
|
||||||
extern void display_cacheinfo(struct cpuinfo_x86 *c);
|
extern void display_cacheinfo(struct cpuinfo_x86 *c);
|
||||||
|
|
||||||
#endif /* CONFIG_X86_32 */
|
#endif
|
||||||
|
@@ -5,7 +5,9 @@
|
|||||||
#include <asm/topology.h>
|
#include <asm/topology.h>
|
||||||
#include <asm/numa_64.h>
|
#include <asm/numa_64.h>
|
||||||
|
|
||||||
void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
|
#include "cpu.h"
|
||||||
|
|
||||||
|
static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
|
if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
|
||||||
(c->x86 == 0x6 && c->x86_model >= 0x0e))
|
(c->x86 == 0x6 && c->x86_model >= 0x0e))
|
||||||
@@ -48,7 +50,7 @@ static void __cpuinit srat_detect_node(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cpuinit init_intel(struct cpuinfo_x86 *c)
|
static void __cpuinit init_intel(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
/* Cache sizes */
|
/* Cache sizes */
|
||||||
unsigned n;
|
unsigned n;
|
||||||
@@ -90,3 +92,12 @@ void __cpuinit init_intel(struct cpuinfo_x86 *c)
|
|||||||
|
|
||||||
srat_detect_node();
|
srat_detect_node();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct cpu_dev intel_cpu_dev __cpuinitdata = {
|
||||||
|
.c_vendor = "Intel",
|
||||||
|
.c_ident = { "GenuineIntel" },
|
||||||
|
.c_early_init = early_init_intel,
|
||||||
|
.c_init = init_intel,
|
||||||
|
};
|
||||||
|
cpu_vendor_dev_register(X86_VENDOR_INTEL, &intel_cpu_dev);
|
||||||
|
|
||||||
|
@@ -80,6 +80,8 @@
|
|||||||
#define ARCH_SETUP
|
#define ARCH_SETUP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "cpu/cpu.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Machine setup..
|
* Machine setup..
|
||||||
*/
|
*/
|
||||||
@@ -163,6 +165,7 @@ static struct resource bss_resource = {
|
|||||||
.flags = IORESOURCE_RAM,
|
.flags = IORESOURCE_RAM,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void __init early_cpu_init(void);
|
||||||
static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c);
|
static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c);
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_VMCORE
|
#ifdef CONFIG_PROC_VMCORE
|
||||||
@@ -339,6 +342,7 @@ void __init setup_arch(char **cmdline_p)
|
|||||||
bss_resource.start = virt_to_phys(&__bss_start);
|
bss_resource.start = virt_to_phys(&__bss_start);
|
||||||
bss_resource.end = virt_to_phys(&__bss_stop)-1;
|
bss_resource.end = virt_to_phys(&__bss_stop)-1;
|
||||||
|
|
||||||
|
early_cpu_init();
|
||||||
early_identify_cpu(&boot_cpu_data);
|
early_identify_cpu(&boot_cpu_data);
|
||||||
|
|
||||||
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
|
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
|
||||||
@@ -524,6 +528,19 @@ void __init setup_arch(char **cmdline_p)
|
|||||||
check_enable_amd_mmconf_dmi();
|
check_enable_amd_mmconf_dmi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
|
||||||
|
|
||||||
|
static void __cpuinit default_init(struct cpuinfo_x86 *c)
|
||||||
|
{
|
||||||
|
display_cacheinfo(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cpu_dev __cpuinitdata default_cpu = {
|
||||||
|
.c_init = default_init,
|
||||||
|
.c_vendor = "Unknown",
|
||||||
|
};
|
||||||
|
static struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
|
||||||
|
|
||||||
int __cpuinit get_model_name(struct cpuinfo_x86 *c)
|
int __cpuinit get_model_name(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
unsigned int *v;
|
unsigned int *v;
|
||||||
@@ -625,24 +642,37 @@ out:
|
|||||||
static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
|
static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
|
||||||
{
|
{
|
||||||
char *v = c->x86_vendor_id;
|
char *v = c->x86_vendor_id;
|
||||||
|
int i;
|
||||||
|
static int printed;
|
||||||
|
|
||||||
if (!strcmp(v, "AuthenticAMD"))
|
for (i = 0; i < X86_VENDOR_NUM; i++) {
|
||||||
c->x86_vendor = X86_VENDOR_AMD;
|
if (cpu_devs[i]) {
|
||||||
else if (!strcmp(v, "GenuineIntel"))
|
if (!strcmp(v, cpu_devs[i]->c_ident[0]) ||
|
||||||
c->x86_vendor = X86_VENDOR_INTEL;
|
(cpu_devs[i]->c_ident[1] &&
|
||||||
else if (!strcmp(v, "CentaurHauls"))
|
!strcmp(v, cpu_devs[i]->c_ident[1]))) {
|
||||||
c->x86_vendor = X86_VENDOR_CENTAUR;
|
c->x86_vendor = i;
|
||||||
else
|
this_cpu = cpu_devs[i];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!printed) {
|
||||||
|
printed++;
|
||||||
|
printk(KERN_ERR "CPU: Vendor unknown, using generic init.\n");
|
||||||
|
printk(KERN_ERR "CPU: Your system may be unstable.\n");
|
||||||
|
}
|
||||||
c->x86_vendor = X86_VENDOR_UNKNOWN;
|
c->x86_vendor = X86_VENDOR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Needs to use cpu_vendor_dev_register
|
static void __init early_cpu_init(void)
|
||||||
extern void __cpuinit early_init_amd(struct cpuinfo_x86 *c);
|
{
|
||||||
extern void __cpuinit init_amd(struct cpuinfo_x86 *c);
|
struct cpu_vendor_dev *cvdev;
|
||||||
extern void __cpuinit early_init_intel(struct cpuinfo_x86 *c);
|
|
||||||
extern void __cpuinit init_intel(struct cpuinfo_x86 *c);
|
for (cvdev = __x86cpuvendor_start ;
|
||||||
extern void __cpuinit early_init_centaur(struct cpuinfo_x86 *c);
|
cvdev < __x86cpuvendor_end ;
|
||||||
extern void __cpuinit init_centaur(struct cpuinfo_x86 *c);
|
cvdev++)
|
||||||
|
cpu_devs[cvdev->vendor] = cvdev->cpu_dev;
|
||||||
|
}
|
||||||
|
|
||||||
/* Do some early cpuid on the boot CPU to get some parameter that are
|
/* Do some early cpuid on the boot CPU to get some parameter that are
|
||||||
needed before check_bugs. Everything advanced is in identify_cpu
|
needed before check_bugs. Everything advanced is in identify_cpu
|
||||||
@@ -722,17 +752,9 @@ static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
|
|||||||
if (c->extended_cpuid_level >= 0x80000007)
|
if (c->extended_cpuid_level >= 0x80000007)
|
||||||
c->x86_power = cpuid_edx(0x80000007);
|
c->x86_power = cpuid_edx(0x80000007);
|
||||||
|
|
||||||
switch (c->x86_vendor) {
|
if (c->x86_vendor != X86_VENDOR_UNKNOWN &&
|
||||||
case X86_VENDOR_AMD:
|
cpu_devs[c->x86_vendor]->c_early_init)
|
||||||
early_init_amd(c);
|
cpu_devs[c->x86_vendor]->c_early_init(c);
|
||||||
break;
|
|
||||||
case X86_VENDOR_INTEL:
|
|
||||||
early_init_intel(c);
|
|
||||||
break;
|
|
||||||
case X86_VENDOR_CENTAUR:
|
|
||||||
early_init_centaur(c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_pat_support(c);
|
validate_pat_support(c);
|
||||||
}
|
}
|
||||||
@@ -760,24 +782,8 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
|
|||||||
* At the end of this section, c->x86_capability better
|
* At the end of this section, c->x86_capability better
|
||||||
* indicate the features this CPU genuinely supports!
|
* indicate the features this CPU genuinely supports!
|
||||||
*/
|
*/
|
||||||
switch (c->x86_vendor) {
|
if (this_cpu->c_init)
|
||||||
case X86_VENDOR_AMD:
|
this_cpu->c_init(c);
|
||||||
init_amd(c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case X86_VENDOR_INTEL:
|
|
||||||
init_intel(c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case X86_VENDOR_CENTAUR:
|
|
||||||
init_centaur(c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case X86_VENDOR_UNKNOWN:
|
|
||||||
default:
|
|
||||||
display_cacheinfo(c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
detect_ht(c);
|
detect_ht(c);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user