[STORPORT] Initialize the port configuration and pass it to the HwFindAdapter routine.
authorEric Kohl <eric.kohl@reactos.org>
Sun, 15 Oct 2017 11:10:08 +0000 (13:10 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 15 Oct 2017 11:10:08 +0000 (13:10 +0200)
drivers/storage/port/storport/fdo.c
drivers/storage/port/storport/miniport.c
drivers/storage/port/storport/precomp.h

index 6338c48..cb85d65 100644 (file)
@@ -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(
 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");
 
         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 */
             return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
 
         case IRP_MN_QUERY_PNP_DEVICE_STATE: /* 0x14 */
index 4e0b37e..dc4818d 100644 (file)
 
 /* FUNCTIONS ******************************************************************/
 
 
 /* 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,
 NTSTATUS
 MiniportInitialize(
     _In_ PMINIPORT Miniport,
@@ -23,6 +97,7 @@ MiniportInitialize(
 {
     PMINIPORT_DEVICE_EXTENSION MiniportExtension;
     ULONG Size;
 {
     PMINIPORT_DEVICE_EXTENSION MiniportExtension;
     ULONG Size;
+    NTSTATUS Status;
 
     DPRINT1("MiniportInitialize(%p %p %p)\n",
             Miniport, DeviceExtension, InitData);
 
     DPRINT1("MiniportInitialize(%p %p %p)\n",
             Miniport, DeviceExtension, InitData);
@@ -46,7 +121,13 @@ MiniportInitialize(
     MiniportExtension->Miniport = Miniport;
     Miniport->MiniportExtension = MiniportExtension;
 
     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,
                                                NULL,
                                                NULL,
-                                               NULL,
+                                               &Miniport->PortConfig,
                                                &Reserved);
     DPRINT1("HwFindAdapter() returned %lu\n", Result);
 
                                                &Reserved);
     DPRINT1("HwFindAdapter() returned %lu\n", Result);
 
index 350ca68..b084e0e 100644 (file)
@@ -26,6 +26,7 @@
 #define TAG_GLOBAL_DATA    'DGtS'
 #define TAG_INIT_DATA      'DItS'
 #define TAG_MINIPORT_DATA  'DMtS'
 #define TAG_GLOBAL_DATA    'DGtS'
 #define TAG_INIT_DATA      'DItS'
 #define TAG_MINIPORT_DATA  'DMtS'
+#define TAG_ACCRESS_RANGE  'RAtS'
 
 typedef enum
 {
 
 typedef enum
 {
@@ -72,6 +73,7 @@ typedef struct _MINIPORT
 {
     struct _FDO_DEVICE_EXTENSION *DeviceExtension;
     PHW_INITIALIZATION_DATA InitData;
 {
     struct _FDO_DEVICE_EXTENSION *DeviceExtension;
     PHW_INITIALIZATION_DATA InitData;
+    PORT_CONFIGURATION_INFORMATION PortConfig;
     PMINIPORT_DEVICE_EXTENSION MiniportExtension;
 } MINIPORT, *PMINIPORT;
 
     PMINIPORT_DEVICE_EXTENSION MiniportExtension;
 } MINIPORT, *PMINIPORT;
 
@@ -82,14 +84,12 @@ typedef struct _FDO_DEVICE_EXTENSION
     PDEVICE_OBJECT Device;
     PDEVICE_OBJECT LowerDevice;
     PDEVICE_OBJECT PhysicalDevice;
     PDEVICE_OBJECT Device;
     PDEVICE_OBJECT LowerDevice;
     PDEVICE_OBJECT PhysicalDevice;
-
     PDRIVER_OBJECT_EXTENSION DriverExtension;
     PDRIVER_OBJECT_EXTENSION DriverExtension;
-
     DEVICE_STATE PnpState;
     LIST_ENTRY AdapterListEntry;
     DEVICE_STATE PnpState;
     LIST_ENTRY AdapterListEntry;
-
     MINIPORT Miniport;
     MINIPORT Miniport;
-
+    ULONG BusNumber;
+    ULONG SlotNumber;
 } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
 
 
 } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;