diff options
author | Josh Bell <josh@lindenlab.com> | 2007-04-11 17:54:18 +0000 |
---|---|---|
committer | Josh Bell <josh@lindenlab.com> | 2007-04-11 17:54:18 +0000 |
commit | 0277259455c4354f81ea8a24c8ab93f27567bc6f (patch) | |
tree | f1411dab563dcf697f794e9e8a592a6d3e5c4d2d /indra/llcommon/llprocessor.cpp | |
parent | 568397bbcc4fca307ebc010ec7f815422b9ba80a (diff) |
svn merge -r 59968:60342 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release
Diffstat (limited to 'indra/llcommon/llprocessor.cpp')
-rw-r--r-- | indra/llcommon/llprocessor.cpp | 216 |
1 files changed, 85 insertions, 131 deletions
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index a941941fa8..0e469e6341 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -84,6 +84,7 @@ static void _Delay(unsigned int ms) CProcessor::CProcessor() { uqwFrequency = 0; + strCPUName[0] = 0; memset(&CPUInfo, 0, sizeof(CPUInfo)); } @@ -226,77 +227,44 @@ bool CProcessor::AnalyzeIntelProcessor() CPUInfo.uiType = (eaxreg >> 12) & 0x3; CPUInfo.uiBrandID = ebxreg & 0xF; - // Now we can translate the type number to a more understandable string format - switch (CPUInfo.uiType) + static const char* INTEL_BRAND[] = { - case 0: // Type = 0: Original OEM processor - strcpy(CPUInfo.strType, "Original OEM"); /* Flawfinder: ignore */ - strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */ - strcat(strCPUName, " "); /* Flawfinder: ignore */ - break; - case 1: // Type = 1: Overdrive processor - strcpy(CPUInfo.strType, "Overdrive"); /* Flawfinder: ignore */ - strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */ - strcat(strCPUName, " "); /* Flawfinder: ignore */ - break; - case 2: // Type = 2: Dual-capable processor - strcpy(CPUInfo.strType, "Dual-capable"); /* Flawfinder: ignore */ - strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */ - strcat(strCPUName, " "); /* Flawfinder: ignore */ - break; - case 3: // Type = 3: Reserved for future use - strcpy(CPUInfo.strType, "Reserved"); /* Flawfinder: ignore */ - break; - default: // This should be never called, cause we just mask 2 bits --> [0..3] - strcpy(CPUInfo.strType, "Unknown"); /* Flawfinder: ignore */ - break; - } - - // Then we translate the brand id: - switch (CPUInfo.uiBrandID) + /* 0x00 */ "", + /* 0x01 */ "0.18 micron Intel Celeron", + /* 0x02 */ "0.18 micron Intel Pentium III", + /* 0x03 */ "0.13 micron Intel Celeron", + /* 0x04 */ "0.13 micron Intel Pentium III", + /* 0x05 */ "", + /* 0x06 */ "0.13 micron Intel Pentium III mobile", + /* 0x07 */ "0.13 micron Intel Celeron mobile", + /* 0x08 */ "0.18 micron Intel Pentium 4", + /* 0x09 */ "0.13 micron Intel Pentium 4", + /* 0x0A */ "0.13 micron Intel Pentium 4", + /* 0x0B */ "0.13 micron Intel Pentium 4 Xeon", + /* 0x0C */ "", + /* 0x0D */ "", + /* 0x0E */ "0.18 micron Intel Pentium 4 Xeon", + /* 0x0F */ "", + /* 0x10 */ "", + /* 0x11 */ "", + /* 0x12 */ "Intel Celeron M", + /* 0x13 */ "mobile Intel Celeron", + /* 0x14 */ "Intel Celeron", + /* 0x15 */ "mobile Intel", + /* 0x16 */ "Intel Pentium M", + /* 0x17 */ "mobile Intel Celeron", + }; + + // Only override the brand if we have it in the lookup table. We should + // already have a string here from GetCPUInfo(). JC + if (CPUInfo.uiBrandID < sizeof(INTEL_BRAND)) { - case 0: // Brand id = 0: Brand id not supported on this processor - strcpy(CPUInfo.strBrandID, "Not supported"); /* Flawfinder: ignore */ - break; - case 1: // Brand id = 1: Intel Celeron (0.18 micron) processor - strcpy(CPUInfo.strBrandID, "0.18 micron Intel Celeron"); /* Flawfinder: ignore */ - break; - case 2: // Brand id = 2: Intel Pentium III (0.18 micron) processor - strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium III"); /* Flawfinder: ignore */ - break; - case 3: // Brand id = 3: Model dependent - if (CPUInfo.uiModel == 6) // If the cpu model is Celeron (well, I'm NOT SURE!!!) - strcpy(CPUInfo.strBrandID, "0.13 micron Intel Celeron"); /* Flawfinder: ignore */ - else - strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium III Xeon"); /* Flawfinder: ignore */ - break; - case 4: // Brand id = 4: Intel Pentium III Tualatin (0.13 micron) processor - strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium III"); /* Flawfinder: ignore */ - break; - case 6: // Brand id = 6: Intel Pentium III mobile (0.13 micron) processor - strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium III mobile"); /* Flawfinder: ignore */ - break; - case 7: // Brand id = 7: Intel Celeron mobile (0.13 micron) processor - strcpy(CPUInfo.strBrandID, "0.13 micron Intel Celeron mobile"); /* Flawfinder: ignore */ - break; - case 8: // Brand id = 8: Intel Pentium 4 Willamette (0.18 micron) processor - strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium 4"); /* Flawfinder: ignore */ - break; - case 9: // Brand id = 9: Intel Pentium 4 Northwood (0.13 micron) processor - strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium 4"); /* Flawfinder: ignore */ - break; - case 0xA: // Brand id = 0xA: Intel Pentium 4 Northwood (0.13 micron processor) - strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium 4"); /* Flawfinder: ignore */ - break; // No idea, where the difference to id=9 is - case 0xB: // Brand id = 0xB: Intel Pentium 4 Northwood Xeon (0.13 micron processor) - strcpy(CPUInfo.strBrandID, "0.13 micron Intel Pentium 4 Xeon"); /* Flawfinder: ignore */ - break; - case 0xE: // Brand id = 0xE: Intel Pentium 4 Willamette Xeon (0.18 micron processor) - strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium 4 Xeon"); /* Flawfinder: ignore */ - break; - default: // Should be never called, but sure is sure - strcpy(CPUInfo.strBrandID, "Unknown"); /* Flawfinder: ignore */ - break; + strcpy(CPUInfo.strBrandID, INTEL_BRAND[CPUInfo.uiBrandID]); + + if (CPUInfo.uiBrandID == 3 && CPUInfo.uiModel == 6) + { + strcpy(CPUInfo.strBrandID, "0.18 micron Intel Pentium III Xeon"); + } } // Then we translate the cpu family @@ -648,33 +616,6 @@ bool CProcessor::AnalyzeAMDProcessor() CPUInfo.uiFamily = (eaxreg >> 8) & 0xF; CPUInfo.uiType = (eaxreg >> 12) & 0x3; - // After that, we translate the processor type (see CProcessor::AnalyzeIntelProcessor() - // for further comments on this) - switch (CPUInfo.uiType) - { - case 0: - strcpy(CPUInfo.strType, "Original OEM"); /* Flawfinder: ignore */ - strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */ - strcat(strCPUName, " "); /*Flawfinder: ignore*/ - break; - case 1: - strcpy(CPUInfo.strType, "Overdrive"); /* Flawfinder: ignore */ - strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */ - strcat(strCPUName, " "); /*Flawfinder: ignore*/ - break; - case 2: - strcpy(CPUInfo.strType, "Dual-capable"); /* Flawfinder: ignore */ - strcpy(strCPUName, CPUInfo.strType); /* Flawfinder: ignore */ - strcat(strCPUName, " "); /*Flawfinder: ignore*/ - break; - case 3: - strcpy(CPUInfo.strType, "Reserved"); /* Flawfinder: ignore */ - break; - default: - strcpy(CPUInfo.strType, "Unknown"); /* Flawfinder: ignore */ - break; - } - // Now we check if the processor supports the brand id string extended CPUID level if (CPUInfo.MaxSupportedExtendedLevel >= 0x80000004) { @@ -709,7 +650,7 @@ bool CProcessor::AnalyzeAMDProcessor() else { // Or just tell there is no brand id string support - strcpy(CPUInfo.strBrandID, "Not supported"); /* Flawfinder: ignore */ + strcpy(CPUInfo.strBrandID, ""); /* Flawfinder: ignore */ } // After that we translate the processor family @@ -1103,26 +1044,6 @@ bool CProcessor::AnalyzeUnknownProcessor() snprintf(CPUInfo.strFamily, sizeof(CPUInfo.strFamily), "Family number %d", CPUInfo.uiFamily); /* Flawfinder: ignore */ snprintf(CPUInfo.strModel, sizeof(CPUInfo.strModel), "Model number %d", CPUInfo.uiModel); /* Flawfinder: ignore */ - // Nevertheless we can determine the processor type - switch (CPUInfo.uiType) - { - case 0: - strcpy(CPUInfo.strType, "Original OEM"); /*Flawfinder: ignore*/ - break; - case 1: - strcpy(CPUInfo.strType, "Overdrive"); /*Flawfinder: ignore*/ - break; - case 2: - strcpy(CPUInfo.strType, "Dual-capable"); /*Flawfinder: ignore*/ - break; - case 3: - strcpy(CPUInfo.strType, "Reserved"); /*Flawfinder: ignore*/ - break; - default: - strcpy(CPUInfo.strType, "Unknown"); /*Flawfinder: ignore*/ - break; - } - // And thats it return true; #else @@ -1634,6 +1555,8 @@ const ProcessorInfo *CProcessor::GetCPUInfo() *((unsigned long *) CPUInfo.strVendor) = ebxreg; *((unsigned long *) (CPUInfo.strVendor+4)) = edxreg; *((unsigned long *) (CPUInfo.strVendor+8)) = ecxreg; + // Null terminate for string comparisons below. + CPUInfo.strVendor[12] = 0; // We can also read the max. supported standard CPUID level CPUInfo.MaxSupportedLevel = eaxreg & 0xFFFF; @@ -1649,22 +1572,52 @@ const ProcessorInfo *CProcessor::GetCPUInfo() CPUInfo.MaxSupportedExtendedLevel = eaxreg; // Then we switch to the specific processor vendors - switch (ebxreg) + // See http://www.sandpile.org/ia32/cpuid.htm + if (!strcmp(CPUInfo.strVendor, "GenuineIntel")) { - case 0x756E6547: // GenuineIntel - AnalyzeIntelProcessor(); - break; - case 0x68747541: // AuthenticAMD - AnalyzeAMDProcessor(); - break; - case 0x69727943: // CyrixInstead - // I really do not know anyone owning such a piece of crab - // So we analyze it as an unknown processor *ggggg* - default: - AnalyzeUnknownProcessor(); - break; + AnalyzeIntelProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "AuthenticAMD")) + { + AnalyzeAMDProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "UMC UMC UMC")) + { + AnalyzeUnknownProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "CyrixInstead")) + { + AnalyzeUnknownProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "NexGenDriven")) + { + AnalyzeUnknownProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "CentaurHauls")) + { + AnalyzeUnknownProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "RiseRiseRise")) + { + AnalyzeUnknownProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "SiS SiS SiS")) + { + AnalyzeUnknownProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "GenuineTMx86")) + { + // Transmeta + AnalyzeUnknownProcessor(); + } + else if (!strcmp(CPUInfo.strVendor, "Geode by NSC")) + { + AnalyzeUnknownProcessor(); + } + else + { + AnalyzeUnknownProcessor(); } - #endif // After all we return the class CPUInfo member var return (&CPUInfo); @@ -1748,6 +1701,7 @@ void CProcessor::TranslateProcessorConfiguration() CProcessor::CProcessor() { uqwFrequency = 0; + strCPUName[0] = 0; memset(&CPUInfo, 0, sizeof(CPUInfo)); } |