From owner-freebsd-bugs Sat Jun 16 14:40:43 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 8822537B405 for ; Sat, 16 Jun 2001 14:40:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f5GLe2147065; Sat, 16 Jun 2001 14:40:02 -0700 (PDT) (envelope-from gnats) Date: Sat, 16 Jun 2001 14:40:02 -0700 (PDT) Message-Id: <200106162140.f5GLe2147065@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Brian Mitchell Subject: Re: i386/26994: AMD Athlon Thunderbird not known to identcpu.c Reply-To: Brian Mitchell Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR i386/26994; it has been noted by GNATS. From: Brian Mitchell To: freebsd-gnats-submit@FreeBSD.org, venglin@freebsd.lublin.pl Cc: freebsd-hackers@iss.net Subject: Re: i386/26994: AMD Athlon Thunderbird not known to identcpu.c Date: Sat, 16 Jun 2001 17:32:06 -0400 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 + } + To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message