diff options
| author | Matthew Parlane <parlane@gmail.com> | 2013-08-23 00:51:12 +1200 |
|---|---|---|
| committer | Matthew Parlane <parlane@gmail.com> | 2013-08-23 00:51:12 +1200 |
| commit | b6e054a2beef3236822e27d95dfe38a4ccee2eb1 (patch) | |
| tree | 6f744593b14def9c2fbc7be9e509df5507835cc4 /Source/Core/Common/Src/ArmCPUDetect.cpp | |
| parent | f274b3b074fb8bb0477b0e9f4e88db0e08bf4f2c (diff) | |
| parent | 41c25d0c90a2461c3e34bf9659dcf1da5e1e8580 (diff) | |
Merge branch 'master' into wii-network
Conflicts:
Source/Core/Core/Core.vcxproj
Source/Core/Core/Core.vcxproj.filters
Source/Core/Core/Src/CoreParameter.cpp
Source/Core/DolphinWX/Dolphin.vcxproj
Source/Core/DolphinWX/Dolphin.vcxproj.filters
Diffstat (limited to 'Source/Core/Common/Src/ArmCPUDetect.cpp')
| -rw-r--r-- | Source/Core/Common/Src/ArmCPUDetect.cpp | 95 |
1 files changed, 80 insertions, 15 deletions
diff --git a/Source/Core/Common/Src/ArmCPUDetect.cpp b/Source/Core/Common/Src/ArmCPUDetect.cpp index ca277ade02..ef49d6efb1 100644 --- a/Source/Core/Common/Src/ArmCPUDetect.cpp +++ b/Source/Core/Common/Src/ArmCPUDetect.cpp @@ -17,9 +17,10 @@ #include "Common.h" #include "CPUDetect.h" -#include "StringUtil.h" #include "FileUtil.h" +// Only Linux platforms have /proc/cpuinfo +#if !defined(BLACKBERRY) && !defined(IOS) && !defined(__SYMBIAN32__) const char procfile[] = "/proc/cpuinfo"; char *GetCPUString() @@ -33,7 +34,7 @@ char *GetCPUString() auto const fp = file.GetHandle(); if (!fp) return 0; - + while (fgets(buf, sizeof(buf), fp)) { if (strncmp(buf, marker, sizeof(marker) - 1)) @@ -42,6 +43,7 @@ char *GetCPUString() cpu_string = strndup(cpu_string, strlen(cpu_string) - 1); // Strip the newline break; } + return cpu_string; } @@ -66,6 +68,9 @@ unsigned char GetCPUImplementer() sscanf(implementer_string, "0x%02hhx", &implementer); break; } + + free(implementer_string); + return implementer; } @@ -90,15 +95,17 @@ unsigned short GetCPUPart() sscanf(part_string, "0x%03hx", &part); break; } - return part; + free(part_string); + + return part; } bool CheckCPUFeature(const char *feature) { const char marker[] = "Features\t: "; char buf[1024]; - + File::IOFile file(procfile, "r"); auto const fp = file.GetHandle(); if (!fp) @@ -117,10 +124,18 @@ bool CheckCPUFeature(const char *feature) token = strtok(NULL, " "); } } + return false; } +#endif + int GetCoreCount() { +#ifdef __SYMBIAN32__ + return 1; +#elif defined(BLACKBERRY) || defined(IOS) + return 2; +#else const char marker[] = "processor\t: "; int cores = 0; char buf[1024]; @@ -129,14 +144,16 @@ int GetCoreCount() auto const fp = file.GetHandle(); if (!fp) return 0; - + while (fgets(buf, sizeof(buf), fp)) { if (strncmp(buf, marker, sizeof(marker) - 1)) continue; ++cores; } + return cores; +#endif } CPUInfo cpu_info; @@ -153,12 +170,58 @@ void CPUInfo::Detect() HTT = false; OS64bit = false; CPU64bit = false; - Mode64bit = false; + Mode64bit = false; vendor = VENDOR_ARM; - + // Get the information about the CPU - strncpy(cpu_string, GetCPUString(), sizeof(cpu_string)); num_cores = GetCoreCount(); +#if defined(__SYMBIAN32__) || defined(BLACKBERRY) || defined(IOS) + bool isVFP3 = false; + bool isVFP4 = false; +#ifdef IOS + isVFP3 = true; + // Check for swift arch (VFP4`) + #ifdef __ARM_ARCH_7S__ + isVFP4 = true; + #endif // #ifdef __ARM_ARCH_7S__ +#elif defined(BLACKBERRY) + isVFP3 = true; + const char cpuInfoPath[] = "/pps/services/hw_info/inventory"; + const char marker[] = "Processor_Name::"; + const char qcCPU[] = "MSM"; + char buf[1024]; + FILE* fp; + if (fp = fopen(cpuInfoPath, "r")) + { + while (fgets(buf, sizeof(buf), fp)) + { + if (strncmp(buf, marker, sizeof(marker) - 1)) + continue; + if (strncmp(buf + sizeof(marker) - 1, qcCPU, sizeof(qcCPU) - 1) == 0) + isVFP4 = true; + break; + } + fclose(fp); + } +#endif + // Hardcode this for now + bSwp = true; + bHalf = true; + bThumb = false; + bFastMult = true; + bVFP = true; + bEDSP = true; + bThumbEE = isVFP3; + bNEON = isVFP3; + bVFPv3 = isVFP3; + bTLS = true; + bVFPv4 = isVFP4; + bIDIVa = isVFP4; + bIDIVt = isVFP4; + bFP = false; + bASIMD = false; +#else + strncpy(cpu_string, GetCPUString(), sizeof(cpu_string)); bSwp = CheckCPUFeature("swp"); bHalf = CheckCPUFeature("half"); bThumb = CheckCPUFeature("thumb"); @@ -172,16 +235,15 @@ void CPUInfo::Detect() bVFPv4 = CheckCPUFeature("vfpv4"); bIDIVa = CheckCPUFeature("idiva"); bIDIVt = CheckCPUFeature("idivt"); - // Qualcomm Krait supports IDIVA but it doesn't report it. Check for krait. if (GetCPUImplementer() == 0x51 && GetCPUPart() == 0x6F) // Krait(300) is 0x6F, Scorpion is 0x4D - bIDIVa = bIDIVt = true; - - // These two are ARMv8 specific. + bIDIVa = bIDIVt = true; + // These two require ARMv8 or higher bFP = CheckCPUFeature("fp"); bASIMD = CheckCPUFeature("asimd"); - - +#endif +// On android, we build a separate library for ARMv7 so this is fine. +// TODO: Check for ARMv7 on other platforms. #if defined(__ARM_ARCH_7A__) bArmV7 = true; #else @@ -193,11 +255,14 @@ void CPUInfo::Detect() std::string CPUInfo::Summarize() { std::string sum; +#if defined(BLACKBERRY) || defined(IOS) || defined(__SYMBIAN32__) + sum = StringFromFormat("%i cores", num_cores); +#else if (num_cores == 1) sum = StringFromFormat("%s, %i core", cpu_string, num_cores); else sum = StringFromFormat("%s, %i cores", cpu_string, num_cores); - +#endif if (bSwp) sum += ", SWP"; if (bHalf) sum += ", Half"; if (bThumb) sum += ", Thumb"; |
