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 =================

Re: accessing PCI configuration space results in STATUS_NOT_SUPPORTED by Doron

Doron
Wed Apr 18 21:47:08 CDT 2007

are you sure your PDO is a PCI PDO? there is no difference,
WdfFdoQueryForInterface does exactly what #2 does

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Joerg Hoppe" <jhoppe@community.nospam> wrote in message
news:ef4SFDbgHHA.588@TK2MSFTNGP06.phx.gbl...
>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 =================



Re: accessing PCI configuration space results in STATUS_NOT_SUPPORTED by Joerg

Joerg
Fri Apr 20 01:16:41 CDT 2007

Doron Holan [MS] schrieb:
> are you sure your PDO is a PCI PDO? there is no difference,
> WdfFdoQueryForInterface does exactly what #2 does
>
> d
>
Thanks for caring. I solved the problem: the device-installation
itself was damaged.
Device occured 2x under different names!
It was neither recognized as a PCI-hardware
nor had the system assigned any resources.
Complete reinstallation solved the problem.