Bug 26994

Summary: AMD Athlon Thunderbird not known to identcpu.c
Product: Base System Reporter: Przemyslaw Frasunek <venglin>
Component: i386Assignee: David E. O'Brien <obrien>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   

Description Przemyslaw Frasunek 2001-04-30 20:40:00 UTC
	AMD Athlon Thunderbird isn't detected by identcpu.c:

	CPU: \^F (908.09-MHz 686-class CPU)
	  Origin = "AuthenticAMD"  Id = 0x642  Stepping = 2

Fix: 

Patch sys/i386/i386/identcpu.c
How-To-Repeat: 
	dmesg(8) on machine with Thunderbird installed.
Comment 1 bem 2001-06-16 22:32:06 UTC
I don't have a thundrbird, but has far as I know, k6-2+ supports the extended 
cpuid functions, so something like the following may be appropriate. This 
worked on my k6-2 and didnt break on any of my other machines (without the 
#if defined guards, in my case), but I don't know if there are some oddball 
686es that either dont support cpuid or dont support service 0x80000000 AND 
do bad things when recieving it.


*** identcpu.c.old	Sat Jun 16 16:39:34 2001
--- identcpu.c	Sat Jun 16 17:19:16 2001
***************
*** 75,80 ****
--- 75,81 ----
  static void print_AMD_info(u_int amd_maxregs);
  static void print_AMD_assoc(int i);
  static void do_cpuid(u_int ax, u_int *p);
+ static int do_ExtendedCPUID(char *buff);
  
  u_int	cyrix_did;		/* Device ID of Cyrix CPU */
  int cpu_class = CPUCLASS_386;	/* least common denominator */
***************
*** 214,220 ****
  					cpu = CPU_PIII;
  					break;
  				default:
! 				        strcat(cpu_model, "Unknown 80686");
  					break;
  				}
  				break;
--- 215,222 ----
  					cpu = CPU_PIII;
  					break;
  				default:
! 					if(do_ExtendedCPUID(cpu_model) < 0)
! 				        	strcat(cpu_model, "Unknown 80686");
  					break;
  				}
  				break;
***************
*** 223,229 ****
  				cpu = CPU_P4;
  				break;
  			default:
! 				strcat(cpu_model, "unknown");
  				break;
  			}
  
--- 225,232 ----
  				cpu = CPU_P4;
  				break;
  			default:
! 				if(do_ExtendedCPUID(cpu_model) < 0)
! 					strcat(cpu_model, "unknown");
  				break;
  			}
  
***************
*** 303,309 ****
  			strcat(cpu_model, "K6-III");
  			break;
  		default:
! 			strcat(cpu_model, "Unknown");
  			break;
  		}
  #if defined(I586_CPU) && defined(CPU_WT_ALLOC)
--- 306,313 ----
  			strcat(cpu_model, "K6-III");
  			break;
  		default:
! 			if(do_ExtendedCPUID(cpu_model) < 0)
! 				strcat(cpu_model, "Unknown");
  			break;
  		}
  #if defined(I586_CPU) && defined(CPU_WT_ALLOC)
***************
*** 1001,1003 ****
--- 1005,1078 ----
  		"\0403DNow!"
  		);
  }
+ 
+ /*
+  * Get the model of the cpu if it is supported by the processor. This
+  * is probably the ideal way to determine the name of the cpu, if it
+  * is supported.
+  *
+  * Documentation on this can be found at:
+  * 
http://developer.intel.com/design/processor/future/manuals/Cpuid_supplement.pdf
+  */
+ static int
+ do_ExtendedCPUID(char *buff)
+ {
+ #if defined(I686_CPU)
+ 	char cpustring[128];
+ 	unsigned int extCpuidFunc=0;
+ 
+ 	/* get the highest cpuid extended func supported */
+ 	__asm ("
+ 	movl $0x80000000, %%eax
+ 	cpuid
+ 	movl %%eax, %0"
+ 	: "=g" (extCpuidFunc)
+ 	:
+ 	: "eax");
+ 
+ 	/*
+ 	 * if 0x80000002 - 0x80000004 are not supported, than this processor
+ 	 * will not supply us the information we need. We should gracefully
+ 	 * exit in that case.
+ 	 */
+ 	if(extCpuidFunc < 0x80000004)
+ #endif
+ 		return -1;
+ #if defined(I686_CPU)
+ 
+ 	/*
+ 	 * we can now use cpuid services 0x80000002-0x80000004 in order to
+ 	 * fill our buffer 16 bytes at a time (total buffer provided can
+ 	 * be up to 48 bytes).
+ 	 */
+ 	__asm ("
+ 	cld
+ 	lea (%0), %%edi
+ 	movl $0x80000002, %%eax
+ 	cpuid
+ 	movl %%eax, (%%edi)
+ 	movl %%ebx, 4(%%edi)
+ 	movl %%ecx, 8(%%edi)
+ 	movl %%edx, 12(%%edi)
+ 	addl $16, %%edi
+ 	movl $0x80000003, %%edi
+ 	cpuid
+ 	movl %%eax, (%%edi)
+ 	movl %%ebx, 4(%%edi)
+ 	movl %%ecx, 8(%%edi)
+ 	movl %%edx, 12(%%edi)
+ 	addl $16, %%edi
+ 	movl $0x80000004, %%eax
+ 	cpuid
+ 	movl %%eax, (%%edi)
+ 	movl %%ebx, 4(%%edi)
+ 	movl %%ecx, 8(%%edi)
+ 	movl %%edx, 12(%%edi)"
+ 	:
+ 	: "g" (cpustring)
+ 	: "eax", "ebx", "ecx", "edx", "esp");
+ 	strcat(buff, cpustring);
+ 	return 0;
+ #endif
+ }
+
Comment 2 David E. O'Brien freebsd_committer freebsd_triage 2001-09-02 18:02:27 UTC
Responsible Changed
From-To: freebsd-bugs->obrien

I have an Athon 
.
Comment 3 Giorgos Keramidas freebsd_committer freebsd_triage 2002-04-08 21:22:50 UTC
Adding to audit trail:

> Date: Mon, 1 Apr 2002 09:43:26 +0200
> From: Przemyslaw Frasunek <venglin@freebsd.lublin.pl>
>
>  This PR can be closed now.
Comment 4 Bruce M Simpson freebsd_committer freebsd_triage 2004-06-22 15:54:34 UTC
State Changed
From-To: open->closed

Closed at submitter's request