From issei@issei.org  Wed Nov 18 16:11:30 1998
Received: from ns.issei.org (ns.issei.org [210.169.187.130])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA07467
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Nov 1998 16:11:28 -0800 (PST)
          (envelope-from issei@issei.org)
Received: from sandra.issei.org (sandra.issei.org [210.169.187.134])
	by ns.issei.org (8.9.1a/3.7W-hub) with ESMTP id JAA03400
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 19 Nov 1998 09:10:58 +0900 (JST)
Received: by sandra.issei.org (8.8.8/3.7W-null)
	id JAA23205; Thu, 19 Nov 1998 09:10:58 +0900 (JST)
Message-Id: <199811190010.JAA23205@sandra.issei.org>
Date: Thu, 19 Nov 1998 09:10:58 +0900 (JST)
From: issei@jp.FreeBSD.ORG
To: FreeBSD-gnats-submit@freebsd.org
Subject: Cannot display new CPU name correctly.
X-Send-Pr-Version: 3.2

>Number:         8751
>Category:       kern
>Synopsis:       Cannot display new CPU name correctly.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 18 16:20:00 PST 1998
>Closed-Date:    Thu Feb 4 08:54:32 PST 1999
>Last-Modified:  Thu Feb  4 08:56:52 PST 1999
>Originator:     Issei Suzuki
>Release:        FreeBSD 2.2.7-STABLE i386
>Organization:
Personal
>Environment:

	

>Description:

	FreeBSD cannot display Intel's new CPU name correctly on boot time.

>How-To-Repeat:

	This is the boot time message when I use Celeron CPU.

CPU: Unknown 80686 (300.68-MHz 686-class CPU)
Origin = "GenuineIntel"  Id = 0x660  Stepping=0
Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,<b16>,<b17>,MMX,<b24>>

	FreeBSD displays CPU name as 'Unknown 80686' instead of 'Celeron'

>Fix:

	Apply the following patch to /sys/i386/i386/identcpu.c


	See also Intel's Application note AP-485 "Intel Processor
	Identification and the CPUID Instruction"

	http://developer.intel.com/design/pro/applnots/241618.HTM

--- i386/i386/identcpu.c.old	Sat Sep 12 09:54:28 1998
+++ i386/i386/identcpu.c	Sat Sep 12 12:22:20 1998
@@ -71,6 +71,7 @@
 static void print_AMD_info(void);
 static void print_AMD_assoc(int i);
 static void do_cpuid(u_long ax, u_long *p);
+static int get_L2cache(void);
 
 u_long	cyrix_did;		/* Device ID of Cyrix CPU */
 int cpu_class = CPUCLASS_386;	/* least common denominator */
@@ -196,8 +197,33 @@
 					cpu = CPU_PII;
 					break;
 				case 0x50:
-				        strcat(cpu_model, "Pentium II (quarter-micron)");
-					cpu = CPU_PII;
+				case 0x60:
+					/* Ident Celeron and Pentium II */
+					switch (get_L2cache()) {
+					case 0:
+						strcat(cpu_model, "Celeron");
+						break;
+					case 128:
+						strcat(cpu_model, "Celeron (L2 128KB)");
+						break;
+					case 512:
+						strcat(cpu_model, "Pentium II (quarter-micron) / Pentium II Xeon (L2 512KB)");
+						cpu = CPU_PII;
+						break;
+					case 1024:
+						strcat(cpu_model, "Pentium II Xeon (L2 1MB)");
+						cpu = CPU_PII;
+						break;
+					case 2048:
+						strcat(cpu_model, "Pentium II Xeon (L2 2MB)");
+						cpu = CPU_PII;
+						break;
+
+					case -1:
+					default:
+				        	strcat(cpu_model, "Unknown 80686");
+						break;
+					}
 					break;
 				default:
 				        strcat(cpu_model, "Unknown 80686");
@@ -829,4 +855,35 @@
 		printf(", %d lines/tag", (regs[3] >> 8) & 0xff);
 		print_AMD_assoc((regs[3] >> 16) & 0xff);
 	}
+}
+
+/* check the amount of L2 cache */
+static int
+get_L2cache(void)
+{
+	int i, j;
+	u_long regs[4];
+	do_cpuid(2, regs);
+
+	for (i=0; i<4; i++)
+		for (j=0; j<4; j++)
+			switch ((regs[i] >> j*8) & 0xff) {
+			case 0x40:
+				return 0;
+			case 0x41:
+				return 128;
+			case 0x42:
+				return 256;
+			case 0x43:
+				return 512;
+			case 0x44:
+				return 1024;
+			case 0x45:
+				return 2048;
+			default:
+			        /* nothing */
+				break;
+			}
+
+	return -1;
 }
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: kato 
State-Changed-When: Thu Feb 4 08:54:32 PST 1999 
State-Changed-Why:  
4.0-current now recognizes your cpu. 
>Unformatted:
