summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/ArmCPUDetect.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2013-03-27 13:19:23 +1100
committerskidau <skidau@gmail.com>2013-03-27 13:19:23 +1100
commit7784fa4c67cc8d2545f45694d83805e7e89cd583 (patch)
tree7724133aabe971ec417d1dea0977a525bb8debfb /Source/Core/Common/Src/ArmCPUDetect.cpp
parentd33c19b0cd2bae982c8d35e86a9d3551f9e5c72f (diff)
parent5cea0d9defeaa23e7af94adf7615a44fb2c9c173 (diff)
Merge branch 'master' into wii-network
# By Ryan Houdek (185) and others # Via degasus (12) and others * master: (625 commits) Revert "Don't open/close file for every file operation." as it was crashing PokePark in Windows builds. Array overrun fixed in VertexShaderCache for the DX11 plugin. Fixed DSPTool build. Windows build fix Go back to assuming every HID device is a wiimote on Windows. Fixed issue 6117. Unfixed issue 6031. VideoSoftware: Improve fog range adjustment by using less magic and more comments. revert RasterFont for VideoSoftware ogl: fix virtual xfb Windows build fix from web interface... Adjusted the audio loop criteria, using >= on the Wii and == on GC. This fixes the audio static that occurred in Wii games after hours of play. Forced the exception check only for ARAM DMA transfers. Removed the Eternal Darkness boot hack and replaced it with an exception check. VideoSoftware: Implement fog range adjustment, fixing issue 6147. implement 4xSSAA for OGL move ogl-only settings into backend Fix description of disable fog, and move it to enhancements tab. Reverted rd76ca5783743 as it was made obsolete by r1d550f4496e4. Removed the tracking of the FIFO Writes as it was made obsolete by r1d550f4496e4. Forced the external exception check to occur sooner by changing the downcount. Mark the Direct3D9 backend deprecated. Prefer D3D11 and OpenGL over D3D9 by default. ... Conflicts: CMakeLists.txt Source/Core/Common/Common.vcxproj.filters Source/Core/Common/Src/CommonPaths.h Source/Core/Core/Core.vcxproj.filters Source/Core/Core/Src/Core.cpp Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp Source/VSProps/Dolphin.Win32.props Source/VSProps/Dolphin.x64.props
Diffstat (limited to 'Source/Core/Common/Src/ArmCPUDetect.cpp')
-rw-r--r--Source/Core/Common/Src/ArmCPUDetect.cpp167
1 files changed, 167 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/ArmCPUDetect.cpp b/Source/Core/Common/Src/ArmCPUDetect.cpp
new file mode 100644
index 0000000000..33eee9f05e
--- /dev/null
+++ b/Source/Core/Common/Src/ArmCPUDetect.cpp
@@ -0,0 +1,167 @@
+// Copyright (C) 2003 Dolphin Project.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 2.0.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License 2.0 for more details.
+
+// A copy of the GPL 2.0 should have been included with the program.
+// If not, see http://www.gnu.org/licenses/
+
+// Official SVN repository and contact information can be found at
+// http://code.google.com/p/dolphin-emu/
+
+#include "Common.h"
+#include "CPUDetect.h"
+#include "StringUtil.h"
+#include "FileUtil.h"
+
+const char procfile[] = "/proc/cpuinfo";
+
+char *GetCPUString()
+{
+ const char marker[] = "Hardware\t: ";
+ char *cpu_string = 0;
+ // Count the number of processor lines in /proc/cpuinfo
+ char buf[1024];
+
+ File::IOFile file(procfile, "r");
+ auto const fp = file.GetHandle();
+ if (!fp)
+ return 0;
+
+ while (fgets(buf, sizeof(buf), fp))
+ {
+ if (strncmp(buf, marker, sizeof(marker) - 1))
+ continue;
+ cpu_string = buf + sizeof(marker) - 1;
+ cpu_string = strndup(cpu_string, strlen(cpu_string) - 1); // Strip the newline
+ break;
+ }
+ return cpu_string;
+}
+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)
+ return 0;
+
+ while (fgets(buf, sizeof(buf), fp))
+ {
+ if (strncmp(buf, marker, sizeof(marker) - 1))
+ continue;
+ char *featurestring = buf + sizeof(marker) - 1;
+ char *token = strtok(featurestring, " ");
+ while (token != NULL)
+ {
+ if (strstr(token, feature))
+ return true;
+ token = strtok(NULL, " ");
+ }
+ }
+ return false;
+}
+int GetCoreCount()
+{
+ const char marker[] = "processor\t: ";
+ int cores = 0;
+ char buf[1024];
+
+ File::IOFile file(procfile, "r");
+ 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;
+}
+
+CPUInfo cpu_info;
+
+CPUInfo::CPUInfo() {
+ Detect();
+}
+
+// Detects the various cpu features
+void CPUInfo::Detect()
+{
+ // Set some defaults here
+ // When ARMv8 cpus come out, these need to be updated.
+ HTT = false;
+ OS64bit = false;
+ CPU64bit = false;
+ Mode64bit = false;
+ vendor = VENDOR_ARM;
+
+ // Get the information about the CPU
+ strncpy(cpu_string, GetCPUString(), sizeof(cpu_string));
+ num_cores = GetCoreCount();
+ bSwp = CheckCPUFeature("swp");
+ bHalf = CheckCPUFeature("half");
+ bThumb = CheckCPUFeature("thumb");
+ bFastMult = CheckCPUFeature("fastmult");
+ bVFP = CheckCPUFeature("vfp");
+ bEDSP = CheckCPUFeature("edsp");
+ bThumbEE = CheckCPUFeature("thumbee");
+ bNEON = CheckCPUFeature("neon");
+ bVFPv3 = CheckCPUFeature("vfpv3");
+ bTLS = CheckCPUFeature("tls");
+ bVFPv4 = CheckCPUFeature("vfpv4");
+ bIDIVa = CheckCPUFeature("idiva");
+ bIDIVt = CheckCPUFeature("idivt");
+
+ // On some buggy kernels(Qualcomm) they show that they support VFPv4 but not IDIVa
+ // All VFPv4 CPUs will support IDIVa
+ if (bVFPv4)
+ bIDIVa = bIDIVt = true;
+
+ // These two are ARMv8 specific.
+ bFP = CheckCPUFeature("fp");
+ bASIMD = CheckCPUFeature("asimd");
+
+
+#if defined(__ARM_ARCH_7A__)
+ bArmV7 = true;
+#else
+ bArmV7 = false;
+#endif
+}
+
+// Turn the cpu info into a string we can show
+std::string CPUInfo::Summarize()
+{
+ std::string sum;
+ if (num_cores == 1)
+ sum = StringFromFormat("%s, %i core", cpu_string, num_cores);
+ else
+ sum = StringFromFormat("%s, %i cores", cpu_string, num_cores);
+
+ if (bSwp) sum += ", SWP";
+ if (bHalf) sum += ", Half";
+ if (bThumb) sum += ", Thumb";
+ if (bFastMult) sum += ", FastMult";
+ if (bVFP) sum += ", VFP";
+ if (bEDSP) sum += ", EDSP";
+ if (bThumbEE) sum += ", ThumbEE";
+ if (bNEON) sum += ", NEON";
+ if (bVFPv3) sum += ", VFPv3";
+ if (bTLS) sum += ", TLS";
+ if (bVFPv4) sum += ", VFPv4";
+ if (bIDIVa) sum += ", IDIVa";
+ if (bIDIVt) sum += ", IDIVt";
+
+ return sum;
+}