Added a missing default case in the mainboard specific configuration selection. The missing default case prevented sensor data from getting displayed on unknown Asus mainboards with NCT6779D super I/O.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2011 Michael Möller <mmoeller@openhardwaremonitor.org>
12 using System.Collections.Generic;
13 using System.Globalization;
16 namespace OpenHardwareMonitor.Hardware.CPU {
18 internal class CPUGroup : IGroup {
19 private readonly List<GenericCPU> hardware = new List<GenericCPU>();
21 private readonly CPUID[][][] threads;
23 private static CPUID[][] GetProcessorThreads() {
25 List<CPUID> threads = new List<CPUID>();
26 for (int i = 0; i < 32; i++) {
28 threads.Add(new CPUID(i));
29 } catch (ArgumentOutOfRangeException) { }
32 SortedDictionary<uint, List<CPUID>> processors =
33 new SortedDictionary<uint, List<CPUID>>();
34 foreach (CPUID thread in threads) {
36 processors.TryGetValue(thread.ProcessorId, out list);
38 list = new List<CPUID>();
39 processors.Add(thread.ProcessorId, list);
44 CPUID[][] processorThreads = new CPUID[processors.Count][];
46 foreach (List<CPUID> list in processors.Values) {
47 processorThreads[index] = list.ToArray();
50 return processorThreads;
53 private static CPUID[][] GroupThreadsByCore(IEnumerable<CPUID> threads) {
55 SortedDictionary<uint, List<CPUID>> cores =
56 new SortedDictionary<uint, List<CPUID>>();
57 foreach (CPUID thread in threads) {
59 cores.TryGetValue(thread.CoreId, out coreList);
60 if (coreList == null) {
61 coreList = new List<CPUID>();
62 cores.Add(thread.CoreId, coreList);
67 CPUID[][] coreThreads = new CPUID[cores.Count][];
69 foreach (List<CPUID> list in cores.Values) {
70 coreThreads[index] = list.ToArray();
76 public CPUGroup(ISettings settings) {
78 CPUID[][] processorThreads = GetProcessorThreads();
79 this.threads = new CPUID[processorThreads.Length][][];
82 foreach (CPUID[] threads in processorThreads) {
83 if (threads.Length == 0)
86 CPUID[][] coreThreads = GroupThreadsByCore(threads);
88 this.threads[index] = coreThreads;
90 switch (threads[0].Vendor) {
92 hardware.Add(new IntelCPU(index, coreThreads, settings));
95 switch (threads[0].Family) {
97 hardware.Add(new AMD0FCPU(index, coreThreads, settings));
104 hardware.Add(new AMD10CPU(index, coreThreads, settings));
107 hardware.Add(new GenericCPU(index, coreThreads, settings));
111 hardware.Add(new GenericCPU(index, coreThreads, settings));
119 public IHardware[] Hardware {
121 return hardware.ToArray();
125 private static void AppendCpuidData(StringBuilder r, uint[,] data,
128 for (int i = 0; i < data.GetLength(0); i++) {
130 r.Append((i + offset).ToString("X8", CultureInfo.InvariantCulture));
131 for (int j = 0; j < 4; j++) {
133 r.Append(data[i, j].ToString("X8", CultureInfo.InvariantCulture));
139 public string GetReport() {
143 StringBuilder r = new StringBuilder();
145 r.AppendLine("CPUID");
148 for (int i = 0; i < threads.Length; i++) {
150 r.AppendLine("Processor " + i);
152 r.AppendFormat("Processor Vendor: {0}{1}", threads[i][0][0].Vendor,
153 Environment.NewLine);
154 r.AppendFormat("Processor Brand: {0}{1}", threads[i][0][0].BrandString,
155 Environment.NewLine);
156 r.AppendFormat("Family: 0x{0}{1}",
157 threads[i][0][0].Family.ToString("X", CultureInfo.InvariantCulture),
158 Environment.NewLine);
159 r.AppendFormat("Model: 0x{0}{1}",
160 threads[i][0][0].Model.ToString("X", CultureInfo.InvariantCulture),
161 Environment.NewLine);
162 r.AppendFormat("Stepping: 0x{0}{1}",
163 threads[i][0][0].Stepping.ToString("X", CultureInfo.InvariantCulture),
164 Environment.NewLine);
167 r.AppendLine("CPUID Return Values");
169 for (int j = 0; j < threads[i].Length; j++)
170 for (int k = 0; k < threads[i][j].Length; k++) {
171 r.AppendLine(" CPU Thread: " + threads[i][j][k].Thread);
172 r.AppendLine(" APIC ID: " + threads[i][j][k].ApicId);
173 r.AppendLine(" Processor ID: " + threads[i][j][k].ProcessorId);
174 r.AppendLine(" Core ID: " + threads[i][j][k].CoreId);
175 r.AppendLine(" Thread ID: " + threads[i][j][k].ThreadId);
177 r.AppendLine(" Function EAX EBX ECX EDX");
178 AppendCpuidData(r, threads[i][j][k].Data, CPUID.CPUID_0);
179 AppendCpuidData(r, threads[i][j][k].ExtData, CPUID.CPUID_EXT);
186 public void Close() {
187 foreach (GenericCPU cpu in hardware) {