Hardware/LPC/LPCGroup.cs
changeset 67 bb5696abab23
parent 60 0e62c377c08c
child 68 d706e16a79c0
     1.1 --- a/Hardware/LPC/LPCGroup.cs	Sun Feb 28 16:12:55 2010 +0000
     1.2 +++ b/Hardware/LPC/LPCGroup.cs	Mon Mar 01 22:12:29 2010 +0000
     1.3 @@ -42,7 +42,9 @@
     1.4  
     1.5  namespace OpenHardwareMonitor.Hardware.LPC {
     1.6    public class LPCGroup : IGroup {
     1.7 +
     1.8      private List<IHardware> hardware = new List<IHardware>();
     1.9 +    private StringBuilder report = new StringBuilder();
    1.10  
    1.11      private Chip chip = Chip.Unknown;
    1.12  
    1.13 @@ -108,6 +110,15 @@
    1.14        WinRing0.WriteIoPortByte(registerPort, 0xAA);      
    1.15      }
    1.16  
    1.17 +    // SMSC
    1.18 +    private void SMSCEnter() {
    1.19 +      WinRing0.WriteIoPortByte(registerPort, 0x55);
    1.20 +    }
    1.21 +
    1.22 +    private void SMSCExit() {
    1.23 +      WinRing0.WriteIoPortByte(registerPort, 0xAA);
    1.24 +    }
    1.25 +
    1.26      public LPCGroup() {
    1.27        if (!WinRing0.IsAvailable)
    1.28          return;
    1.29 @@ -167,6 +178,13 @@
    1.30                  logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
    1.31                  break;
    1.32              } break;
    1.33 +          case 0x85:
    1.34 +            switch (revision) {
    1.35 +              case 0x41:
    1.36 +                chip = Chip.W83687THF;
    1.37 +                logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
    1.38 +                break;
    1.39 +            } break;
    1.40            case 0x88:
    1.41              switch (revision & 0xF0) {
    1.42                case 0x60:
    1.43 @@ -203,7 +221,15 @@
    1.44                  break;
    1.45              } break; 
    1.46          }
    1.47 -        if (chip != Chip.Unknown) {
    1.48 +        if (chip == Chip.Unknown) {
    1.49 +          if (id != 0 && id != 0xff) {
    1.50 +            WinbondFintekExit();
    1.51 +
    1.52 +            report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x"); 
    1.53 +            report.AppendLine(((id << 8) | revision).ToString("X"));
    1.54 +            report.AppendLine();
    1.55 +          }
    1.56 +        } else {
    1.57  
    1.58            Select(logicalDeviceNumber);
    1.59            ushort address = ReadWord(BASE_ADDRESS_REGISTER);          
    1.60 @@ -216,16 +242,31 @@
    1.61  
    1.62            WinbondFintekExit();
    1.63  
    1.64 -          if (address != verify)
    1.65 +          if (address != verify) {            
    1.66 +            report.Append("Chip ID: 0x"); 
    1.67 +            report.AppendLine(chip.ToString("X"));
    1.68 +            report.Append("Chip revision: 0x"); 
    1.69 +            report.AppendLine(revision.ToString("X"));
    1.70 +            report.AppendLine("Error: Address verification failed");
    1.71 +            report.AppendLine();
    1.72              return;
    1.73 +          }
    1.74  
    1.75            // some Fintek chips have address register offset 0x05 added already
    1.76            if ((address & 0x07) == 0x05)
    1.77              address &= 0xFFF8;
    1.78  
    1.79 -          if (address < 0x100 || (address & 0xF007) != 0)
    1.80 +          if (address < 0x100 || (address & 0xF007) != 0) {            
    1.81 +            report.Append("Chip ID: 0x");
    1.82 +            report.AppendLine(chip.ToString("X"));
    1.83 +            report.Append("Chip revision: 0x");
    1.84 +            report.AppendLine(revision.ToString("X"));
    1.85 +            report.Append("Error: Invalid address 0x");
    1.86 +            report.AppendLine(address.ToString("X"));
    1.87 +            report.AppendLine();
    1.88              return;
    1.89 -          
    1.90 +          }
    1.91 +
    1.92            switch (chip) {
    1.93              case Chip.W83627DHG:
    1.94              case Chip.W83627DHGP:
    1.95 @@ -234,6 +275,7 @@
    1.96              case Chip.W83627THF:
    1.97              case Chip.W83667HG:
    1.98              case Chip.W83667HGB:
    1.99 +            case Chip.W83687THF:
   1.100                W836XX w836XX = new W836XX(chip, revision, address);
   1.101                if (w836XX.IsAvailable)
   1.102                  hardware.Add(w836XX);
   1.103 @@ -255,15 +297,23 @@
   1.104  
   1.105          IT87Enter();
   1.106  
   1.107 -        switch (ReadWord(CHIP_ID_REGISTER)) {
   1.108 +        ushort chipID = ReadWord(CHIP_ID_REGISTER);
   1.109 +        switch (chipID) {
   1.110            case 0x8716: chip = Chip.IT8716F; break;
   1.111            case 0x8718: chip = Chip.IT8718F; break;
   1.112            case 0x8720: chip = Chip.IT8720F; break;
   1.113 -          case 0x8726: chip = Chip.IT8726F; break;
   1.114 +          case 0x8726: chip = Chip.IT8726F; break; 
   1.115            default: chip = Chip.Unknown; break;
   1.116          }
   1.117 +        if (chip == Chip.Unknown) {
   1.118 +          if (chipID != 0 && chipID != 0xffff) {
   1.119 +            IT87Exit();
   1.120  
   1.121 -        if (chip != Chip.Unknown) {
   1.122 +            report.Append("Chip ID: Unknown ITE with ID 0x");
   1.123 +            report.AppendLine(chipID.ToString("X"));
   1.124 +            report.AppendLine();
   1.125 +          }
   1.126 +        } else {
   1.127            Select(IT87_ENVIRONMENT_CONTROLLER_LDN);
   1.128            ushort address = ReadWord(BASE_ADDRESS_REGISTER);
   1.129            Thread.Sleep(1);
   1.130 @@ -271,8 +321,14 @@
   1.131  
   1.132            IT87Exit();
   1.133  
   1.134 -          if (address != verify || address < 0x100 || (address & 0xF007) != 0)
   1.135 +          if (address != verify || address < 0x100 || (address & 0xF007) != 0) {
   1.136 +            report.Append("Chip ID: 0x");
   1.137 +            report.AppendLine(chip.ToString("X"));            
   1.138 +            report.Append("Error: Invalid address 0x");
   1.139 +            report.AppendLine(address.ToString("X"));
   1.140 +            report.AppendLine();
   1.141              return;
   1.142 +          }
   1.143  
   1.144            IT87XX it87 = new IT87XX(chip, address);
   1.145            if (it87.IsAvailable)
   1.146 @@ -280,6 +336,26 @@
   1.147  
   1.148            return;
   1.149          }
   1.150 +
   1.151 +        SMSCEnter();
   1.152 +
   1.153 +        chipID = ReadWord(CHIP_ID_REGISTER);
   1.154 +        switch (chipID) {
   1.155 +          default: chip = Chip.Unknown; break;
   1.156 +        }
   1.157 +        if (chip == Chip.Unknown) {
   1.158 +          if (chipID != 0 && chipID != 0xffff) {
   1.159 +            SMSCExit();
   1.160 +
   1.161 +            report.Append("Chip ID: Unknown SMSC with ID 0x");
   1.162 +            report.AppendLine(chipID.ToString("X"));
   1.163 +            report.AppendLine();
   1.164 +          }
   1.165 +        } else {
   1.166 +          SMSCExit();
   1.167 +
   1.168 +          return;
   1.169 +        }
   1.170        }   
   1.171      }
   1.172  
   1.173 @@ -290,7 +366,12 @@
   1.174      }
   1.175  
   1.176      public string GetReport() {
   1.177 -      return null;
   1.178 +      if (report.Length > 0) {
   1.179 +        report.Insert(0, "LPCIO" + Environment.NewLine +
   1.180 +          Environment.NewLine);        
   1.181 +        return report.ToString();
   1.182 +      } else
   1.183 +        return null;
   1.184      }
   1.185  
   1.186      public void Close() { }