[ISAPNP] Improvements around hardware access helpers

- Reimplement WriteWord using the WriteByte helper.
- Remove inline qualifiers from the bus read and write functions.
  This code path is considered "cold" and using an inline for it is overkill.
- Don't apply the IRQL restrictions to our PnP state transition helpers.
  They are only called at IRQL below dispatch level.
This commit is contained in:
Dmitry Borisov 2024-05-03 20:43:40 +06:00
parent 2981e63a31
commit 6091dde0d3
2 changed files with 27 additions and 14 deletions

View File

@ -48,12 +48,14 @@ ReadData(
}
static
inline
CODE_SEG("PAGE")
VOID
WriteByte(
_In_ UCHAR Address,
_In_ UCHAR Value)
{
PAGED_CODE();
WriteAddress(Address);
WriteData(Value);
}
@ -65,10 +67,8 @@ WriteWord(
_In_ UCHAR Address,
_In_ USHORT Value)
{
WriteAddress(Address + 1);
WriteData((UCHAR)Value);
WriteAddress(Address);
WriteData(Value >> 8);
WriteByte(Address + 1, (UCHAR)Value);
WriteByte(Address, Value >> 8);
}
static
@ -83,12 +83,14 @@ WriteDoubleWord(
}
static
inline
CODE_SEG("PAGE")
UCHAR
ReadByte(
_In_ PUCHAR ReadDataPort,
_In_ UCHAR Address)
{
PAGED_CODE();
WriteAddress(Address);
return ReadData(ReadDataPort);
}
@ -325,11 +327,14 @@ NextLFSR(
}
static
CODE_SEG("PAGE")
VOID
SendKey(VOID)
{
UCHAR i, Lfsr;
PAGED_CODE();
WriteAddress(0x00);
WriteAddress(0x00);
@ -1634,37 +1639,45 @@ IsaHwConfigureDevice(
return STATUS_SUCCESS;
}
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwWakeDevice(
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
{
PAGED_CODE();
SendKey();
Wake(LogicalDevice->CSN);
}
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwActivateDevice(
_In_ PISAPNP_FDO_EXTENSION FdoExt,
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
{
PAGED_CODE();
ActivateDevice(FdoExt->ReadDataPort, LogicalDevice->LDN);
}
#ifndef UNIT_TEST
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwDeactivateDevice(
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
{
PAGED_CODE();
DeactivateDevice(LogicalDevice->LDN);
}
#endif /* UNIT_TEST */
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwWaitForKey(VOID)
{
PAGED_CODE();
WaitForKey();
}

View File

@ -244,23 +244,23 @@ IsaHwConfigureDevice(
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice,
_In_ PCM_RESOURCE_LIST Resources);
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwWakeDevice(
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice);
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwDeactivateDevice(
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice);
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwActivateDevice(
_In_ PISAPNP_FDO_EXTENSION FdoExt,
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice);
_IRQL_requires_max_(DISPATCH_LEVEL)
CODE_SEG("PAGE")
VOID
IsaHwWaitForKey(VOID);