summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2003-01-09 19:54:49 +0000
committerjhb <jhb@FreeBSD.org>2003-01-09 19:54:49 +0000
commit6117002b61e9cf3e6b8c795f462d4ed00ea369a1 (patch)
treeb6755bdd2a99b2a0667f49e6b75c0a99d0917da4 /sys/i386
parent5635a285bade3330f0cbf5635e246acf0cbcd923 (diff)
downloadFreeBSD-src-6117002b61e9cf3e6b8c795f462d4ed00ea369a1.zip
FreeBSD-src-6117002b61e9cf3e6b8c795f462d4ed00ea369a1.tar.gz
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)
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/identcpu.c30
-rw-r--r--sys/i386/i386/initcpu.c2
-rw-r--r--sys/i386/i386/locore.s24
-rw-r--r--sys/i386/include/md_var.h1
4 files changed, 28 insertions, 29 deletions
diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c
index 712a97c..4880c74 100644
--- a/sys/i386/i386/identcpu.c
+++ b/sys/i386/i386/identcpu.c
@@ -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;
diff --git a/sys/i386/i386/initcpu.c b/sys/i386/i386/initcpu.c
index 581fd63..9f13eb6 100644
--- a/sys/i386/i386/initcpu.c
+++ b/sys/i386/i386/initcpu.c
@@ -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
/*
diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s
index 58c008b..b9efaf6 100644
--- a/sys/i386/i386/locore.s
+++ b/sys/i386/i386/locore.s
@@ -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
diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h
index 1d0a03d..107c90e 100644
--- a/sys/i386/include/md_var.h
+++ b/sys/i386/include/md_var.h
@@ -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[];
OpenPOWER on IntegriCloud