Hardware/LPC/LPCIO.cs
changeset 228 458a6c3de579
parent 195 0ee888c485d5
child 236 763675f19ff4
     1.1 --- a/Hardware/LPC/LPCIO.cs	Sun Oct 17 08:21:33 2010 +0000
     1.2 +++ b/Hardware/LPC/LPCIO.cs	Sun Oct 17 16:04:19 2010 +0000
     1.3 @@ -64,10 +64,10 @@
     1.4      private byte ReadByte(byte register) {
     1.5        WinRing0.WriteIoPortByte(registerPort, register);
     1.6        return WinRing0.ReadIoPortByte(valuePort);
     1.7 -    } 
     1.8 +    }
     1.9  
    1.10      private ushort ReadWord(byte register) {
    1.11 -      return (ushort)((ReadByte(register) << 8) | 
    1.12 +      return (ushort)((ReadByte(register) << 8) |
    1.13          ReadByte((byte)(register + 1)));
    1.14      }
    1.15  
    1.16 @@ -218,7 +218,7 @@
    1.17          if (id != 0 && id != 0xff) {
    1.18            WinbondFintekExit();
    1.19  
    1.20 -          ReportUnknownChip("Winbond / Fintek", ((id << 8) | revision));         
    1.21 +          ReportUnknownChip("Winbond / Fintek", ((id << 8) | revision));
    1.22          }
    1.23        } else {
    1.24  
    1.25 @@ -235,7 +235,7 @@
    1.26            report.Append("Chip ID: 0x");
    1.27            report.AppendLine(chip.ToString("X"));
    1.28            report.Append("Chip revision: 0x");
    1.29 -          report.AppendLine(revision.ToString("X", 
    1.30 +          report.AppendLine(revision.ToString("X",
    1.31              CultureInfo.InvariantCulture));
    1.32            report.AppendLine("Error: Address verification failed");
    1.33            report.AppendLine();
    1.34 @@ -250,10 +250,10 @@
    1.35            report.Append("Chip ID: 0x");
    1.36            report.AppendLine(chip.ToString("X"));
    1.37            report.Append("Chip revision: 0x");
    1.38 -          report.AppendLine(revision.ToString("X", 
    1.39 +          report.AppendLine(revision.ToString("X",
    1.40              CultureInfo.InvariantCulture));
    1.41            report.Append("Error: Invalid address 0x");
    1.42 -          report.AppendLine(address.ToString("X", 
    1.43 +          report.AppendLine(address.ToString("X",
    1.44              CultureInfo.InvariantCulture));
    1.45            report.AppendLine();
    1.46            return false;
    1.47 @@ -280,10 +280,10 @@
    1.48                report.Append("Chip ID: 0x");
    1.49                report.AppendLine(chip.ToString("X"));
    1.50                report.Append("Chip revision: 0x");
    1.51 -              report.AppendLine(revision.ToString("X", 
    1.52 +              report.AppendLine(revision.ToString("X",
    1.53                  CultureInfo.InvariantCulture));
    1.54                report.Append("Error: Invalid vendor ID 0x");
    1.55 -              report.AppendLine(vendorID.ToString("X", 
    1.56 +              report.AppendLine(vendorID.ToString("X",
    1.57                  CultureInfo.InvariantCulture));
    1.58                report.AppendLine();
    1.59                return false;
    1.60 @@ -304,6 +304,7 @@
    1.61      #region ITE
    1.62  
    1.63      private const byte IT87_ENVIRONMENT_CONTROLLER_LDN = 0x04;
    1.64 +    private const byte IT87_GPIO_LDN = 0x07;
    1.65      private const byte IT87_CHIP_VERSION_REGISTER = 0x22;
    1.66  
    1.67      private void IT87Enter() {
    1.68 @@ -351,6 +352,11 @@
    1.69  
    1.70          byte version = (byte)(ReadByte(IT87_CHIP_VERSION_REGISTER) & 0x0F);
    1.71  
    1.72 +        Select(IT87_GPIO_LDN);
    1.73 +        ushort gpioAddress = ReadWord(BASE_ADDRESS_REGISTER + 2);
    1.74 +        Thread.Sleep(1);
    1.75 +        ushort gpioVerify = ReadWord(BASE_ADDRESS_REGISTER + 2);
    1.76 +
    1.77          IT87Exit();
    1.78  
    1.79          if (address != verify || address < 0x100 || (address & 0xF007) != 0) {
    1.80 @@ -363,7 +369,18 @@
    1.81            return false;
    1.82          }
    1.83  
    1.84 -        superIOs.Add(new IT87XX(chip, address, version));
    1.85 +        if (gpioAddress != gpioVerify || gpioAddress < 0x100 ||
    1.86 +          (gpioAddress & 0xF007) != 0) {
    1.87 +          report.Append("Chip ID: 0x");
    1.88 +          report.AppendLine(chip.ToString("X"));
    1.89 +          report.Append("Error: Invalid GPIO address 0x");
    1.90 +          report.AppendLine(gpioAddress.ToString("X",
    1.91 +            CultureInfo.InvariantCulture));
    1.92 +          report.AppendLine();
    1.93 +          return false;
    1.94 +        }
    1.95 +
    1.96 +        superIOs.Add(new IT87XX(chip, address, gpioAddress, version));
    1.97          return true;
    1.98        }
    1.99  
   1.100 @@ -417,7 +434,7 @@
   1.101          if (DetectIT87()) continue;
   1.102  
   1.103          if (DetectSMSC()) continue;
   1.104 -      }  
   1.105 +      }
   1.106      }
   1.107  
   1.108      public LPCIO() {
   1.109 @@ -429,7 +446,7 @@
   1.110  
   1.111        Detect();
   1.112  
   1.113 -      WinRing0.ReleaseIsaBusMutex();      
   1.114 +      WinRing0.ReleaseIsaBusMutex();
   1.115      }
   1.116  
   1.117      public ISuperIO[] SuperIO {