Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > How to read extended config space on Windows XP

Reply
Thread Tools Display Modes

How to read extended config space on Windows XP

 
 
Jeff Yang
Guest
Posts: n/a

 
      04-09-2007
I used below code segment to try to access the extended config space of an
PCI express card on Windows Vista, when the offset is not greater then 0xfc,
the
value can be read to the buffer. But if offset is greater then 0xfc, the
read will fail and the status is returned as 0xC0000010, I checked
the error code, it means "STATUS_INVALID_DEVICE_REQUEST". But from the
document PCI-PCIe_FAQ.doc downloaded from
http://www.microsoft.com/taiwan/whdc.../PCIe_FAQ.mspx, the
extended space should be accessable on Vista.

Windows Vista and Windows Server Longhorn. To access extended configuration
space on these operating systems, drivers should use documented interfaces
such as BUS_INTERFACE_STANDARD and IRP_MJ_PNP requests with
IRP_MN_READ_CONFIG or IRP_MN_WRITE_CONFIG. These interfaces have been
extended in Windows Vista and Windows Server Longhorn to support accessing
extended configuration space.



I used WDK 6000 to build the code.



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 );
if (ReadOrWrite == 0) {
irpStack->MinorFunction = IRP_MN_READ_CONFIG;
}else {
irpStack->MinorFunction = IRP_MN_WRITE_CONFIG;
}
DbgPrint("ReadWriteConfigSpace:Offset 0x%x\n", Offset);
irpStack->Parameters.ReadWriteConfig.WhichSpace = PCI_WHICHSPACE_CONFIG;
irpStack->Parameters.ReadWriteConfig.Buffer = Buffer;
irpStack->Parameters.ReadWriteConfig.Offset = Offset;
irpStack->Parameters.ReadWriteConfig.Length = Length;
// 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) {
KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL );
status = ioStatusBlock.Status;
}
End:
// Done with reference
ObDereferenceObject( targetObject );
DbgPrint("ReadWriteConfigSpace:Status = 0x%x\n", status);
return status;


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading/writing config space for any/all devices Hua-Ying Ling Windows Vista Drivers 1 11-10-2005 12:37 PM
PCI-Extended Config Space Rupesh Windows Vista Drivers 4 09-01-2005 05:20 AM
PCI Express extended Configuration Space access Sachin Windows Vista Drivers 3 01-07-2005 01:57 PM
PCI Bus Filter driver to read config space? HyperWalker Windows Vista Drivers 5 07-15-2004 11:21 AM
Questions on PCI config space when ressetting a PCI board User1964 Windows Vista Drivers 5 03-03-2004 10:44 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59