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

View file

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