https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b21019e3d1bfa6614c89f…
commit b21019e3d1bfa6614c89fd38ec6bcfce94c0e46a
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Mon Oct 16 00:13:21 2017 +0200
[STORPORT] Query the bus interface of the lower (bus) device and implement
StorPortGetBusData().
CORE-13866
---
drivers/storage/port/storport/fdo.c | 14 +++++++++
drivers/storage/port/storport/misc.c | 50 ++++++++++++++++++++++++++++++++
drivers/storage/port/storport/precomp.h | 11 +++++++
drivers/storage/port/storport/storport.c | 31 +++++++++++++++++---
4 files changed, 102 insertions(+), 4 deletions(-)
diff --git a/drivers/storage/port/storport/fdo.c b/drivers/storage/port/storport/fdo.c
index 3f569ac5c9..70b6a30dd3 100644
--- a/drivers/storage/port/storport/fdo.c
+++ b/drivers/storage/port/storport/fdo.c
@@ -114,6 +114,20 @@ PortFdoStartDevice(
return STATUS_NO_MEMORY;
}
+ /* Get the bus interface of the lower (bus) device */
+ Status = QueryBusInterface(DeviceExtension->LowerDevice,
+ (PGUID)&GUID_BUS_INTERFACE_STANDARD,
+ sizeof(BUS_INTERFACE_STANDARD),
+ 1,
+ &DeviceExtension->BusInterface,
+ NULL);
+ DPRINT1("Status: 0x%08lx\n", Status);
+ if (NT_SUCCESS(Status))
+ {
+ DPRINT1("Context: %p\n", DeviceExtension->BusInterface.Context);
+ DeviceExtension->BusInitialized = TRUE;
+ }
+
/* Start the miniport (FindAdapter & Initialize) */
Status = PortFdoStartMiniport(DeviceExtension);
if (!NT_SUCCESS(Status))
diff --git a/drivers/storage/port/storport/misc.c b/drivers/storage/port/storport/misc.c
index 5f42be2fe8..bcbdb05912 100644
--- a/drivers/storage/port/storport/misc.c
+++ b/drivers/storage/port/storport/misc.c
@@ -167,4 +167,54 @@ CopyResourceList(
}
+NTSTATUS
+QueryBusInterface(
+ PDEVICE_OBJECT DeviceObject,
+ PGUID Guid,
+ USHORT Size,
+ USHORT Version,
+ PBUS_INTERFACE_STANDARD Interface,
+ PVOID InterfaceSpecificData)
+{
+ KEVENT Event;
+ NTSTATUS Status;
+ PIRP Irp;
+ IO_STATUS_BLOCK IoStatus;
+ PIO_STACK_LOCATION Stack;
+
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP,
+ DeviceObject,
+ NULL,
+ 0,
+ NULL,
+ &Event,
+ &IoStatus);
+ if (Irp == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Stack = IoGetNextIrpStackLocation(Irp);
+
+ Stack->MajorFunction = IRP_MJ_PNP;
+ Stack->MinorFunction = IRP_MN_QUERY_INTERFACE;
+ Stack->Parameters.QueryInterface.InterfaceType = Guid;
+ Stack->Parameters.QueryInterface.Size = Size;
+ Stack->Parameters.QueryInterface.Version = Version;
+ Stack->Parameters.QueryInterface.Interface = (PINTERFACE)Interface;
+ Stack->Parameters.QueryInterface.InterfaceSpecificData = InterfaceSpecificData;
+
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+
+ Status = IoCallDriver(DeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+
+ Status=IoStatus.Status;
+ }
+
+ return Status;
+}
+
/* EOF */
diff --git a/drivers/storage/port/storport/precomp.h
b/drivers/storage/port/storport/precomp.h
index beacc8eb77..1bbd70c00e 100644
--- a/drivers/storage/port/storport/precomp.h
+++ b/drivers/storage/port/storport/precomp.h
@@ -93,6 +93,8 @@ typedef struct _FDO_DEVICE_EXTENSION
ULONG SlotNumber;
PCM_RESOURCE_LIST AllocatedResources;
PCM_RESOURCE_LIST TranslatedResources;
+ BUS_INTERFACE_STANDARD BusInterface;
+ BOOLEAN BusInitialized;
} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
@@ -155,6 +157,15 @@ CopyResourceList(
POOL_TYPE PoolType,
PCM_RESOURCE_LIST Source);
+NTSTATUS
+QueryBusInterface(
+ PDEVICE_OBJECT DeviceObject,
+ PGUID Guid,
+ USHORT Size,
+ USHORT Version,
+ PBUS_INTERFACE_STANDARD Interface,
+ PVOID InterfaceSpecificData);
+
/* pdo.c */
diff --git a/drivers/storage/port/storport/storport.c
b/drivers/storage/port/storport/storport.c
index 3520bbf3a3..170c4eb678 100644
--- a/drivers/storage/port/storport/storport.c
+++ b/drivers/storage/port/storport/storport.c
@@ -548,7 +548,7 @@ StorPortFreeRegistryBuffer(
/*
- * @unimplemented
+ * @implemented
*/
STORPORT_API
ULONG
@@ -561,9 +561,32 @@ StorPortGetBusData(
_Out_ _When_(Length != 0, _Out_writes_bytes_(Length)) PVOID Buffer,
_In_ ULONG Length)
{
- DPRINT1("StorPortGetBusData()\n");
- UNIMPLEMENTED;
- return 0;
+ PMINIPORT_DEVICE_EXTENSION MiniportExtension;
+ PBUS_INTERFACE_STANDARD Interface;
+ ULONG ReturnLength;
+
+ DPRINT1("StorPortGetBusData(%p %lu %lu %lu %p %lu)\n",
+ DeviceExtension, BusDataType, SystemIoBusNumber, SlotNumber, Buffer,
Length);
+
+ MiniportExtension = CONTAINING_RECORD(DeviceExtension,
+ MINIPORT_DEVICE_EXTENSION,
+ HwDeviceExtension);
+ DPRINT1("DeviceExtension %p MiniportExtension %p\n",
+ DeviceExtension, MiniportExtension);
+
+ Interface =
&MiniportExtension->Miniport->DeviceExtension->BusInterface;
+
+ if (BusDataType == 4)
+ BusDataType = 0;
+
+ ReturnLength = Interface->GetBusData(Interface->Context,
+ BusDataType,
+ Buffer,
+ 0,
+ Length);
+ DPRINT1("ReturnLength: %lu\n", ReturnLength);
+
+ return ReturnLength;
}