From 6091dde0d348d138bc6f80fbe7354cc30627cbe2 Mon Sep 17 00:00:00 2001 From: Dmitry Borisov Date: Fri, 3 May 2024 20:43:40 +0600 Subject: [PATCH] [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. --- drivers/bus/isapnp/hardware.c | 33 +++++++++++++++++++++++---------- drivers/bus/isapnp/isapnp.h | 8 ++++---- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/bus/isapnp/hardware.c b/drivers/bus/isapnp/hardware.c index ecaec120c14..443fb787bbd 100644 --- a/drivers/bus/isapnp/hardware.c +++ b/drivers/bus/isapnp/hardware.c @@ -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(); } diff --git a/drivers/bus/isapnp/isapnp.h b/drivers/bus/isapnp/isapnp.h index 998c7e766f0..344cc23691d 100644 --- a/drivers/bus/isapnp/isapnp.h +++ b/drivers/bus/isapnp/isapnp.h @@ -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);