Implementation for Intel Core i7 temperature sensors.
authormoel.mich
Wed, 27 Jan 2010 23:00:13 +0000
changeset 45d81d4a63965
parent 3 1a0928afac6b
child 5 a5ecd988d38f
Implementation for Intel Core i7 temperature sensors.
Hardware/CPU/IntelCPU.cs
     1.1 --- a/Hardware/CPU/IntelCPU.cs	Wed Jan 27 19:30:10 2010 +0000
     1.2 +++ b/Hardware/CPU/IntelCPU.cs	Wed Jan 27 23:00:13 2010 +0000
     1.3 @@ -52,6 +52,7 @@
     1.4      private float tjMax = 0;   
     1.5  
     1.6      private const uint IA32_THERM_STATUS_MSR = 0x019C;
     1.7 +    private const uint IA32_TEMPERATURE_TARGET = 0x01A2;
     1.8  
     1.9      public IntelCPU(string name, uint family, uint model, uint stepping, 
    1.10        uint[,] cpuidData, uint[,] cpuidExtData) {
    1.11 @@ -59,9 +60,17 @@
    1.12        this.name = name;
    1.13        this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
    1.14        
    1.15 -      uint coreCount = 1;
    1.16 -      if (cpuidData.GetLength(0) > 4)
    1.17 -        coreCount = ((cpuidData[4, 0] >> 26) & 0x3F) + 1;
    1.18 +      uint logicalProcessors = 1;
    1.19 +      if (cpuidData.GetLength(0) > 0x04)
    1.20 +        logicalProcessors = ((cpuidData[4, 0] >> 26) & 0x3F) + 1;
    1.21 +
    1.22 +      uint logicalProcessorsPerCore = 1;
    1.23 +      if (cpuidData.GetLength(0) > 0x0B)
    1.24 +        logicalProcessorsPerCore = cpuidData[0x0B, 1] & 0xFF;
    1.25 +      if (logicalProcessorsPerCore == 0)
    1.26 +        logicalProcessorsPerCore = 1;
    1.27 +
    1.28 +      uint coreCount = logicalProcessors / logicalProcessorsPerCore;
    1.29  
    1.30        switch (family) {
    1.31          case 0x06: {
    1.32 @@ -84,11 +93,19 @@
    1.33                    tjMax = 85; break;
    1.34                  default:
    1.35                    tjMax = 85; break;
    1.36 -              } break;
    1.37 -            case 0x1c: // Intel Atom 
    1.38 -              tjMax = 90; break;
    1.39 +              } break;            
    1.40              case 0x17: // Intel Core 45nm
    1.41                tjMax = 100; break;
    1.42 +            case 0x1C: // Intel Atom 
    1.43 +              tjMax = 90; break;
    1.44 +            case 0x1A:
    1.45 +              uint eax = 0, edx = 0;
    1.46 +              if (WinRing0.RdmsrPx(
    1.47 +                  IA32_TEMPERATURE_TARGET, ref eax, ref edx, (UIntPtr)1)) {
    1.48 +                tjMax = (eax >> 16) & 0xFF;
    1.49 +              } else
    1.50 +                tjMax = 100;
    1.51 +              break;
    1.52              default:
    1.53                tjMax = 100; break;
    1.54            }