summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-11-15 19:27:51 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-11-15 19:27:51 +0000
commita776d248d9d62c644b7452e865d96e865515e179 (patch)
tree32da7a607d4233e9c2e5cc7fe714154ec333b6cb /sys
parent1a547c336ab1c5f970f92e58a7c0b16c724a7630 (diff)
diff from andreas@:
use the cpuid instruction for processor identification where available. tested by grange@, tedu@ and me
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/locore.s30
-rw-r--r--sys/arch/i386/i386/machdep.c38
2 files changed, 59 insertions, 9 deletions
diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s
index 08d323c3a96..6a650c6d633 100644
--- a/sys/arch/i386/i386/locore.s
+++ b/sys/arch/i386/i386/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.73 2003/07/29 18:24:36 mickey Exp $ */
+/* $OpenBSD: locore.s,v 1.74 2003/11/15 19:27:50 henning Exp $ */
/* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */
/*-
@@ -138,6 +138,7 @@
.data
.globl _C_LABEL(cpu), _C_LABEL(cpu_id), _C_LABEL(cpu_vendor)
+ .globl _C_LABEL(cpu_brandstr)
.globl _C_LABEL(cpuid_level)
.globl _C_LABEL(cpu_feature), _C_LABEL(cpu_ecxfeature)
.globl _C_LABEL(cpu_cache_eax), _C_LABEL(cpu_cache_ebx)
@@ -158,6 +159,7 @@ _C_LABEL(cpu_cache_ebx):.long 0
_C_LABEL(cpu_cache_ecx):.long 0
_C_LABEL(cpu_cache_edx):.long 0
_C_LABEL(cpu_vendor): .space 16 # vendor string returned by 'cpuid' instruction
+_C_LABEL(cpu_brandstr): .space 48 # brand string returned by 'cpuid'
_C_LABEL(cold): .long 1 # cold till we are not
_C_LABEL(esym): .long 0 # ptr to end of syms
_C_LABEL(boothowto): .long 0 # boot flags
@@ -394,6 +396,32 @@ try586: /* Use the `cpuid' instruction. */
movl %edx,RELOC(_C_LABEL(cpu_cache_edx))
2:
+ /* Check if brand identification string is supported */
+ movl $0x80000000,%eax
+ cpuid
+ cmpl $0x80000000,%eax
+ jbe 3f
+ movl $0x80000002,%eax
+ cpuid
+ movl %eax,RELOC(_C_LABEL(cpu_brandstr))
+ movl %ebx,RELOC(_C_LABEL(cpu_brandstr))+4
+ movl %ecx,RELOC(_C_LABEL(cpu_brandstr))+8
+ movl %edx,RELOC(_C_LABEL(cpu_brandstr))+12
+ movl $0x80000003,%eax
+ cpuid
+ movl %eax,RELOC(_C_LABEL(cpu_brandstr))+16
+ movl %ebx,RELOC(_C_LABEL(cpu_brandstr))+20
+ movl %ecx,RELOC(_C_LABEL(cpu_brandstr))+24
+ movl %edx,RELOC(_C_LABEL(cpu_brandstr))+28
+ movl $0x80000004,%eax
+ cpuid
+ movl %eax,RELOC(_C_LABEL(cpu_brandstr))+32
+ movl %ebx,RELOC(_C_LABEL(cpu_brandstr))+36
+ movl %ecx,RELOC(_C_LABEL(cpu_brandstr))+40
+ andl $0x00ffffff,%edx /* Shouldn't be necessary */
+ movl %edx,RELOC(_C_LABEL(cpu_brandstr))+44
+
+3:
/*
* Finished with old stack; load new %esp now instead of later so we
* can trace this code without having to worry about the trace trap
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 70e1075d6ef..0093d518613 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.249 2003/11/14 07:15:53 kevlo Exp $ */
+/* $OpenBSD: machdep.c,v 1.250 2003/11/15 19:27:50 henning Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -1714,6 +1714,7 @@ void
identifycpu()
{
extern char cpu_vendor[];
+ extern char cpu_brandstr[];
extern int cpu_id;
extern int cpu_feature;
extern int cpu_ecxfeature;
@@ -1728,6 +1729,8 @@ identifycpu()
int family, model, step, modif, cachesize;
const struct cpu_cpuid_nameclass *cpup = NULL;
void (*cpu_setup)(const char *, int, int);
+ char *brandstr_from, *brandstr_to;
+ int skipspace;
if (cpuid_level == -1) {
#ifdef DIAGNOSTIC
@@ -1833,16 +1836,35 @@ identifycpu()
cachesize = intel_cachetable[(cpu_cache_edx & 0xFF) - 0x40];
}
+ /* Remove leading and duplicated spaces from cpu_brandstr */
+ brandstr_from = brandstr_to = cpu_brandstr;
+ skipspace = 1;
+ while (*brandstr_from != '\0') {
+ if (!skipspace || *brandstr_from != ' ') {
+ skipspace = 0;
+ *(brandstr_to++) = *brandstr_from;
+ }
+ if (*brandstr_from == ' ')
+ skipspace = 1;
+ brandstr_from++;
+ }
+ *brandstr_to = '\0';
+
+ if (cpu_brandstr[0] == '\0') {
+ snprintf(cpu_brandstr, 48 /* sizeof(cpu_brandstr) */,
+ "%s %s%s", vendorname, modifier, name);
+ }
+
if (cachesize > -1) {
snprintf(cpu_model, sizeof(cpu_model),
- "%s %s%s (%s%s%s%s-class, %dKB L2 cache)",
- vendorname, modifier, name,
+ "%s (%s%s%s%s-class, %dKB L2 cache)",
+ cpu_brandstr,
((*token) ? "\"" : ""), ((*token) ? token : ""),
((*token) ? "\" " : ""), classnames[class], cachesize);
} else {
snprintf(cpu_model, sizeof(cpu_model),
- "%s %s%s (%s%s%s%s-class)",
- vendorname, modifier, name,
+ "%s (%s%s%s%s-class)",
+ cpu_brandstr,
((*token) ? "\"" : ""), ((*token) ? token : ""),
((*token) ? "\" " : ""), classnames[class]);
}
@@ -1862,11 +1884,11 @@ identifycpu()
ghz = (pentium_mhz + 9) / 1000;
fr = ((pentium_mhz + 9) / 10 ) % 100;
if (fr)
- printf(" %d.%02d GHz", ghz, fr);
+ printf(" @%d.%02d GHz", ghz, fr);
else
- printf(" %d GHz", ghz);
+ printf(" @%d GHz", ghz);
} else
- printf(" %d MHz", pentium_mhz);
+ printf(" @%d MHz", pentium_mhz);
}
#endif
printf("\n");