Subject: Re: PIII overheat detection (redux)
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Johan Danielsson <joda@pdc.kth.se>
List: current-users
Date: 11/09/2002 23:24:46
Manuel Bouyer <bouyer@antioche.eu.org> writes:
> It is. My 1.2Ghz celeron is identifed as Xeon too:
I'd say it's *really* a bug in the cpuid instruction. For some
processors there is *no* way to tell what you're using without
resorting to serious hocus-pocus. I assume that's one reason Intel
invented the brand identifier. They only had like 2^32 combinations,
so I guess they felt they had to make some more room.
I have something like this in my machdep.c, along with lots of other
crap, so the patch may not apply cleanly.
/Johan
--- machdep.c 2002/10/20 10:35:41 1.492
+++ machdep.c 2002/11/09 22:11:06
@@ -1418,6 +1555,60 @@
/* ---------------------------------------------------------------------- */
+/*
+ * Map Brand ID from cpuid instruction to brand name.
+ * Source: Intel Processor Identification and the CPUID Instruction, AP-485
+ */
+
+/*
+
+*/
+
+
+
+const static struct intel_brand_name {
+ int brand;
+ int signature_min;
+ int signature_max;
+ const char *name;
+} intel_brand_names[] = {
+ { 1, 0, 0x0fff, "Celeron" },
+ { 2, 0, 0x0fff, "Pentium III" },
+ { 3, 0x06b1, 0x06b1, "Celeron" },
+ { 3, 0, 0x0fff, "Pentium III Xeon" },
+ { 4, 0, 0x0fff, "Pentium III" },
+ { 6, 0, 0x0fff, "Pentium III-M" },
+ { 7, 0, 0x0fff, "Celeron" }, /* mobile */
+#if 0
+ { 8, 0x0f13, 0x0fff, "\"Genuine\"" }, /* typo in AP-485? */
+#endif
+ { 8, 0, 0x0fff, "Pentium 4" },
+ { 9, 0, 0x0fff, "Pentium 4" },
+ { 10, 0, 0x0fff, "Celeron" },
+ { 11, 0, 0x0f12, "Xeon MP" },
+ { 11, 0x0f13, 0x0fff, "Xeon" },
+ { 14, 0, 0x0f12, "Xeon" },
+ { 14, 0x0f13, 0x0fff, "Pentium 4-M" },
+ { 15, 0, 0x0fff, "Pentium 4-M" } /* sample processors */
+};
+
+const static int num_intel_brand_names = sizeof(intel_brand_names) / sizeof(intel_brand_names[0]);
+
+static const char *
+intel_brand_name(struct cpu_info *ci)
+{
+ int i;
+ for (i = 0; i < num_intel_brand_names; i++) {
+ if(intel_brand_names[i].brand == ci->ci_brand_id &&
+ intel_brand_names[i].signature_min <= ci->ci_signature &&
+ intel_brand_names[i].signature_max >= ci->ci_signature)
+ return intel_brand_names[i].name;
+ }
+ return NULL;
+}
+
+/* ---------------------------------------------------------------------- */
+
static const struct i386_cache_info *
cache_info_lookup(const struct i386_cache_info *cai, u_int8_t desc)
{
@@ -1701,11 +2042,13 @@
* Intel processors family >= 6, model 8 allow to
* recognize brand by Brand ID value.
*/
- if (vendor == CPUVENDOR_INTEL && family >= 6 &&
- model >= 8 && ci->ci_brand_id &&
- ci->ci_brand_id < 8)
- brand = i386_intel_brand[ci->ci_brand_id];
+ if(vendor == CPUVENDOR_INTEL) {
+ const char *b;
+ b = intel_brand_name(ci);
+ if(b != NULL)
+ name = b;
+ }
if (vendor == CPUVENDOR_AMD && family == 6 &&
model >= 6) {
if (ci->ci_brand_id == 1)