I try to access the PCI configuration space of my PCI hardware.
I follow the WDK help topic "Accessing PCI Device Configuration Space".
As a first step, I try to get a BusInterface, but this fails.
I used two different styles (see code below), both result with
status = STATUS_NOT_SUPPORTED.
I can not see the difference between the PCIDRV example and my own
device, so any help is welcome!
J. Hoppe, PEAK System Technik GmbH
======= Try #1 (as in example "src/kmdf/pcidrv") : ================
xxxDeviceAdd() {
...
...
status = WdfFdoQueryForInterface(Device,
&GUID_BUS_INTERFACE_STANDARD,
(PINTERFACE) & pDeviceContext->BusInterface,
sizeof(BUS_INTERFACE_STANDARD), 1, // Version
NULL); //InterfaceSpecificData
....
}
======= Try #2 (as in other example / Knowledgebase) ================
// from C:\WinDDK\6000\src\general\pcidrv\sys\hw\nic_init.c
NTSTATUS
GetPCIBusInterfaceStandard(
__in PDEVICE_OBJECT DeviceObject,
__out PBUS_INTERFACE_STANDARD BusInterfaceStandard
)
/*++
Routine Description:
This routine gets the bus interface standard information from the PDO.
Arguments:
DeviceObject - Device object to query for this information.
BusInterface - Supplies a pointer to the retrieved information.
Return Value:
NT status.
--*/
{
KEVENT event;
NTSTATUS status;
PIRP irp;
IO_STATUS_BLOCK ioStatusBlock;
PIO_STACK_LOCATION irpStack;
PDEVICE_OBJECT targetObject;
DiagMsg("GetPciBusInterfaceStandard entered.");
PAGED_CODE();
KeInitializeEvent( &event, NotificationEvent, FALSE );
targetObject = IoGetAttachedDeviceReference( DeviceObject );
irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,
targetObject,
NULL,
0,
NULL,
&event,
&ioStatusBlock );
if (irp == NULL) {
status = STATUS_INSUFFICIENT_RESOURCES;
goto End;
}
irpStack = IoGetNextIrpStackLocation( irp );
irpStack->MinorFunction = IRP_MN_QUERY_INTERFACE;
irpStack->Parameters.QueryInterface.InterfaceType =
(LPGUID) &GUID_BUS_INTERFACE_STANDARD ;
irpStack->Parameters.QueryInterface.Size =
sizeof(BUS_INTERFACE_STANDARD);
irpStack->Parameters.QueryInterface.Version = 1;
irpStack->Parameters.QueryInterface.Interface =
(PINTERFACE)BusInterfaceStandard;
irpStack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
//
// Initialize the status to error in case the bus driver does not
// set it correctly.
irp->IoStatus.Status = STATUS_NOT_SUPPORTED ;
status = IoCallDriver( targetObject, irp );
if (status == STATUS_PENDING) {
status = KeWaitForSingleObject( &event, Executive, KernelMode,
FALSE, NULL);
ASSERT(NT_SUCCESS(status));
status = ioStatusBlock.Status;
}
End:
// Done with reference
ObDereferenceObject( targetObject );
return status;
}
xxxDeviceAdd() {
...
...
{
PDEVICE_OBJECT devobj = WdfDeviceWdmGetDeviceObject(Device) ;
status = GetPCIBusInterfaceStandard(devobj,
& (pDeviceContext->BusInterface)) ;
}
....
}
=============== end code examples =================