# HG changeset patch # User moel.mich # Date 1281031578 0 # Node ID 67be1c62f950f7e07b072137f726051c9c7d5db4 # Parent 2129ccee0bd1adae54e14a9a52414e0a50804c9c Added ISA bus mutex support to the super IO detection. diff -r 2129ccee0bd1 -r 67be1c62f950 Hardware/LPC/F718XX.cs --- a/Hardware/LPC/F718XX.cs Wed Aug 04 20:27:05 2010 +0000 +++ b/Hardware/LPC/F718XX.cs Thu Aug 05 18:06:18 2010 +0000 @@ -88,7 +88,7 @@ r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); - if (!WinRing0.WaitIsaBusMutex()) + if (!WinRing0.WaitIsaBusMutex(100)) return r.ToString(); r.AppendLine("Hardware Monitor Registers"); @@ -111,7 +111,7 @@ } public void Update() { - if (!WinRing0.WaitIsaBusMutex()) + if (!WinRing0.WaitIsaBusMutex(10)) return; for (int i = 0; i < voltages.Length; i++) { diff -r 2129ccee0bd1 -r 67be1c62f950 Hardware/LPC/IT87XX.cs --- a/Hardware/LPC/IT87XX.cs Wed Aug 04 20:27:05 2010 +0000 +++ b/Hardware/LPC/IT87XX.cs Thu Aug 05 18:06:18 2010 +0000 @@ -119,7 +119,7 @@ r.Append("Base Address: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); - if (!WinRing0.WaitIsaBusMutex()) + if (!WinRing0.WaitIsaBusMutex(100)) return r.ToString(); r.AppendLine("Environment Controller Registers"); @@ -147,7 +147,7 @@ } public void Update() { - if (!WinRing0.WaitIsaBusMutex()) + if (!WinRing0.WaitIsaBusMutex(10)) return; for (int i = 0; i < voltages.Length; i++) { diff -r 2129ccee0bd1 -r 67be1c62f950 Hardware/LPC/LPCIO.cs --- a/Hardware/LPC/LPCIO.cs Wed Aug 04 20:27:05 2010 +0000 +++ b/Hardware/LPC/LPCIO.cs Thu Aug 05 18:06:18 2010 +0000 @@ -120,9 +120,7 @@ WinRing0.WriteIoPortByte(registerPort, 0xAA); } - public LPCIO() { - if (!WinRing0.IsAvailable) - return; + private void Detect() { for (int i = 0; i < REGISTER_PORTS.Length; i++) { registerPort = REGISTER_PORTS[i]; @@ -145,35 +143,35 @@ case 0x41: chip = Chip.F71882; logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; + break; } break; case 0x06: - switch (revision) { + switch (revision) { case 0x01: chip = Chip.F71862; logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; + break; } break; case 0x07: switch (revision) { case 0x23: chip = Chip.F71889F; logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; + break; } break; case 0x08: switch (revision) { case 0x14: chip = Chip.F71869; logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; + break; } break; case 0x09: switch (revision) { case 0x09: chip = Chip.F71889ED; logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; + break; } break; case 0x52: switch (revision) { @@ -182,7 +180,7 @@ case 0x41: chip = Chip.W83627HF; logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; + break; } break; case 0x82: switch (revision & 0xF0) { @@ -208,10 +206,10 @@ } break; case 0xA0: switch (revision & 0xF0) { - case 0x20: + case 0x20: chip = Chip.W83627DHG; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; } break; case 0xA5: switch (revision & 0xF0) { @@ -225,7 +223,7 @@ case 0x70: chip = Chip.W83627DHGP; logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; + break; } break; case 0xB3: switch (revision & 0xF0) { @@ -233,20 +231,20 @@ chip = Chip.W83667HGB; logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; break; - } break; + } break; } if (chip == Chip.Unknown) { if (id != 0 && id != 0xff) { WinbondFintekExit(); - report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x"); + report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x"); report.AppendLine(((id << 8) | revision).ToString("X")); report.AppendLine(); } } else { Select(logicalDeviceNumber); - ushort address = ReadWord(BASE_ADDRESS_REGISTER); + ushort address = ReadWord(BASE_ADDRESS_REGISTER); Thread.Sleep(1); ushort verify = ReadWord(BASE_ADDRESS_REGISTER); @@ -254,10 +252,10 @@ WinbondFintekExit(); - if (address != verify) { - report.Append("Chip ID: 0x"); + if (address != verify) { + report.Append("Chip ID: 0x"); report.AppendLine(chip.ToString("X")); - report.Append("Chip revision: 0x"); + report.Append("Chip revision: 0x"); report.AppendLine(revision.ToString("X")); report.AppendLine("Error: Address verification failed"); report.AppendLine(); @@ -268,7 +266,7 @@ if ((address & 0x07) == 0x05) address &= 0xFFF8; - if (address < 0x100 || (address & 0xF007) != 0) { + if (address < 0x100 || (address & 0xF007) != 0) { report.Append("Chip ID: 0x"); report.AppendLine(chip.ToString("X")); report.Append("Chip revision: 0x"); @@ -310,7 +308,7 @@ break; default: break; } - + return; } @@ -322,7 +320,7 @@ case 0x8716: chip = Chip.IT8716F; break; case 0x8718: chip = Chip.IT8718F; break; case 0x8720: chip = Chip.IT8720F; break; - case 0x8726: chip = Chip.IT8726F; break; + case 0x8726: chip = Chip.IT8726F; break; default: chip = Chip.Unknown; break; } if (chip == Chip.Unknown) { @@ -333,7 +331,7 @@ report.AppendLine(chipID.ToString("X")); report.AppendLine(); } - } else { + } else { Select(IT87_ENVIRONMENT_CONTROLLER_LDN); ushort address = ReadWord(BASE_ADDRESS_REGISTER); Thread.Sleep(1); @@ -345,14 +343,14 @@ if (address != verify || address < 0x100 || (address & 0xF007) != 0) { report.Append("Chip ID: 0x"); - report.AppendLine(chip.ToString("X")); + report.AppendLine(chip.ToString("X")); report.Append("Error: Invalid address 0x"); report.AppendLine(address.ToString("X")); report.AppendLine(); return; } - superIOs.Add(new IT87XX(chip, address, version)); + superIOs.Add(new IT87XX(chip, address, version)); return; } @@ -376,7 +374,19 @@ return; } - } + } + } + + public LPCIO() { + if (!WinRing0.IsAvailable) + return; + + if (!WinRing0.WaitIsaBusMutex(100)) + return; + + Detect(); + + WinRing0.ReleaseIsaBusMutex(); } public ISuperIO[] SuperIO { diff -r 2129ccee0bd1 -r 67be1c62f950 Hardware/LPC/W836XX.cs --- a/Hardware/LPC/W836XX.cs Wed Aug 04 20:27:05 2010 +0000 +++ b/Hardware/LPC/W836XX.cs Thu Aug 05 18:06:18 2010 +0000 @@ -194,7 +194,7 @@ public float?[] Fans { get { return fans; } } public void Update() { - if (!WinRing0.WaitIsaBusMutex()) + if (!WinRing0.WaitIsaBusMutex(10)) return; for (int i = 0; i < voltages.Length; i++) { @@ -295,7 +295,7 @@ r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); - if (!WinRing0.WaitIsaBusMutex()) + if (!WinRing0.WaitIsaBusMutex(100)) return r.ToString(); r.AppendLine("Hardware Monitor Registers"); diff -r 2129ccee0bd1 -r 67be1c62f950 Hardware/WinRing0.cs --- a/Hardware/WinRing0.cs Wed Aug 04 20:27:05 2010 +0000 +++ b/Hardware/WinRing0.cs Thu Aug 05 18:06:18 2010 +0000 @@ -162,9 +162,9 @@ get { return available; } } - public static bool WaitIsaBusMutex() { + public static bool WaitIsaBusMutex(int millisecondsTimeout) { try { - return isaBusMutex.WaitOne(10); + return isaBusMutex.WaitOne(millisecondsTimeout); } catch { return false; } }