Added an ISA bus mutex.
1.1 --- a/Hardware/LPC/F718XX.cs Wed Aug 04 19:10:20 2010 +0000
1.2 +++ b/Hardware/LPC/F718XX.cs Wed Aug 04 20:27:05 2010 +0000
1.3 @@ -87,9 +87,12 @@
1.4 r.AppendLine();
1.5 r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4"));
1.6 r.AppendLine();
1.7 +
1.8 + if (!WinRing0.WaitIsaBusMutex())
1.9 + return r.ToString();
1.10 +
1.11 r.AppendLine("Hardware Monitor Registers");
1.12 r.AppendLine();
1.13 -
1.14 r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
1.15 r.AppendLine();
1.16 for (int i = 0; i <= 0xF; i++) {
1.17 @@ -101,10 +104,15 @@
1.18 r.AppendLine();
1.19 }
1.20 r.AppendLine();
1.21 +
1.22 + WinRing0.ReleaseIsaBusMutex();
1.23 +
1.24 return r.ToString();
1.25 }
1.26
1.27 public void Update() {
1.28 + if (!WinRing0.WaitIsaBusMutex())
1.29 + return;
1.30
1.31 for (int i = 0; i < voltages.Length; i++) {
1.32 int value = ReadByte((byte)(VOLTAGE_BASE_REG + i));
1.33 @@ -154,7 +162,9 @@
1.34 fans[i] = (value < 0x0fff) ? 1.5e6f / value : 0;
1.35 else
1.36 fans[i] = null;
1.37 - }
1.38 + }
1.39 +
1.40 + WinRing0.ReleaseIsaBusMutex();
1.41 }
1.42 }
1.43 }
2.1 --- a/Hardware/LPC/IT87XX.cs Wed Aug 04 19:10:20 2010 +0000
2.2 +++ b/Hardware/LPC/IT87XX.cs Wed Aug 04 20:27:05 2010 +0000
2.3 @@ -118,9 +118,12 @@
2.4 r.Append("Chip Version: 0x"); r.AppendLine(version.ToString("X"));
2.5 r.Append("Base Address: 0x"); r.AppendLine(address.ToString("X4"));
2.6 r.AppendLine();
2.7 +
2.8 + if (!WinRing0.WaitIsaBusMutex())
2.9 + return r.ToString();
2.10 +
2.11 r.AppendLine("Environment Controller Registers");
2.12 r.AppendLine();
2.13 -
2.14 r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
2.15 r.AppendLine();
2.16 for (int i = 0; i <= 0xA; i++) {
2.17 @@ -138,10 +141,14 @@
2.18 }
2.19 r.AppendLine();
2.20
2.21 + WinRing0.ReleaseIsaBusMutex();
2.22 +
2.23 return r.ToString();
2.24 }
2.25
2.26 public void Update() {
2.27 + if (!WinRing0.WaitIsaBusMutex())
2.28 + return;
2.29
2.30 for (int i = 0; i < voltages.Length; i++) {
2.31 bool valid;
2.32 @@ -182,7 +189,9 @@
2.33 } else {
2.34 fans[i] = null;
2.35 }
2.36 - }
2.37 + }
2.38 +
2.39 + WinRing0.ReleaseIsaBusMutex();
2.40 }
2.41 }
2.42 }
3.1 --- a/Hardware/LPC/W836XX.cs Wed Aug 04 19:10:20 2010 +0000
3.2 +++ b/Hardware/LPC/W836XX.cs Wed Aug 04 20:27:05 2010 +0000
3.3 @@ -194,6 +194,8 @@
3.4 public float?[] Fans { get { return fans; } }
3.5
3.6 public void Update() {
3.7 + if (!WinRing0.WaitIsaBusMutex())
3.8 + return;
3.9
3.10 for (int i = 0; i < voltages.Length; i++) {
3.11 if (voltageRegister[i] != VOLTAGE_VBAT_REG) {
3.12 @@ -279,6 +281,8 @@
3.13 if (oldByte != newByte)
3.14 WriteByte(0, FAN_BIT_REG[i], newByte);
3.15 }
3.16 +
3.17 + WinRing0.ReleaseIsaBusMutex();
3.18 }
3.19
3.20 public string GetReport() {
3.21 @@ -290,6 +294,10 @@
3.22 r.Append("Chip revision: 0x"); r.AppendLine(revision.ToString("X"));
3.23 r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4"));
3.24 r.AppendLine();
3.25 +
3.26 + if (!WinRing0.WaitIsaBusMutex())
3.27 + return r.ToString();
3.28 +
3.29 r.AppendLine("Hardware Monitor Registers");
3.30 r.AppendLine();
3.31 r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
3.32 @@ -316,6 +324,8 @@
3.33 }
3.34 r.AppendLine();
3.35
3.36 + WinRing0.ReleaseIsaBusMutex();
3.37 +
3.38 return r.ToString();
3.39 }
3.40 }
4.1 --- a/Hardware/WinRing0.cs Wed Aug 04 19:10:20 2010 +0000
4.2 +++ b/Hardware/WinRing0.cs Wed Aug 04 20:27:05 2010 +0000
4.3 @@ -39,7 +39,7 @@
4.4 using System.Collections.Generic;
4.5 using System.IO;
4.6 using System.Runtime.InteropServices;
4.7 -using System.Text;
4.8 +using System.Threading;
4.9
4.10 namespace OpenHardwareMonitor.Hardware {
4.11
4.12 @@ -56,6 +56,7 @@
4.13 }
4.14
4.15 private static bool available = false;
4.16 + public static Mutex isaBusMutex;
4.17
4.18 private static string GetDllName() {
4.19 int p = (int)System.Environment.OSVersion.Platform;
4.20 @@ -103,20 +104,22 @@
4.21 private static InitializeOlsDelegate InitializeOls;
4.22 private static DeinitializeOlsDelegate DeinitializeOls;
4.23
4.24 - public static GetDllStatusDelegate GetDllStatus;
4.25 - public static IsCpuidDelegate IsCpuid;
4.26 - public static CpuidDelegate Cpuid;
4.27 - public static CpuidTxDelegate CpuidTx;
4.28 - public static RdmsrDelegate Rdmsr;
4.29 - public static RdmsrTxDelegate RdmsrTx;
4.30 - public static ReadIoPortByteDelegate ReadIoPortByte;
4.31 - public static WriteIoPortByteDelegate WriteIoPortByte;
4.32 - public static SetPciMaxBusIndexDelegate SetPciMaxBusIndex;
4.33 - public static FindPciDeviceByIdDelegate FindPciDeviceById;
4.34 - public static ReadPciConfigDwordExDelegate ReadPciConfigDwordEx;
4.35 - public static WritePciConfigDwordExDelegate WritePciConfigDwordEx;
4.36 - public static RdtscTxDelegate RdtscTx;
4.37 - public static RdtscDelegate Rdtsc;
4.38 + public static readonly GetDllStatusDelegate GetDllStatus;
4.39 + public static readonly IsCpuidDelegate IsCpuid;
4.40 + public static readonly CpuidDelegate Cpuid;
4.41 + public static readonly CpuidTxDelegate CpuidTx;
4.42 + public static readonly RdmsrDelegate Rdmsr;
4.43 + public static readonly RdmsrTxDelegate RdmsrTx;
4.44 + public static readonly ReadIoPortByteDelegate ReadIoPortByte;
4.45 + public static readonly WriteIoPortByteDelegate WriteIoPortByte;
4.46 + public static readonly SetPciMaxBusIndexDelegate SetPciMaxBusIndex;
4.47 + public static readonly FindPciDeviceByIdDelegate FindPciDeviceById;
4.48 + public static readonly ReadPciConfigDwordExDelegate ReadPciConfigDwordEx;
4.49 + public static readonly WritePciConfigDwordExDelegate WritePciConfigDwordEx;
4.50 + public static readonly RdtscTxDelegate RdtscTx;
4.51 + public static readonly RdtscDelegate Rdtsc;
4.52 +
4.53 +
4.54
4.55 private static void GetDelegate<T>(string entryPoint, out T newDelegate)
4.56 where T : class
4.57 @@ -150,18 +153,32 @@
4.58 try {
4.59 if (InitializeOls != null && InitializeOls())
4.60 available = true;
4.61 - } catch (DllNotFoundException) { }
4.62 + } catch (DllNotFoundException) { }
4.63 +
4.64 + isaBusMutex = new Mutex(false, "Access_ISABUS.HTP.Method");
4.65 }
4.66
4.67 public static bool IsAvailable {
4.68 get { return available; }
4.69 }
4.70
4.71 + public static bool WaitIsaBusMutex() {
4.72 + try {
4.73 + return isaBusMutex.WaitOne(10);
4.74 + } catch { return false; }
4.75 + }
4.76 +
4.77 + public static void ReleaseIsaBusMutex() {
4.78 + isaBusMutex.ReleaseMutex();
4.79 + }
4.80 +
4.81 private static Deinitializer deinitializer = new Deinitializer();
4.82 private class Deinitializer {
4.83 ~Deinitializer() {
4.84 if (available)
4.85 DeinitializeOls();
4.86 +
4.87 + isaBusMutex.Close();
4.88 }
4.89 }
4.90 }