[STORPORT] Query the bus interface of the lower (bus) device and implement StorPortGetBusData().

CORE-13866
This commit is contained in:
Eric Kohl 2017-10-16 00:13:21 +02:00
parent 3f5aeb9363
commit b21019e3d1
4 changed files with 102 additions and 4 deletions

View file

@ -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))

View file

@ -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 */

View file

@ -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 */

View file

@ -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;
}