https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dd0027ba1959a6a2b9d88…
commit dd0027ba1959a6a2b9d88ccec2ee991d5e05b7b0
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Oct 15 13:10:08 2017 +0200
[STORPORT] Initialize the port configuration and pass it to the HwFindAdapter
routine.
---
drivers/storage/port/storport/fdo.c | 23 +++++++++
drivers/storage/port/storport/miniport.c | 85 +++++++++++++++++++++++++++++++-
drivers/storage/port/storport/precomp.h | 8 +--
3 files changed, 110 insertions(+), 6 deletions(-)
diff --git a/drivers/storage/port/storport/fdo.c b/drivers/storage/port/storport/fdo.c
index 6338c48d12..cb85d65c77 100644
--- a/drivers/storage/port/storport/fdo.c
+++ b/drivers/storage/port/storport/fdo.c
@@ -124,6 +124,28 @@ PortFdoQueryBusRelations(
}
+static
+NTSTATUS
+PortFdoFilterRequirements(
+ PFDO_DEVICE_EXTENSION DeviceExtension,
+ PIRP Irp)
+{
+ PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
+
+ DPRINT1("PortFdoFilterRequirements(%p %p)\n", DeviceExtension, Irp);
+
+ /* Get the bus number and the slot number */
+ RequirementsList =(PIO_RESOURCE_REQUIREMENTS_LIST)Irp->IoStatus.Information;
+ if (RequirementsList != NULL)
+ {
+ DeviceExtension->BusNumber = RequirementsList->BusNumber;
+ DeviceExtension->SlotNumber = RequirementsList->SlotNumber;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+
NTSTATUS
NTAPI
PortFdoPnp(
@@ -197,6 +219,7 @@ PortFdoPnp(
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: /* 0x0d */
DPRINT1("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
+ PortFdoFilterRequirements(DeviceExtension, Irp);
return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
case IRP_MN_QUERY_PNP_DEVICE_STATE: /* 0x14 */
diff --git a/drivers/storage/port/storport/miniport.c
b/drivers/storage/port/storport/miniport.c
index 4e0b37e182..dc4818dbd2 100644
--- a/drivers/storage/port/storport/miniport.c
+++ b/drivers/storage/port/storport/miniport.c
@@ -15,6 +15,80 @@
/* FUNCTIONS ******************************************************************/
+static
+NTSTATUS
+InitializeConfiguration(
+ _In_ PPORT_CONFIGURATION_INFORMATION PortConfig,
+ _In_ PHW_INITIALIZATION_DATA InitData,
+ _In_ ULONG BusNumber,
+ _In_ ULONG SlotNumber)
+{
+ PCONFIGURATION_INFORMATION ConfigInfo;
+ ULONG i;
+
+ DPRINT1("InitializeConfiguration(%p %p %lu %lu)\n",
+ PortConfig, InitData, BusNumber, SlotNumber);
+
+ /* Get the configurration information */
+ ConfigInfo = IoGetConfigurationInformation();
+
+ /* Initialize the port configuration */
+ RtlZeroMemory(PortConfig,
+ sizeof(PORT_CONFIGURATION_INFORMATION));
+
+ PortConfig->Length = sizeof(PORT_CONFIGURATION_INFORMATION);
+ PortConfig->SystemIoBusNumber = BusNumber;
+ PortConfig->SlotNumber = SlotNumber;
+ PortConfig->AdapterInterfaceType = InitData->AdapterInterfaceType;
+
+ PortConfig->MaximumTransferLength = -1; //SP_UNINITIALIZED_VALUE;
+ PortConfig->DmaChannel = -1; //SP_UNINITIALIZED_VALUE;
+ PortConfig->DmaPort = -1; //SP_UNINITIALIZED_VALUE;
+
+ PortConfig->InterruptMode = LevelSensitive;
+
+ PortConfig->Master = TRUE;
+ PortConfig->AtdiskPrimaryClaimed = ConfigInfo->AtDiskPrimaryAddressClaimed;
+ PortConfig->AtdiskSecondaryClaimed =
ConfigInfo->AtDiskSecondaryAddressClaimed;
+ PortConfig->Dma32BitAddresses = TRUE;
+ PortConfig->DemandMode = FALSE;
+ PortConfig->MapBuffers = InitData->MapBuffers;
+
+ PortConfig->NeedPhysicalAddresses = TRUE;
+ PortConfig->TaggedQueuing = TRUE;
+ PortConfig->AutoRequestSense = TRUE;
+ PortConfig->MultipleRequestPerLu = TRUE;
+ PortConfig->ReceiveEvent = InitData->ReceiveEvent;
+ PortConfig->RealModeInitialized = FALSE;
+ PortConfig->BufferAccessScsiPortControlled = TRUE;
+ PortConfig->MaximumNumberOfTargets = 128;
+
+ PortConfig->SpecificLuExtensionSize = InitData->SpecificLuExtensionSize;
+ PortConfig->SrbExtensionSize = InitData->SrbExtensionSize;
+ PortConfig->MaximumNumberOfLogicalUnits = 1;
+ PortConfig->WmiDataProvider = TRUE;
+
+ PortConfig->NumberOfAccessRanges = InitData->NumberOfAccessRanges;
+ DPRINT1("NumberOfAccessRanges: %lu\n",
PortConfig->NumberOfAccessRanges);
+ if (PortConfig->NumberOfAccessRanges != 0)
+ {
+ PortConfig->AccessRanges = ExAllocatePoolWithTag(NonPagedPool,
+
PortConfig->NumberOfAccessRanges * sizeof(ACCESS_RANGE),
+ TAG_ACCRESS_RANGE);
+ if (PortConfig->AccessRanges == NULL)
+ return STATUS_NO_MEMORY;
+
+ RtlZeroMemory(PortConfig->AccessRanges,
+ PortConfig->NumberOfAccessRanges * sizeof(ACCESS_RANGE));
+ }
+
+ for (i = 0; i < 7; i++)
+ PortConfig->InitiatorBusId[i] = 0xff;
+
+ return STATUS_SUCCESS;
+}
+
+
NTSTATUS
MiniportInitialize(
_In_ PMINIPORT Miniport,
@@ -23,6 +97,7 @@ MiniportInitialize(
{
PMINIPORT_DEVICE_EXTENSION MiniportExtension;
ULONG Size;
+ NTSTATUS Status;
DPRINT1("MiniportInitialize(%p %p %p)\n",
Miniport, DeviceExtension, InitData);
@@ -46,7 +121,13 @@ MiniportInitialize(
MiniportExtension->Miniport = Miniport;
Miniport->MiniportExtension = MiniportExtension;
- return STATUS_SUCCESS;
+ /* Initialize the port configuration */
+ Status = InitializeConfiguration(&Miniport->PortConfig,
+ InitData,
+ DeviceExtension->BusNumber,
+ DeviceExtension->SlotNumber);
+
+ return Status;
}
@@ -65,7 +146,7 @@ MiniportFindAdapter(
NULL,
NULL,
NULL,
- NULL,
+ &Miniport->PortConfig,
&Reserved);
DPRINT1("HwFindAdapter() returned %lu\n", Result);
diff --git a/drivers/storage/port/storport/precomp.h
b/drivers/storage/port/storport/precomp.h
index 350ca6854d..b084e0e9da 100644
--- a/drivers/storage/port/storport/precomp.h
+++ b/drivers/storage/port/storport/precomp.h
@@ -26,6 +26,7 @@
#define TAG_GLOBAL_DATA 'DGtS'
#define TAG_INIT_DATA 'DItS'
#define TAG_MINIPORT_DATA 'DMtS'
+#define TAG_ACCRESS_RANGE 'RAtS'
typedef enum
{
@@ -72,6 +73,7 @@ typedef struct _MINIPORT
{
struct _FDO_DEVICE_EXTENSION *DeviceExtension;
PHW_INITIALIZATION_DATA InitData;
+ PORT_CONFIGURATION_INFORMATION PortConfig;
PMINIPORT_DEVICE_EXTENSION MiniportExtension;
} MINIPORT, *PMINIPORT;
@@ -82,14 +84,12 @@ typedef struct _FDO_DEVICE_EXTENSION
PDEVICE_OBJECT Device;
PDEVICE_OBJECT LowerDevice;
PDEVICE_OBJECT PhysicalDevice;
-
PDRIVER_OBJECT_EXTENSION DriverExtension;
-
DEVICE_STATE PnpState;
LIST_ENTRY AdapterListEntry;
-
MINIPORT Miniport;
-
+ ULONG BusNumber;
+ ULONG SlotNumber;
} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;