Rework part of the previous processor name changes so that we read
cpu_exthigh and cpu_brand in printcpuinfo() instead of in identify_cpu(). We also only do it for known-good values of cpu_vendor which is a bit more conservative. Reviewed by: bde (mostly)
This commit is contained in:
parent
deb8c6ddce
commit
f85b149dae
@ -84,8 +84,9 @@ static void print_AMD_assoc(int i);
|
||||
static void print_transmeta_info(void);
|
||||
static void setup_tmx86_longrun(void);
|
||||
|
||||
int cpu_class;
|
||||
u_int cpu_exthigh; /* Highest arg to extended CPUID */
|
||||
u_int cyrix_did; /* Device ID of Cyrix CPU */
|
||||
int cpu_class = CPUCLASS_386; /* least common denominator */
|
||||
char machine[] = "i386";
|
||||
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
|
||||
machine, 0, "Machine class");
|
||||
@ -94,6 +95,8 @@ static char cpu_model[128];
|
||||
SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
|
||||
cpu_model, 0, "Machine model");
|
||||
|
||||
static char cpu_brand[48];
|
||||
|
||||
#define MAX_BRAND_INDEX 8
|
||||
|
||||
static const char *cpu_brandtable[MAX_BRAND_INDEX + 1] = {
|
||||
@ -135,13 +138,36 @@ int has_f00f_bug = 0; /* Initialized so that it can be patched. */
|
||||
void
|
||||
printcpuinfo(void)
|
||||
{
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
u_int regs[4], i;
|
||||
#endif
|
||||
char *brand;
|
||||
|
||||
cpu_class = i386_cpus[cpu].cpu_class;
|
||||
printf("CPU: ");
|
||||
strncpy(cpu_model, i386_cpus[cpu].cpu_name, sizeof cpu_model);
|
||||
strncpy(cpu_model, i386_cpus[cpu].cpu_name, sizeof (cpu_model));
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
/* Check for extended CPUID information and a processor name. */
|
||||
if (cpu_high > 0 &&
|
||||
(strcmp(cpu_vendor, "GenuineIntel") == 0 ||
|
||||
strcmp(cpu_vendor, "AuthenticAMD") == 0 ||
|
||||
strcmp(cpu_vendor, "GenuineTMx86") == 0 ||
|
||||
strcmp(cpu_vendor, "TransmetaCPU") == 0)) {
|
||||
do_cpuid(0x80000000, regs);
|
||||
if (regs[0] >= 0x80000000) {
|
||||
cpu_exthigh = regs[0];
|
||||
if (cpu_exthigh >= 0x80000004) {
|
||||
brand = cpu_brand;
|
||||
for (i = 0x80000002; i < 0x80000005; i++) {
|
||||
do_cpuid(i, regs);
|
||||
memcpy(brand, regs, sizeof(regs));
|
||||
brand += sizeof(regs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(cpu_vendor, "GenuineIntel") == 0) {
|
||||
if ((cpu_id & 0xf00) > 0x300) {
|
||||
u_int brand_index;
|
||||
|
@ -83,12 +83,10 @@ u_int cpu_id = 0; /* Stepping ID */
|
||||
u_int cpu_feature = 0; /* Feature flags */
|
||||
u_int cpu_high = 0; /* Highest arg to CPUID */
|
||||
u_int cpuid_cpuinfo = 0; /* HyperThreading Info / Brand Index / CLFUSH */
|
||||
u_int cpu_exthigh = 0; /* Highest arg to extended CPUID */
|
||||
#ifdef CPU_ENABLE_SSE
|
||||
u_int cpu_fxsr = 0; /* SSE enabled */
|
||||
#endif
|
||||
char cpu_vendor[20] = ""; /* CPU Origin code */
|
||||
char cpu_brand[48] = ""; /* Brand name */
|
||||
|
||||
#ifdef I486_CPU
|
||||
/*
|
||||
|
@ -740,30 +740,6 @@ trycpuid: /* Use the `cpuid' instruction. */
|
||||
/* Greater than Pentium...call it a Pentium Pro */
|
||||
movl $CPU_686,R(cpu)
|
||||
3:
|
||||
/* Try to read extended CPUID information. */
|
||||
movl $0x80000000,%eax # cpuid 80000000
|
||||
cpuid
|
||||
cmpl $0x80000000,%eax # is it a valid value?
|
||||
jb 5f
|
||||
movl %eax,R(cpu_exthigh) # highest extended capability
|
||||
cmpl $0x80000004,%eax # does it have a brand name?
|
||||
jb 5f
|
||||
|
||||
/* Read the brand name. */
|
||||
leal R(cpu_brand),%edi
|
||||
movl $0x80000002,%esi
|
||||
4:
|
||||
movl %esi,%eax
|
||||
cpuid
|
||||
movl %eax,(%edi) # Store next 16 characters
|
||||
movl %ebx,4(%edi) # of brand name
|
||||
movl %ecx,8(%edi)
|
||||
movl %edx,12(%edi)
|
||||
incl %esi # Advance to next set of 16
|
||||
addl $16,%edi
|
||||
cmpl $0x80000004,%esi
|
||||
jbe 4b
|
||||
5:
|
||||
ret
|
||||
|
||||
|
||||
|
@ -740,30 +740,6 @@ trycpuid: /* Use the `cpuid' instruction. */
|
||||
/* Greater than Pentium...call it a Pentium Pro */
|
||||
movl $CPU_686,R(cpu)
|
||||
3:
|
||||
/* Try to read extended CPUID information. */
|
||||
movl $0x80000000,%eax # cpuid 80000000
|
||||
cpuid
|
||||
cmpl $0x80000000,%eax # is it a valid value?
|
||||
jb 5f
|
||||
movl %eax,R(cpu_exthigh) # highest extended capability
|
||||
cmpl $0x80000004,%eax # does it have a brand name?
|
||||
jb 5f
|
||||
|
||||
/* Read the brand name. */
|
||||
leal R(cpu_brand),%edi
|
||||
movl $0x80000002,%esi
|
||||
4:
|
||||
movl %esi,%eax
|
||||
cpuid
|
||||
movl %eax,(%edi) # Store next 16 characters
|
||||
movl %ebx,4(%edi) # of brand name
|
||||
movl %ecx,8(%edi)
|
||||
movl %edx,12(%edi)
|
||||
incl %esi # Advance to next set of 16
|
||||
addl $16,%edi
|
||||
cmpl $0x80000004,%esi
|
||||
jbe 4b
|
||||
5:
|
||||
ret
|
||||
|
||||
|
||||
|
@ -49,7 +49,6 @@ extern u_int cpuid_cpuinfo;
|
||||
extern u_int cpu_id;
|
||||
extern u_int cpu_fxsr;
|
||||
extern char cpu_vendor[];
|
||||
extern char cpu_brand[];
|
||||
extern u_int cyrix_did;
|
||||
extern uint16_t *elan_mmcr;
|
||||
extern char kstack[];
|
||||
|
@ -84,8 +84,9 @@ static void print_AMD_assoc(int i);
|
||||
static void print_transmeta_info(void);
|
||||
static void setup_tmx86_longrun(void);
|
||||
|
||||
int cpu_class;
|
||||
u_int cpu_exthigh; /* Highest arg to extended CPUID */
|
||||
u_int cyrix_did; /* Device ID of Cyrix CPU */
|
||||
int cpu_class = CPUCLASS_386; /* least common denominator */
|
||||
char machine[] = "i386";
|
||||
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
|
||||
machine, 0, "Machine class");
|
||||
@ -94,6 +95,8 @@ static char cpu_model[128];
|
||||
SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
|
||||
cpu_model, 0, "Machine model");
|
||||
|
||||
static char cpu_brand[48];
|
||||
|
||||
#define MAX_BRAND_INDEX 8
|
||||
|
||||
static const char *cpu_brandtable[MAX_BRAND_INDEX + 1] = {
|
||||
@ -135,13 +138,36 @@ int has_f00f_bug = 0; /* Initialized so that it can be patched. */
|
||||
void
|
||||
printcpuinfo(void)
|
||||
{
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
u_int regs[4], i;
|
||||
#endif
|
||||
char *brand;
|
||||
|
||||
cpu_class = i386_cpus[cpu].cpu_class;
|
||||
printf("CPU: ");
|
||||
strncpy(cpu_model, i386_cpus[cpu].cpu_name, sizeof cpu_model);
|
||||
strncpy(cpu_model, i386_cpus[cpu].cpu_name, sizeof (cpu_model));
|
||||
|
||||
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
|
||||
/* Check for extended CPUID information and a processor name. */
|
||||
if (cpu_high > 0 &&
|
||||
(strcmp(cpu_vendor, "GenuineIntel") == 0 ||
|
||||
strcmp(cpu_vendor, "AuthenticAMD") == 0 ||
|
||||
strcmp(cpu_vendor, "GenuineTMx86") == 0 ||
|
||||
strcmp(cpu_vendor, "TransmetaCPU") == 0)) {
|
||||
do_cpuid(0x80000000, regs);
|
||||
if (regs[0] >= 0x80000000) {
|
||||
cpu_exthigh = regs[0];
|
||||
if (cpu_exthigh >= 0x80000004) {
|
||||
brand = cpu_brand;
|
||||
for (i = 0x80000002; i < 0x80000005; i++) {
|
||||
do_cpuid(i, regs);
|
||||
memcpy(brand, regs, sizeof(regs));
|
||||
brand += sizeof(regs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(cpu_vendor, "GenuineIntel") == 0) {
|
||||
if ((cpu_id & 0xf00) > 0x300) {
|
||||
u_int brand_index;
|
||||
|
@ -83,12 +83,10 @@ u_int cpu_id = 0; /* Stepping ID */
|
||||
u_int cpu_feature = 0; /* Feature flags */
|
||||
u_int cpu_high = 0; /* Highest arg to CPUID */
|
||||
u_int cpuid_cpuinfo = 0; /* HyperThreading Info / Brand Index / CLFUSH */
|
||||
u_int cpu_exthigh = 0; /* Highest arg to extended CPUID */
|
||||
#ifdef CPU_ENABLE_SSE
|
||||
u_int cpu_fxsr = 0; /* SSE enabled */
|
||||
#endif
|
||||
char cpu_vendor[20] = ""; /* CPU Origin code */
|
||||
char cpu_brand[48] = ""; /* Brand name */
|
||||
|
||||
#ifdef I486_CPU
|
||||
/*
|
||||
|
@ -740,30 +740,6 @@ trycpuid: /* Use the `cpuid' instruction. */
|
||||
/* Greater than Pentium...call it a Pentium Pro */
|
||||
movl $CPU_686,R(cpu)
|
||||
3:
|
||||
/* Try to read extended CPUID information. */
|
||||
movl $0x80000000,%eax # cpuid 80000000
|
||||
cpuid
|
||||
cmpl $0x80000000,%eax # is it a valid value?
|
||||
jb 5f
|
||||
movl %eax,R(cpu_exthigh) # highest extended capability
|
||||
cmpl $0x80000004,%eax # does it have a brand name?
|
||||
jb 5f
|
||||
|
||||
/* Read the brand name. */
|
||||
leal R(cpu_brand),%edi
|
||||
movl $0x80000002,%esi
|
||||
4:
|
||||
movl %esi,%eax
|
||||
cpuid
|
||||
movl %eax,(%edi) # Store next 16 characters
|
||||
movl %ebx,4(%edi) # of brand name
|
||||
movl %ecx,8(%edi)
|
||||
movl %edx,12(%edi)
|
||||
incl %esi # Advance to next set of 16
|
||||
addl $16,%edi
|
||||
cmpl $0x80000004,%esi
|
||||
jbe 4b
|
||||
5:
|
||||
ret
|
||||
|
||||
|
||||
|
@ -49,7 +49,6 @@ extern u_int cpuid_cpuinfo;
|
||||
extern u_int cpu_id;
|
||||
extern u_int cpu_fxsr;
|
||||
extern char cpu_vendor[];
|
||||
extern char cpu_brand[];
|
||||
extern u_int cyrix_did;
|
||||
extern uint16_t *elan_mmcr;
|
||||
extern char kstack[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user