Fixed Intel CPU coreCount in case CPUID 0x0B is supported but returns only 0.
authormoel.mich
Wed, 03 Feb 2010 18:10:11 +0000
changeset 231662dea7a261
parent 22 e6832d4b89d2
child 24 09ab31bee6bd
Fixed Intel CPU coreCount in case CPUID 0x0B is supported but returns only 0.
Hardware/CPU/IntelCPU.cs
     1.1 --- a/Hardware/CPU/IntelCPU.cs	Tue Feb 02 21:58:54 2010 +0000
     1.2 +++ b/Hardware/CPU/IntelCPU.cs	Wed Feb 03 18:10:11 2010 +0000
     1.3 @@ -63,17 +63,21 @@
     1.4        this.name = name;
     1.5        this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
     1.6              
     1.7 -      logicalProcessorsPerCore = 1;
     1.8 +      logicalProcessors = 0;
     1.9        if (cpuidData.GetLength(0) > 0x0B) {
    1.10          uint eax, ebx, ecx, edx;
    1.11          WinRing0.CpuidEx(0x0B, 0, out eax, out ebx, out ecx, out edx);
    1.12 -        logicalProcessorsPerCore = ebx & 0xFF; 
    1.13 -        WinRing0.CpuidEx(0x0B, 1, out eax, out ebx, out ecx, out edx);
    1.14 -        logicalProcessors = ebx & 0xFF;            
    1.15 -      } else if (cpuidData.GetLength(0) > 0x04) {
    1.16 +        logicalProcessorsPerCore = ebx & 0xFF;
    1.17 +        if (logicalProcessorsPerCore > 0) {
    1.18 +          WinRing0.CpuidEx(0x0B, 1, out eax, out ebx, out ecx, out edx);
    1.19 +          logicalProcessors = ebx & 0xFF;
    1.20 +        }   
    1.21 +      }
    1.22 +      if (logicalProcessors <= 0 && cpuidData.GetLength(0) > 0x04) {
    1.23          logicalProcessors = ((cpuidData[4, 0] >> 26) & 0x3F) + 1;
    1.24          logicalProcessorsPerCore = 1;
    1.25 -      } else {
    1.26 +      }
    1.27 +      if (logicalProcessors <= 0) {
    1.28          logicalProcessors = 1;
    1.29          logicalProcessorsPerCore = 1;
    1.30        }