# HG changeset patch # User moel.mich # Date 1280953625 0 # Node ID 2129ccee0bd1adae54e14a9a52414e0a50804c9c # Parent 65f2d62d7838f69aa7c2c8c6d3bbcbc689c28ea0 Added an ISA bus mutex. diff -r 65f2d62d7838 -r 2129ccee0bd1 Hardware/LPC/F718XX.cs --- a/Hardware/LPC/F718XX.cs Wed Aug 04 19:10:20 2010 +0000 +++ b/Hardware/LPC/F718XX.cs Wed Aug 04 20:27:05 2010 +0000 @@ -87,9 +87,12 @@ r.AppendLine(); r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); + + if (!WinRing0.WaitIsaBusMutex()) + return r.ToString(); + r.AppendLine("Hardware Monitor Registers"); r.AppendLine(); - r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); r.AppendLine(); for (int i = 0; i <= 0xF; i++) { @@ -101,10 +104,15 @@ r.AppendLine(); } r.AppendLine(); + + WinRing0.ReleaseIsaBusMutex(); + return r.ToString(); } public void Update() { + if (!WinRing0.WaitIsaBusMutex()) + return; for (int i = 0; i < voltages.Length; i++) { int value = ReadByte((byte)(VOLTAGE_BASE_REG + i)); @@ -154,7 +162,9 @@ fans[i] = (value < 0x0fff) ? 1.5e6f / value : 0; else fans[i] = null; - } + } + + WinRing0.ReleaseIsaBusMutex(); } } } diff -r 65f2d62d7838 -r 2129ccee0bd1 Hardware/LPC/IT87XX.cs --- a/Hardware/LPC/IT87XX.cs Wed Aug 04 19:10:20 2010 +0000 +++ b/Hardware/LPC/IT87XX.cs Wed Aug 04 20:27:05 2010 +0000 @@ -118,9 +118,12 @@ r.Append("Chip Version: 0x"); r.AppendLine(version.ToString("X")); r.Append("Base Address: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); + + if (!WinRing0.WaitIsaBusMutex()) + return r.ToString(); + r.AppendLine("Environment Controller Registers"); r.AppendLine(); - r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); r.AppendLine(); for (int i = 0; i <= 0xA; i++) { @@ -138,10 +141,14 @@ } r.AppendLine(); + WinRing0.ReleaseIsaBusMutex(); + return r.ToString(); } public void Update() { + if (!WinRing0.WaitIsaBusMutex()) + return; for (int i = 0; i < voltages.Length; i++) { bool valid; @@ -182,7 +189,9 @@ } else { fans[i] = null; } - } + } + + WinRing0.ReleaseIsaBusMutex(); } } } diff -r 65f2d62d7838 -r 2129ccee0bd1 Hardware/LPC/W836XX.cs --- a/Hardware/LPC/W836XX.cs Wed Aug 04 19:10:20 2010 +0000 +++ b/Hardware/LPC/W836XX.cs Wed Aug 04 20:27:05 2010 +0000 @@ -194,6 +194,8 @@ public float?[] Fans { get { return fans; } } public void Update() { + if (!WinRing0.WaitIsaBusMutex()) + return; for (int i = 0; i < voltages.Length; i++) { if (voltageRegister[i] != VOLTAGE_VBAT_REG) { @@ -279,6 +281,8 @@ if (oldByte != newByte) WriteByte(0, FAN_BIT_REG[i], newByte); } + + WinRing0.ReleaseIsaBusMutex(); } public string GetReport() { @@ -290,6 +294,10 @@ r.Append("Chip revision: 0x"); r.AppendLine(revision.ToString("X")); r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); + + if (!WinRing0.WaitIsaBusMutex()) + return r.ToString(); + r.AppendLine("Hardware Monitor Registers"); r.AppendLine(); r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); @@ -316,6 +324,8 @@ } r.AppendLine(); + WinRing0.ReleaseIsaBusMutex(); + return r.ToString(); } } diff -r 65f2d62d7838 -r 2129ccee0bd1 Hardware/WinRing0.cs --- a/Hardware/WinRing0.cs Wed Aug 04 19:10:20 2010 +0000 +++ b/Hardware/WinRing0.cs Wed Aug 04 20:27:05 2010 +0000 @@ -39,7 +39,7 @@ using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; -using System.Text; +using System.Threading; namespace OpenHardwareMonitor.Hardware { @@ -56,6 +56,7 @@ } private static bool available = false; + public static Mutex isaBusMutex; private static string GetDllName() { int p = (int)System.Environment.OSVersion.Platform; @@ -103,20 +104,22 @@ private static InitializeOlsDelegate InitializeOls; private static DeinitializeOlsDelegate DeinitializeOls; - public static GetDllStatusDelegate GetDllStatus; - public static IsCpuidDelegate IsCpuid; - public static CpuidDelegate Cpuid; - public static CpuidTxDelegate CpuidTx; - public static RdmsrDelegate Rdmsr; - public static RdmsrTxDelegate RdmsrTx; - public static ReadIoPortByteDelegate ReadIoPortByte; - public static WriteIoPortByteDelegate WriteIoPortByte; - public static SetPciMaxBusIndexDelegate SetPciMaxBusIndex; - public static FindPciDeviceByIdDelegate FindPciDeviceById; - public static ReadPciConfigDwordExDelegate ReadPciConfigDwordEx; - public static WritePciConfigDwordExDelegate WritePciConfigDwordEx; - public static RdtscTxDelegate RdtscTx; - public static RdtscDelegate Rdtsc; + public static readonly GetDllStatusDelegate GetDllStatus; + public static readonly IsCpuidDelegate IsCpuid; + public static readonly CpuidDelegate Cpuid; + public static readonly CpuidTxDelegate CpuidTx; + public static readonly RdmsrDelegate Rdmsr; + public static readonly RdmsrTxDelegate RdmsrTx; + public static readonly ReadIoPortByteDelegate ReadIoPortByte; + public static readonly WriteIoPortByteDelegate WriteIoPortByte; + public static readonly SetPciMaxBusIndexDelegate SetPciMaxBusIndex; + public static readonly FindPciDeviceByIdDelegate FindPciDeviceById; + public static readonly ReadPciConfigDwordExDelegate ReadPciConfigDwordEx; + public static readonly WritePciConfigDwordExDelegate WritePciConfigDwordEx; + public static readonly RdtscTxDelegate RdtscTx; + public static readonly RdtscDelegate Rdtsc; + + private static void GetDelegate(string entryPoint, out T newDelegate) where T : class @@ -150,18 +153,32 @@ try { if (InitializeOls != null && InitializeOls()) available = true; - } catch (DllNotFoundException) { } + } catch (DllNotFoundException) { } + + isaBusMutex = new Mutex(false, "Access_ISABUS.HTP.Method"); } public static bool IsAvailable { get { return available; } } + public static bool WaitIsaBusMutex() { + try { + return isaBusMutex.WaitOne(10); + } catch { return false; } + } + + public static void ReleaseIsaBusMutex() { + isaBusMutex.ReleaseMutex(); + } + private static Deinitializer deinitializer = new Deinitializer(); private class Deinitializer { ~Deinitializer() { if (available) DeinitializeOls(); + + isaBusMutex.Close(); } } }