[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / utils / CPUInfo.h
blobe11384e8a5f38519b4179864ea190f9acc7682d2
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "threads/SystemClock.h"
12 #include "utils/Temperature.h"
14 #include <chrono>
15 #include <memory>
16 #include <string>
17 #include <vector>
19 enum CpuFeature
21 CPU_FEATURE_MMX = 1 << 0,
22 CPU_FEATURE_MMX2 = 1 << 1,
23 CPU_FEATURE_SSE = 1 << 2,
24 CPU_FEATURE_SSE2 = 1 << 3,
25 CPU_FEATURE_SSE3 = 1 << 4,
26 CPU_FEATURE_SSSE3 = 1 << 5,
27 CPU_FEATURE_SSE4 = 1 << 6,
28 CPU_FEATURE_SSE42 = 1 << 7,
29 CPU_FEATURE_3DNOW = 1 << 8,
30 CPU_FEATURE_3DNOWEXT = 1 << 9,
31 CPU_FEATURE_ALTIVEC = 1 << 10,
32 CPU_FEATURE_NEON = 1 << 11,
35 struct CoreInfo
37 int m_id = 0;
38 double m_usagePercent = 0.0;
39 std::size_t m_activeTime = 0;
40 std::size_t m_idleTime = 0;
41 std::size_t m_totalTime = 0;
44 class CCPUInfo
46 public:
47 // Defines to help with calls to CPUID
48 const unsigned int CPUID_INFOTYPE_MANUFACTURER = 0x00000000;
49 const unsigned int CPUID_INFOTYPE_STANDARD = 0x00000001;
50 const unsigned int CPUID_INFOTYPE_EXTENDED_IMPLEMENTED = 0x80000000;
51 const unsigned int CPUID_INFOTYPE_EXTENDED = 0x80000001;
52 const unsigned int CPUID_INFOTYPE_PROCESSOR_1 = 0x80000002;
53 const unsigned int CPUID_INFOTYPE_PROCESSOR_2 = 0x80000003;
54 const unsigned int CPUID_INFOTYPE_PROCESSOR_3 = 0x80000004;
56 // Standard Features
57 // Bitmasks for the values returned by a call to cpuid with eax=0x00000001
58 const unsigned int CPUID_00000001_ECX_SSE3 = (1 << 0);
59 const unsigned int CPUID_00000001_ECX_SSSE3 = (1 << 9);
60 const unsigned int CPUID_00000001_ECX_SSE4 = (1 << 19);
61 const unsigned int CPUID_00000001_ECX_SSE42 = (1 << 20);
63 const unsigned int CPUID_00000001_EDX_MMX = (1 << 23);
64 const unsigned int CPUID_00000001_EDX_SSE = (1 << 25);
65 const unsigned int CPUID_00000001_EDX_SSE2 = (1 << 26);
67 // Extended Features
68 // Bitmasks for the values returned by a call to cpuid with eax=0x80000001
69 const unsigned int CPUID_80000001_EDX_MMX2 = (1 << 22);
70 const unsigned int CPUID_80000001_EDX_MMX = (1 << 23);
71 const unsigned int CPUID_80000001_EDX_3DNOWEXT = (1 << 30);
72 const unsigned int CPUID_80000001_EDX_3DNOW = (1U << 31);
74 // In milliseconds
75 const std::chrono::milliseconds MINIMUM_TIME_BETWEEN_READS{500};
77 static std::shared_ptr<CCPUInfo> GetCPUInfo();
79 virtual bool SupportsCPUUsage() const { return true; }
81 virtual int GetUsedPercentage() = 0;
82 virtual float GetCPUFrequency() = 0;
83 virtual bool GetTemperature(CTemperature& temperature) = 0;
85 bool HasCoreId(int coreId) const;
86 const CoreInfo GetCoreInfo(int coreId);
87 std::string GetCoresUsageString();
89 unsigned int GetCPUFeatures() const { return m_cpuFeatures; }
90 int GetCPUCount() const { return m_cpuCount; }
91 std::string GetCPUModel() { return m_cpuModel; }
92 std::string GetCPUBogoMips() { return m_cpuBogoMips; }
93 std::string GetCPUSoC() { return m_cpuSoC; }
94 std::string GetCPUHardware() { return m_cpuHardware; }
95 std::string GetCPURevision() { return m_cpuRevision; }
96 std::string GetCPUSerial() { return m_cpuSerial; }
98 protected:
99 CCPUInfo() = default;
100 virtual ~CCPUInfo() = default;
102 int m_lastUsedPercentage;
103 XbmcThreads::EndTime<> m_nextUsedReadTime;
104 std::string m_cpuVendor;
105 std::string m_cpuModel;
106 std::string m_cpuBogoMips;
107 std::string m_cpuSoC;
108 std::string m_cpuHardware;
109 std::string m_cpuRevision;
110 std::string m_cpuSerial;
112 double m_usagePercent{0.0};
113 std::size_t m_activeTime{0};
114 std::size_t m_idleTime{0};
115 std::size_t m_totalTime{0};
117 int m_cpuCount;
118 unsigned int m_cpuFeatures;
120 std::vector<CoreInfo> m_cores;