Added a processorIndex to CPU classes for multi CPU support.

This commit is contained in:
Michael Möller
2010-04-26 18:51:22 +00:00
parent 7232b41e02
commit 540d615641
4 changed files with 19 additions and 13 deletions

View File

@@ -48,6 +48,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private string name; private string name;
private Image icon; private Image icon;
private int processorIndex;
private uint pciAddress; private uint pciAddress;
private Sensor[] coreTemperatures; private Sensor[] coreTemperatures;
@@ -63,8 +64,9 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private const byte THERM_SENSE_CORE_SEL_CPU0 = 0x4; private const byte THERM_SENSE_CORE_SEL_CPU0 = 0x4;
private const byte THERM_SENSE_CORE_SEL_CPU1 = 0x0; private const byte THERM_SENSE_CORE_SEL_CPU1 = 0x0;
public AMD0FCPU(CPUID[][] cpuid) { public AMD0FCPU(int processorIndex, CPUID[][] cpuid) {
this.processorIndex = processorIndex;
this.name = cpuid[0][0].Name; this.name = cpuid[0][0].Name;
this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
@@ -110,7 +112,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
} }
pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID,
PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID, 0); PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex);
Update(); Update();
} }
@@ -120,7 +122,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
} }
public string Identifier { public string Identifier {
get { return "/amdcpu/0"; } get { return "/amdcpu/" + processorIndex; }
} }
public Image Icon { public Image Icon {

View File

@@ -47,6 +47,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private string name; private string name;
private Image icon; private Image icon;
private int processorIndex;
private uint pciAddress; private uint pciAddress;
private Sensor coreTemperature; private Sensor coreTemperature;
@@ -60,8 +61,9 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private const ushort PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID = 0x1303; private const ushort PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID = 0x1303;
private const uint REPORTED_TEMPERATURE_CONTROL_REGISTER = 0xA4; private const uint REPORTED_TEMPERATURE_CONTROL_REGISTER = 0xA4;
public AMD10CPU(CPUID[][] cpuid) { public AMD10CPU(int processorIndex, CPUID[][] cpuid) {
this.processorIndex = processorIndex;
this.name = cpuid[0][0].Name; this.name = cpuid[0][0].Name;
this.icon = Utilities.EmbeddedResources.GetImage("cpu.png"); this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
@@ -89,10 +91,10 @@ namespace OpenHardwareMonitor.Hardware.CPU {
}); });
pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID,
PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, 0); PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex);
if (pciAddress == 0xFFFFFFFF) if (pciAddress == 0xFFFFFFFF)
pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID,
PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID, 0); PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex);
Update(); Update();
} }
@@ -102,7 +104,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
} }
public string Identifier { public string Identifier {
get { return "/amdcpu/0"; } get { return "/amdcpu/" + processorIndex; }
} }
public Image Icon { public Image Icon {

View File

@@ -119,15 +119,15 @@ namespace OpenHardwareMonitor.Hardware.CPU {
switch (threads[0].Vendor) { switch (threads[0].Vendor) {
case Vendor.Intel: case Vendor.Intel:
hardware.Add(new IntelCPU(coreThreads)); hardware.Add(new IntelCPU(index, coreThreads));
break; break;
case Vendor.AMD: case Vendor.AMD:
switch (threads[0].Family) { switch (threads[0].Family) {
case 0x0F: case 0x0F:
hardware.Add(new AMD0FCPU(coreThreads)); hardware.Add(new AMD0FCPU(index, coreThreads));
break; break;
case 0x10: case 0x10:
hardware.Add(new AMD10CPU(coreThreads)); hardware.Add(new AMD10CPU(index, coreThreads));
break; break;
default: default:
break; break;

View File

@@ -48,6 +48,7 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
public class IntelCPU : Hardware, IHardware { public class IntelCPU : Hardware, IHardware {
private int processorIndex;
private CPUID[][] cpuid; private CPUID[][] cpuid;
private int coreCount; private int coreCount;
@@ -93,8 +94,9 @@ namespace OpenHardwareMonitor.Hardware.CPU {
return result; return result;
} }
public IntelCPU(CPUID[][] cpuid) { public IntelCPU(int processorIndex, CPUID[][] cpuid) {
this.processorIndex = processorIndex;
this.cpuid = cpuid; this.cpuid = cpuid;
this.coreCount = cpuid.Length; this.coreCount = cpuid.Length;
this.name = cpuid[0][0].Name; this.name = cpuid[0][0].Name;
@@ -236,7 +238,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
} }
public string Identifier { public string Identifier {
get { return "/intelcpu/0"; } get { return "/intelcpu/" + processorIndex; }
} }
public Image Icon { public Image Icon {