Added more fine grained compatability for cpus in CPUID. Not implemented in NativeBigInteger yet.

This commit is contained in:
dev
2011-06-08 18:07:46 +00:00
parent 2cebe86524
commit 26899e488e

View File

@ -198,32 +198,44 @@ public class CPUID {
protected abstract static class CPUIDCPUInfo protected abstract static class CPUIDCPUInfo
{ {
protected boolean isX64 = false;
public String getVendor() public String getVendor()
{ {
return getCPUVendorID(); return getCPUVendorID();
} }
public boolean hasMMX(){ public boolean hasMMX()
{
return (getEDXCPUFlags() & 0x800000) >0; //EDX Bit 23 return (getEDXCPUFlags() & 0x800000) >0; //EDX Bit 23
} }
public boolean hasSSE(){ public boolean hasSSE(){
return (getEDXCPUFlags() & 0x2000000) >0; //EDX Bit 25 return (getEDXCPUFlags() & 0x2000000) >0; //EDX Bit 25
} }
public boolean hasSSE2(){ public boolean hasSSE2()
{
return (getEDXCPUFlags() & 0x4000000) >0; //EDX Bit 26 return (getEDXCPUFlags() & 0x4000000) >0; //EDX Bit 26
} }
public boolean hasSSE3(){ public boolean hasSSE3()
{
return (getEDXCPUFlags() & 0x1) >0; //ECX Bit 0 return (getEDXCPUFlags() & 0x1) >0; //ECX Bit 0
} }
public boolean hasSSE41(){ public boolean hasSSE41()
{
return (getEDXCPUFlags() & 0x80000) >0; //ECX Bit 19 return (getEDXCPUFlags() & 0x80000) >0; //ECX Bit 19
} }
public boolean hasSSE42(){ public boolean hasSSE42()
{
return (getEDXCPUFlags() & 0x100000) >0; //ECX Bit 20 return (getEDXCPUFlags() & 0x100000) >0; //ECX Bit 20
} }
public boolean hasSSE4A(){ public boolean hasSSE4A()
{
return (getExtendedECXCPUFlags() & 0x40) >0; //Extended ECX Bit 6 return (getExtendedECXCPUFlags() & 0x40) >0; //Extended ECX Bit 6
} }
public boolean IsC3Compatible() { return false; } public boolean IsC3Compatible() { return false; }
public boolean hasX64()
{
return isX64;
}
} }
protected static class VIAC3Impl extends CPUIDCPUInfo implements CPUInfo { protected static class VIAC3Impl extends CPUIDCPUInfo implements CPUInfo {
@ -234,41 +246,24 @@ public class CPUID {
protected static class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo protected static class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
{ {
protected static boolean isK6Compatible = false;
protected static boolean isK6_2_Compatible = false;
protected static boolean isK6_3_Compatible = false;
protected static boolean isAthlonCompatible = false;
protected static boolean isAthlon64Compatible = false;
protected static boolean isBobcatCompatible = false;
//AMD-family = getCPUFamily()+getCPUExtendedFamily() //AMD-family = getCPUFamily()+getCPUExtendedFamily()
//AMD-model = getCPUModel()+getCPUExtendedModel() //AMD-model = getCPUModel()+getCPUExtendedModel()
public boolean IsK6Compatible(){ public boolean IsK6Compatible(){ return isK6Compatible; }
return (getCPUFamily() + getCPUExtendedFamily()) >= 5 && (getCPUModel() + getCPUExtendedModel()) >= 6; public boolean IsK6_2_Compatible(){ return isK6_2_Compatible; }
} public boolean IsK6_3_Compatible(){ return isK6_3_Compatible; }
public boolean IsAthlonCompatible(){ return isAthlonCompatible; }
public boolean IsK6_2_Compatible(){ public boolean IsAthlon64Compatible(){ return isAthlon64Compatible; }
return (getCPUFamily() + getCPUExtendedFamily()) >= 5 && (getCPUModel() + getCPUExtendedModel()) >= 8; public boolean IsBobcatCompatible(){ return isBobcatCompatible; }
}
public boolean IsK6_3_Compatible(){
return (getCPUFamily() + getCPUExtendedFamily()) >= 5 && (getCPUModel() + getCPUExtendedModel()) >= 9;
}
public boolean IsAthlonCompatible(){
return (getCPUFamily() + getCPUExtendedFamily()) >= 6;
}
public boolean IsAthlon64Compatible(){
//AMD64 class
if ((getCPUFamily() + getCPUExtendedFamily()) == 15){
return true;
//Stars (Phenom II/Athlon II/Third-Generation Opteron/Opteron 4100 & 6100/Sempron 1xx)
} else if ((getCPUFamily() + getCPUExtendedFamily()) == 16){
return true;
//K8 mobile+HT3 (Turion X2/Athlon X2/Sempron)
} else if ((getCPUFamily() + getCPUExtendedFamily()) == 17){
return true;
} else {
return false;
}
}
public String getCPUModelString() throws UnknownCPUException {
public String getCPUModelString() throws UnknownCPUException
{
//i486 class (Am486, 5x86) //i486 class (Am486, 5x86)
if(getCPUFamily() + getCPUExtendedFamily() == 4){ if(getCPUFamily() + getCPUExtendedFamily() == 4){
switch(getCPUModel() + getCPUExtendedModel()){ switch(getCPUModel() + getCPUExtendedModel()){
@ -288,6 +283,7 @@ public class CPUID {
} }
//i586 class (K5/K6/K6-2/K6-III) //i586 class (K5/K6/K6-2/K6-III)
if(getCPUFamily() + getCPUExtendedFamily() == 5){ if(getCPUFamily() + getCPUExtendedFamily() == 5){
isK6Compatible = true;
switch(getCPUModel() + getCPUExtendedModel()){ switch(getCPUModel() + getCPUExtendedModel()){
case 0: case 0:
return "K5/SSA5"; return "K5/SSA5";
@ -302,15 +298,23 @@ public class CPUID {
case 7: case 7:
return "K6"; return "K6";
case 8: case 8:
isK6_2_Compatible = true;
return "K6-2"; return "K6-2";
case 9: case 9:
isK6_2_Compatible = true;
isK6_3_Compatible = true;
return "K6-3"; return "K6-3";
case 13: case 13:
isK6_2_Compatible = true;
return "K6-2+ or K6-III+"; return "K6-2+ or K6-III+";
} }
} }
//i686 class (Athlon/Athlon XP/Duron/K7 Sempron) //i686 class (Athlon/Athlon XP/Duron/K7 Sempron)
if(getCPUFamily() + getCPUExtendedFamily() == 6){ if(getCPUFamily() + getCPUExtendedFamily() == 6){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
switch(getCPUModel() + getCPUExtendedModel()){ switch(getCPUModel() + getCPUExtendedModel()){
case 0: case 0:
return "Athlon (250 nm)"; return "Athlon (250 nm)";
@ -334,6 +338,12 @@ public class CPUID {
} }
//AMD64 class (A64/Opteron/A64 X2/K8 Sempron/Turion/Second-Generation Opteron/Athlon Neo) //AMD64 class (A64/Opteron/A64 X2/K8 Sempron/Turion/Second-Generation Opteron/Athlon Neo)
if(getCPUFamily() + getCPUExtendedFamily() == 15){ if(getCPUFamily() + getCPUExtendedFamily() == 15){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){ switch(getCPUModel() + getCPUExtendedModel()){
case 4: case 4:
return "Athlon 64/Mobile XP-M"; return "Athlon 64/Mobile XP-M";
@ -419,6 +429,12 @@ public class CPUID {
} }
//Stars (Phenom II/Athlon II/Third-Generation Opteron/Opteron 4100 & 6100/Sempron 1xx) //Stars (Phenom II/Athlon II/Third-Generation Opteron/Opteron 4100 & 6100/Sempron 1xx)
if(getCPUFamily() + getCPUExtendedFamily() == 16){ if(getCPUFamily() + getCPUExtendedFamily() == 16){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){ switch(getCPUModel() + getCPUExtendedModel()){
case 2: case 2:
return "Phenom / Athlon / Opteron Gen 3 (Barcelona/Agena/Toliman/Kuma, 65 nm)"; return "Phenom / Athlon / Opteron Gen 3 (Barcelona/Agena/Toliman/Kuma, 65 nm)";
@ -438,6 +454,12 @@ public class CPUID {
} }
//K8 mobile+HT3 (Turion X2/Athlon X2/Sempron) //K8 mobile+HT3 (Turion X2/Athlon X2/Sempron)
if(getCPUFamily() + getCPUExtendedFamily() == 17){ if(getCPUFamily() + getCPUExtendedFamily() == 17){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){ switch(getCPUModel() + getCPUExtendedModel()){
case 3: case 3:
return "AMD Turion X2/Athlon X2/Sempron (Lion/Sable, 65 nm)"; return "AMD Turion X2/Athlon X2/Sempron (Lion/Sable, 65 nm)";
@ -445,6 +467,13 @@ public class CPUID {
} }
//Bobcat //Bobcat
if(getCPUFamily() + getCPUExtendedFamily() == 20){ if(getCPUFamily() + getCPUExtendedFamily() == 20){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isBobcatCompatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){ switch(getCPUModel() + getCPUExtendedModel()){
case 1: case 1:
return "Bobcat APU"; return "Bobcat APU";
@ -459,67 +488,26 @@ public class CPUID {
protected static class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo protected static class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
{ {
public boolean IsPentiumCompatible() protected static boolean isPentiumCompatible = false;
{ protected static boolean isPentiumMMXCompatible = false;
return getCPUFamily() >= 5; protected static boolean isPentium2Compatible = false;
} protected static boolean isPentium3Compatible = false;
public boolean IsPentiumMMXCompatible() protected static boolean isPentium4Compatible = false;
{ protected static boolean isAtomCompatible = false;
return IsPentium2Compatible() || (getCPUFamily() == 5 && (getCPUModel() ==4 || getCPUModel() == 8)); protected static boolean isCore2Compatible = false;
} protected static boolean isCoreiCompatible = false;
public boolean IsPentium2Compatible()
{
return getCPUFamily() > 6 || (getCPUFamily() == 6 && getCPUModel() >=3);
}
public boolean IsPentium3Compatible()
{
return getCPUFamily() > 6 || (getCPUFamily() == 6 && getCPUModel() >=7);
}
public boolean IsPentium4Compatible()
{
// P4
if (getCPUFamily() >= 15){
return true;
// Core i3/i5/i7
// Remove when implemented isCoreiCompatible in BigInteger
} else if (getCPUExtendedModel() == 2 && (getCPUFamily() == 6)){
// Xeon MP (45nm) or Core i7
// Remove when implemented isCoreiCompatible in BigInteger
} else if (getCPUExtendedModel() == 1 && (getCPUFamily() == 6 && (getCPUModel() == 10 || getCPUModel() == 13 || getCPUModel() == 14))){
return true;
// Core 2 Duo
// Remove when implemented isCore7Compatible in BigInteger
} else if (getCPUExtendedModel() == 0 && getCPUFamily() == 6 && getCPUModel() == 15){
return true;
}
return false;
}
public boolean IsAtomCompatible()
{
if (getCPUExtendedModel() == 0 && getCPUFamily() == 6 && getCPUModel() == 12){
return true;
}
return false;
} public boolean IsPentiumCompatible(){ return isPentiumCompatible; }
public boolean IsCore2Compatible() public boolean IsPentiumMMXCompatible(){ return isPentiumMMXCompatible; }
public boolean IsPentium2Compatible(){ return isPentium2Compatible; }
public boolean IsPentium3Compatible(){ return isPentium3Compatible; }
public boolean IsPentium4Compatible(){ return isPentium4Compatible; }
public boolean IsAtomCompatible(){ return isAtomCompatible; }
public boolean IsCore2Compatible(){ return isCore2Compatible; }
public boolean IsCoreiCompatible(){ return isCoreiCompatible; }
public String getCPUModelString() throws UnknownCPUException
{ {
if (getCPUExtendedModel() == 0 && getCPUFamily() == 6 && getCPUModel() == 15){
return true;
}
return false;
}
public boolean IsCoreiCompatible()
{
// Core i3/i5/i7
if (getCPUExtendedModel() == 2 && (getCPUFamily() == 6)){
// Xeon MP (45nm) or Core i7
} else if (getCPUExtendedModel() == 1 && (getCPUFamily() == 6 && (getCPUModel() == 10 || getCPUModel() == 13 || getCPUModel() == 14))){
return true;
}
return false;
}
public String getCPUModelString() throws UnknownCPUException {
if (getCPUExtendedModel() == 0){ if (getCPUExtendedModel() == 0){
if(getCPUFamily() == 4){ if(getCPUFamily() == 4){
switch(getCPUModel()){ switch(getCPUModel()){
@ -546,6 +534,7 @@ public class CPUID {
} }
if (getCPUExtendedModel() == 0){ if (getCPUExtendedModel() == 0){
if(getCPUFamily() == 5){ if(getCPUFamily() == 5){
isPentiumCompatible = true;
switch(getCPUModel()){ switch(getCPUModel()){
case 0: case 0:
return "Pentium 60/66 A-step"; return "Pentium 60/66 A-step";
@ -556,56 +545,108 @@ public class CPUID {
case 3: case 3:
return "OverDrive PODP5V83"; return "OverDrive PODP5V83";
case 4: case 4:
isPentiumMMXCompatible = true;
return "Pentium MMX"; return "Pentium MMX";
case 7: case 7:
return "Mobile Pentium 75 - 200"; return "Mobile Pentium 75 - 200";
case 8: case 8:
isPentiumMMXCompatible = true;
return "Mobile Pentium MMX"; return "Mobile Pentium MMX";
} }
} }
} }
if(getCPUFamily() == 6){ if(getCPUFamily() == 6){
if (getCPUExtendedModel() == 0){ if (getCPUExtendedModel() == 0){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
switch(getCPUModel()){ switch(getCPUModel()){
case 0: case 0:
return "Pentium Pro A-step"; return "Pentium Pro A-step";
case 1: case 1:
return "Pentium Pro"; return "Pentium Pro";
case 3: case 3:
isPentium2Compatible = true;
return "Pentium II (Klamath)"; return "Pentium II (Klamath)";
case 5: case 5:
isPentium2Compatible = true;
return "Pentium II (Deschutes), Celeron (Covington), Mobile Pentium II (Dixon)"; return "Pentium II (Deschutes), Celeron (Covington), Mobile Pentium II (Dixon)";
case 6: case 6:
isPentium2Compatible = true;
return "Mobile Pentium II, Celeron (Mendocino)"; return "Mobile Pentium II, Celeron (Mendocino)";
case 7: case 7:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III (Katmai)"; return "Pentium III (Katmai)";
case 8: case 8:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III (Coppermine), Celeron w/SSE"; return "Pentium III (Coppermine), Celeron w/SSE";
case 9: case 9:
return "Mobile Pentium III (Banias)"; isPentium2Compatible = true;
isPentium3Compatible = true;
isX64 = true;
return "Pentium M (Banias)";
case 10: case 10:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III Xeon (Cascades)"; return "Pentium III Xeon (Cascades)";
case 11: case 11:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III (130 nm)"; return "Pentium III (130 nm)";
case 13: case 13:
return "Mobile Pentium III (Dothan)"; isPentium2Compatible = true;
isPentium3Compatible = true;
isX64 = true;
return "Core (Yonah)";
case 14: case 14:
return "Mobile Core (Yonah)"; isPentium2Compatible = true;
isPentium3Compatible = true;
isCore2Compatible = true;
isX64 = true;
return "Core 2 (Conroe)";
case 15: case 15:
isPentium2Compatible = true;
isPentium3Compatible = true;
isCore2Compatible = true;
isX64 = true;
return "Core 2 (Conroe)"; return "Core 2 (Conroe)";
} }
} else if (getCPUExtendedModel() == 1){ } else if (getCPUExtendedModel() == 1){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
isPentium2Compatible = true;
isPentium3Compatible = true;
isPentium4Compatible = true;
isCore2Compatible = true;
isX64 = true;
switch(getCPUModel()){ switch(getCPUModel()){
case 6:
return "Celeron";
case 10: case 10:
isCoreiCompatible = true;
return "Core i7 (45nm)"; return "Core i7 (45nm)";
case 12: case 12:
isAtomCompatible = true;
isCore2Compatible = false;
isPentium4Compatible = false;
isX64 = true;
return "Atom"; return "Atom";
case 13: case 13:
isCoreiCompatible = true;
return "Xeon MP (45nm)"; return "Xeon MP (45nm)";
case 14: case 14:
isCoreiCompatible = true;
return "Core i5/i7 (45nm)"; return "Core i5/i7 (45nm)";
} }
} else if (getCPUExtendedModel() == 2){ } else if (getCPUExtendedModel() == 2){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
isPentium2Compatible = true;
isPentium3Compatible = true;
isCore2Compatible = true;
isCoreiCompatible = true;
isX64 = true;
switch(getCPUModel()){ switch(getCPUModel()){
case 5: case 5:
return "Core i3 or i5/i7 mobile (32nm)"; return "Core i3 or i5/i7 mobile (32nm)";
@ -627,6 +668,11 @@ public class CPUID {
} }
if(getCPUFamily() == 15){ if(getCPUFamily() == 15){
if(getCPUExtendedFamily() == 0){ if(getCPUExtendedFamily() == 0){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
isPentium2Compatible = true;
isPentium3Compatible = true;
isPentium4Compatible = true;
switch(getCPUModel()){ switch(getCPUModel()){
case 0: case 0:
return "Pentium IV (180 nm)"; return "Pentium IV (180 nm)";
@ -637,8 +683,10 @@ public class CPUID {
case 3: case 3:
return "Pentium IV (90 nm)"; return "Pentium IV (90 nm)";
case 4: case 4:
isX64 = true;
return "Pentium IV (90 nm)"; return "Pentium IV (90 nm)";
case 6: case 6:
isX64 = true;
return "Pentium IV (65 nm)"; return "Pentium IV (65 nm)";
} }
} }