[MPlayer-dev-eng] [PATCH] CPU detection related
Zuxy Meng
zuxy.meng at gmail.com
Sun May 14 14:28:15 CEST 2006
Hi,
2006/5/14, Diego Biurrun <diego at biurrun.de>:
> This hunk has inconsistent indentation with the rest of the block:
>
> + while(*ptmpstr == ' ')
> + ptmpstr++;
>
> Also, your patch does not apply here, please resend:
>
> patching file cpudetect.c
> Hunk #1 succeeded at 118 (offset 4 lines).
> Hunk #2 FAILED at 144.
> Hunk #3 succeeded at 229 (offset 4 lines).
> Hunk #4 succeeded at 239 (offset 4 lines).
> 1 out of 4 hunks FAILED -- saving rejects to file cpudetect.c.rej
>
I hope this works. Test with your K6-3+ first:-) It has builtin name string.
--
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
--- main/cpudetect.h 2006-05-11 15:26:30.000000000 +0800
+++ main.new/cpudetect.h 2006-05-14 20:07:40.000000000 +0800
@@ -36,6 +36,7 @@
typedef struct cpucaps_s {
int cpuType;
+ int cpuModel;
int cpuStepping;
int hasMMX;
int hasMMX2;
--- main/cpudetect.c 2006-03-04 20:51:49.000000000 +0800
+++ main.new/cpudetect.c 2006-05-14 20:23:06.000000000 +0800
@@ -118,12 +118,13 @@
(char*) (regs+1),(char*) (regs+3),(char*) (regs+2), regs[0]);
if (regs[0]>=0x00000001)
{
- char *tmpstr;
+ char *tmpstr, *ptmpstr;
unsigned cl_size;
do_cpuid(0x00000001, regs2);
caps->cpuType=(regs2[0] >> 8)&0xf;
+ caps->cpuModel=(regs2[0] >> 4)&0xf;
// see AMD64 Architecture Programmer's Manual, Volume 3: General-purpose and
// System Instructions, Table 3-2: Effective family computation, page 120.
@@ -131,6 +132,9 @@
// use extended family (P4, IA64, K8)
caps->cpuType=0xf+((regs2[0]>>20)&255);
}
+ if(caps->cpuType==0xf || caps->cpuType==6)
+ caps->cpuModel |= ((regs2[0]>>16)&0xf) << 4;
+
caps->cpuStepping=regs2[0] & 0xf;
// general feature flags:
@@ -142,11 +146,13 @@
cl_size = ((regs2[1] >> 8) & 0xFF)*8;
if(cl_size) caps->cl_size = cl_size;
- tmpstr=GetCpuFriendlyName(regs, regs2);
+ ptmpstr=tmpstr=GetCpuFriendlyName(regs, regs2);
+ while(*ptmpstr == ' ')
+ ptmpstr++;
mp_msg(MSGT_CPUDETECT,MSGL_INFO,"CPU: %s ",tmpstr);
free(tmpstr);
- mp_msg(MSGT_CPUDETECT,MSGL_INFO,"(Family: %d, Stepping: %d)\n",
- caps->cpuType, caps->cpuStepping);
+ mp_msg(MSGT_CPUDETECT,MSGL_INFO,"(Family: %d, Model: %d, Stepping: %d)\n",
+ caps->cpuType, caps->cpuModel, caps->cpuStepping);
}
do_cpuid(0x80000000, regs);
@@ -225,7 +231,7 @@
char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){
#include "cputable.h" /* get cpuname and cpuvendors */
- char vendor[17];
+ char vendor[13];
char *retname;
int i;
@@ -236,6 +242,19 @@
sprintf(vendor,"%.4s%.4s%.4s",(char*)(regs+1),(char*)(regs+3),(char*)(regs+2));
+ do_cpuid(0x80000000,regs);
+ if (regs[0] >= 0x80000004)
+ {
+ // CPU has built-in namestring
+ retname[0] = '\0';
+ for (i = 0x80000002; i <= 0x80000004; i++)
+ {
+ do_cpuid(i, regs);
+ strncat(retname, (char*)regs, 16);
+ }
+ return retname;
+ }
+
for(i=0; i<MAX_VENDORS; i++){
if(!strcmp(cpuvendors[i].string,vendor)){
if(cpuname[i][CPUID_FAMILY][CPUID_MODEL]){
@@ -495,6 +514,7 @@
void GetCpuCaps( CpuCaps *caps)
{
caps->cpuType=0;
+ caps->cpuModel=0;
caps->cpuStepping=0;
caps->hasMMX=0;
caps->hasMMX2=0;
More information about the MPlayer-dev-eng
mailing list