Skip to content

Commit 25b4227

Browse files
committed
Move PCICMD read into PCICMDIOGuard.
1 parent 9b2aeab commit 25b4227

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

RAMSPDToolkit/I2CSMBus/Interop/Shared/PCICMDIOGuard.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ internal class PCICMDIOGuard : IDisposable
2121
{
2222
#region Constructor
2323

24-
public PCICMDIOGuard(uint pciAddress, ushort pciCMDOriginal)
24+
public PCICMDIOGuard(uint pciAddress)
2525
{
2626
_PCIAddress = pciAddress;
27-
_PCICMDOriginal = pciCMDOriginal;
27+
_PCICMDOriginal = DriverAccess.ReadPciConfigWord(_PCIAddress, SharedConstants.PCICMD);
2828

2929
//I/O is not enabled
30-
if (!BitHandler.IsBitSet(pciCMDOriginal, SharedConstants.PCI_CMD_IO_BIT))
30+
if (!BitHandler.IsBitSet(_PCICMDOriginal, SharedConstants.PCI_CMD_IO_BIT))
3131
{
3232
//Enable I/O
3333
_PCICMDModified = (ushort)(_PCICMDOriginal | SharedConstants.PCI_CMD_IO_BIT);

RAMSPDToolkit/I2CSMBus/SMBusI801.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public sealed class SMBusI801 : SMBusInterface
3737
}
3838

3939
_PCIAddress = pciAddress;
40-
41-
_PCICMDOriginal = DriverAccess.ReadPciConfigWord(_PCIAddress, SharedConstants.PCICMD);
42-
43-
LogSimple.LogTrace($"{nameof(SMBusI801)}: PCICMD is 0x{_PCICMDOriginal:X4} ({_PCICMDOriginal}).");
4440
}
4541

4642
#endregion
@@ -52,11 +48,6 @@ public sealed class SMBusI801 : SMBusInterface
5248
/// </summary>
5349
readonly uint _PCIAddress = PCIConstants.PCI_DEVICE_INVALID;
5450

55-
/// <summary>
56-
/// Initial value of the PCI Command Register (PCICMD) for this SMBus controller.
57-
/// </summary>
58-
readonly ushort _PCICMDOriginal;
59-
6051
#endregion
6152

6253
#region Properties
@@ -98,7 +89,7 @@ protected override int I2CSMBusXfer(byte addr, byte read_write, byte command, in
9889
using (var pci = new WorldMutexGuard(WorldMutexManager.WorldPCIMutex))
9990
{
10091
//Modify (if necessary) and restore PCICMD
101-
using (var io = new PCICMDIOGuard(_PCIAddress, _PCICMDOriginal))
92+
using (var io = new PCICMDIOGuard(_PCIAddress))
10293
{
10394
var result = i801Access(addr, read_write, command, size, data);
10495

RAMSPDToolkit/I2CSMBus/SMBusPiix4.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using RAMSPDToolkit.I2CSMBus.Interop;
1313
using RAMSPDToolkit.I2CSMBus.Interop.Piix4;
1414
using RAMSPDToolkit.I2CSMBus.Interop.Shared;
15-
using RAMSPDToolkit.Logging;
1615
using RAMSPDToolkit.Mutexes;
1716
using RAMSPDToolkit.PCI;
1817
using RAMSPDToolkit.Windows.Driver;
@@ -35,10 +34,6 @@ public sealed class SMBusPiix4 : SMBusInterface
3534
}
3635

3736
_PCIAddress = pciAddress;
38-
39-
_PCICMDOriginal = DriverAccess.ReadPciConfigWord(_PCIAddress, SharedConstants.PCICMD);
40-
41-
LogSimple.LogTrace($"{nameof(SMBusPiix4)}: PCICMD is 0x{_PCICMDOriginal:X4} ({_PCICMDOriginal}).");
4237
}
4338

4439
#endregion
@@ -50,11 +45,6 @@ public sealed class SMBusPiix4 : SMBusInterface
5045
/// </summary>
5146
readonly uint _PCIAddress = PCIConstants.PCI_DEVICE_INVALID;
5247

53-
/// <summary>
54-
/// Initial value of the PCI Command Register (PCICMD) for this SMBus controller.
55-
/// </summary>
56-
readonly ushort _PCICMDOriginal;
57-
5848
#endregion
5949

6050
#region Properties
@@ -91,7 +81,7 @@ protected override int I2CSMBusXfer(byte addr, byte read_write, byte command, in
9181
using (var pci = new WorldMutexGuard(WorldMutexManager.WorldPCIMutex))
9282
{
9383
//Modify (if necessary) and restore PCICMD
94-
using (var io = new PCICMDIOGuard(_PCIAddress, _PCICMDOriginal))
84+
using (var io = new PCICMDIOGuard(_PCIAddress))
9585
{
9686
var result = Piix4Access(addr, read_write, command, size, data);
9787

0 commit comments

Comments
 (0)