summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2003-01-08 16:41:48 +0000
committerjhb <jhb@FreeBSD.org>2003-01-08 16:41:48 +0000
commitafa86be815a3f13b2608d36e73194d7320f9d365 (patch)
tree15a9a83778707b9559148a2df525172323317494 /sys/i386
parent6873375d06f281732e2bd5e1a509b1bd8edec189 (diff)
downloadFreeBSD-src-afa86be815a3f13b2608d36e73194d7320f9d365.zip
FreeBSD-src-afa86be815a3f13b2608d36e73194d7320f9d365.tar.gz
- Use cpu_exthigh instead of executing cpuid again to retrieve it for the
print_AMD_foo() functions. - Add a brand name table for the brand index provided on Intel CPU's in %ebx after cpuid 1. - For Intel CPUs, if we don't get a processor name from the extended cpuid then use the brand index in cpuid_cpuinfo to pick a name from the brand table and copy that name into cpu_brand. - Replace the duplicated code to use the extended cpuid to replace cpu_model with the processor name in the AMD and Transmeta sections of printcpuinfo() with generic code that replaces cpu_model with cpu_brand if cpu_brand is not an empty string. We also trim leading spaces from cpu_brand prior to doing this since at least some processor names (notably those of Intel CPUs) have leading spaces in the name. - Give print_AMD_features() its own private regs[] array since printcpuinfo() doesn't use the one it has anymore.
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/identcpu.c87
1 files changed, 51 insertions, 36 deletions
diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c
index 97d30e2..2d07a62 100644
--- a/sys/i386/i386/identcpu.c
+++ b/sys/i386/i386/identcpu.c
@@ -77,9 +77,9 @@ void panicifcpuunsupported(void);
static void identifycyrix(void);
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
-static void print_AMD_features(u_int *regs);
+static void print_AMD_features(void);
#endif
-static void print_AMD_info(u_int amd_maxregs);
+static void print_AMD_info(void);
static void print_AMD_assoc(int i);
static void print_transmeta_info(void);
static void setup_tmx86_longrun(void);
@@ -94,6 +94,20 @@ static char cpu_model[128];
SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
cpu_model, 0, "Machine model");
+#define MAX_BRAND_INDEX 8
+
+static const char *cpu_brandtable[MAX_BRAND_INDEX + 1] = {
+ NULL, /* No brand */
+ "Intel Celeron",
+ "Intel Pentium III",
+ "Intel Pentium III Xeon",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "Intel Pentium 4"
+};
+
static struct cpu_nameclass i386_cpus[] = {
{ "Intel 80286", CPUCLASS_286 }, /* CPU_286 */
{ "i386SX", CPUCLASS_386 }, /* CPU_386SX */
@@ -121,10 +135,8 @@ 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];
-#endif
- u_int nreg = 0;
+ char *brand;
+
cpu_class = i386_cpus[cpu].cpu_class;
printf("CPU: ");
strncpy(cpu_model, i386_cpus[cpu].cpu_name, sizeof cpu_model);
@@ -132,6 +144,8 @@ printcpuinfo(void)
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
if (strcmp(cpu_vendor,"GenuineIntel") == 0) {
if ((cpu_id & 0xf00) > 0x300) {
+ u_int brand_index;
+
cpu_model[0] = '\0';
switch (cpu_id & 0x3000) {
@@ -249,6 +263,17 @@ printcpuinfo(void)
break;
}
+ /*
+ * If we didn't get a brand name from the extended
+ * CPUID, try to look it up in the brand table.
+ */
+ if (cpu_high > 0 && *cpu_brand == '\0') {
+ brand_index = cpuid_cpuinfo & CPUID_BRAND_INDEX;
+ if (brand_index <= MAX_BRAND_INDEX &&
+ cpu_brandtable[brand_index] != NULL)
+ strcpy(cpu_brand,
+ cpu_brandtable[brand_index]);
+ }
}
} else if (strcmp(cpu_vendor,"AuthenticAMD") == 0) {
/*
@@ -322,16 +347,6 @@ printcpuinfo(void)
enable_K6_wt_alloc();
}
#endif
- do_cpuid(0x80000000, regs);
- nreg = regs[0];
- if (nreg >= 0x80000004) {
- do_cpuid(0x80000002, regs);
- memcpy(cpu_model, regs, sizeof regs);
- do_cpuid(0x80000003, regs);
- memcpy(cpu_model+16, regs, sizeof regs);
- do_cpuid(0x80000004, regs);
- memcpy(cpu_model+32, regs, sizeof regs);
- }
} else if (strcmp(cpu_vendor,"CyrixInstead") == 0) {
strcpy(cpu_model, "Cyrix ");
switch (cpu_id & 0xff0) {
@@ -493,20 +508,18 @@ printcpuinfo(void)
}
} else if (strcmp(cpu_vendor, "IBM") == 0) {
strcpy(cpu_model, "Blue Lightning CPU");
- } else if (strcmp(cpu_vendor, "GenuineTMx86") == 0 ||
- strcmp(cpu_vendor, "TransmetaCPU") == 0) {
- do_cpuid(0x80000000, regs);
- nreg = regs[0];
- if (nreg >= 0x80000004) {
- do_cpuid(0x80000002, regs);
- memcpy(cpu_model, regs, sizeof regs);
- do_cpuid(0x80000003, regs);
- memcpy(cpu_model+16, regs, sizeof regs);
- do_cpuid(0x80000004, regs);
- memcpy(cpu_model+32, regs, sizeof regs);
- }
- cpu_model[64] = '\0';
}
+
+ /*
+ * Replace cpu_model with cpu_brand minus leading spaces if
+ * we have one.
+ */
+ brand = cpu_brand;
+ while (*brand == ' ')
+ ++brand;
+ if (*brand != '\0')
+ strcpy(cpu_model, brand);
+
#endif
printf("%s (", cpu_model);
@@ -615,8 +628,8 @@ printcpuinfo(void)
(cpuid_cpuinfo & CPUID_HTT_CORES) >> 16);
}
if (strcmp(cpu_vendor, "AuthenticAMD") == 0 &&
- nreg >= 0x80000001)
- print_AMD_features(regs);
+ cpu_exthigh >= 0x80000001)
+ print_AMD_features();
} else if (strcmp(cpu_vendor, "CyrixInstead") == 0) {
printf(" DIR=0x%04x", cyrix_did);
printf(" Stepping=%u", (cyrix_did & 0xf000) >> 12);
@@ -640,7 +653,7 @@ printcpuinfo(void)
return;
if (strcmp(cpu_vendor, "AuthenticAMD") == 0)
- print_AMD_info(nreg);
+ print_AMD_info();
else if (strcmp(cpu_vendor, "GenuineTMx86") == 0 ||
strcmp(cpu_vendor, "TransmetaCPU") == 0)
print_transmeta_info();
@@ -937,11 +950,11 @@ print_AMD_assoc(int i)
}
static void
-print_AMD_info(u_int amd_maxregs)
+print_AMD_info(void)
{
quad_t amd_whcr;
- if (amd_maxregs >= 0x80000005) {
+ if (cpu_exthigh >= 0x80000005) {
u_int regs[4];
do_cpuid(0x80000005, regs);
@@ -957,7 +970,7 @@ print_AMD_info(u_int amd_maxregs)
printf(", %d bytes/line", regs[3] & 0xff);
printf(", %d lines/tag", (regs[3] >> 8) & 0xff);
print_AMD_assoc((regs[3] >> 16) & 0xff);
- if (amd_maxregs >= 0x80000006) { /* K6-III only */
+ if (cpu_exthigh >= 0x80000006) { /* K6-III only */
do_cpuid(0x80000006, regs);
printf("L2 internal cache: %d kbytes", regs[2] >> 16);
printf(", %d bytes/line", regs[2] & 0xff);
@@ -998,8 +1011,10 @@ print_AMD_info(u_int amd_maxregs)
#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
static void
-print_AMD_features(u_int *regs)
+print_AMD_features(void)
{
+ u_int regs[4];
+
/*
* Values taken from AMD Processor Recognition
* http://www.amd.com/products/cpg/athlon/techdocs/pdf/20734.pdf
OpenPOWER on IntegriCloud