IoEnumerateDeviceObjectList help

Hi everyone,
Has anyone used the new IoEnumerateDeviceObjectList function to obtain a Device Object for a PCI Bridge adapter? Basically I’ve been trying to access the configuration space of a PCI bridge adapter with no luck. I realize I need to use the BUS_INTERFACE_STANDARD method to acquire a driver interface for pci.sys. What’s confusing is how do I determine which device object belongs to the PCI Bridge adapter I am trying to access? Calling ObReferenceObject ByName will give me the driver object but there are at least 20 device objects associated with it.

This is the first time I’m doing this and information on the internet seems scarce or the preferred method would be to write a Bus Filter Driver. I’m trying to avoid this however by implementing this mechanism in my PMC module WDM Funtion driver.

Thanks in adavance

You are going about this the wrong way. If you need to access the bridge’s config space, install your driver as a filter on the bridge. Brute forcing your way through all of PCI’s device objects is not hte the thing to do

d

Wouldn’t you still need to know the transparent bridge adapter’s device object in order to write to it’s configuration space? How do you distinguish the device objects of the pci devices. Is there a flag or can you somehow retrieve the actual Device ID through the device object?

you don’t know about it explicitly. when your driver is instaled as a filter, it will be given to you when you attach to the PDO in your AddDevice routine

d

Thanks, but It just seems like an awful lot of work just to do one simple write to the PCI Configuration space of a PCI bridge adapter.

If i’m interpreting this correctly, I have to write a whole other driver just to do this. The other problem I have is even if I write a Bus Filter driver, if it’s not Microsoft Driver Signed I won’t be able to install it by clicking Update driver in the Device Manager. I’ve actually written an upper filter driver but everytime I go to install the driver it says that it can’t install because it can’t find the software. I have to resort back to the old machine.inf file in order for it to work properly again.

Now, if for some reason I can install my function driver as a filter driver maybe this would help but I’m still lost as to how to write to the PCI Bridge adapter configuration space.

I use the PCI bridge from PLX in one of my projects. Check out their website and download the SDK. It includes WDM-based driver examples for doing what you want.

Yes you can obtain the device id through IoGetDeviceProperty type DevicePropertyHardwareID. This will return the PCI enumerator string. To see what this looks like, and what other properties your can use to decide what to do with a particular device, use regedit to look at HKLM\System\CurrentControlSet\Enum\PCI and then look at the various enumerated pci devices there.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-276220-
xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Friday, January 19, 2007 12:42 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] IoEnumerateDeviceObjectList help

Wouldn’t you still need to know the transparent bridge adapter’s device
object in order to write to it’s configuration space? How do you
distinguish the device objects of the pci devices. Is there a flag or
can you somehow retrieve the actual Device ID through the device
object?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thanks, Mark! I’ll give that a try.

I appreciate everyone’s response. Thanks all!

note that you cannot tell which devobj in the list is a PDO or an FDO. If you are going to pass the devobj to a API which requires a PDO, you will have to send an IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_RELATIONS(TargetDeviceRelations) to it first to the the PDO.

d

Is the IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_RELATIONS really necessary? If you have all of the device objects associated with the driver object then couldn’t you just loop the IoGetDeviceProperty function until the Hardware ID string matches what your PCI bridge adapter is? I understand that the IoGetDeviceProperty function takes a PDO but do I really need it? If I pass in an FDO the function will probably fail but I can continue looping until a valid PDO was suppled. I’m probably missing something. Can some point me in the direction of where I can see a code snippet of how to retrieve the PDO from an FDO?

I’m using IoGetDeviceProperty right now but I don’t see the hardware ID of the PCI Bridge adapter I’m trying to access.

If you pass a non PDO to a function that requires a PDO, it can, and most likely will, bugcheck. You get the PDO from the FDO (or any device object) is by

  1. Getting the top of the stack via IoGetAttachedDeviceReference
  2. allocating a PIRP
  3. setting up the next stack location for IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_RELATIONS(TargetDeviceRelations)
  4. init the status to STATUS_NOT_SUPPORTED
  5. send the irp, wait for it synchronously
  6. on success, get the PDO out of the DEVICE_RELATIONS list. You will then need to
    a) free the relations list
    b) dereference the PDO (ObDereferenceObject) since the PDO was referenced when it was returned to you

d

Thanks! I think I know what I need to do now. I hope these are the right steps for accessing the pci configuration space of a transparent PCI Bridge adapter that my PMC module sits on. In my PMC function driver I…

  1. Call ObReferenceObjectByName to retrieve the driver object for pci.sys
  2. Call the IoEnumerateDeviceObjectList to get all of the DO’s associated with that driver object
  3. For each DO call the IoGetAttachedDeviceReference to get to the top of the stack
  4. Allocate the PIRP
  5. Call IoGetNextIrpStackLocation
  6. Send an IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_RELATIONS(TargetDeviceRelations) for each DO

Once I receive the DO I can then use IoGetDevicePropertyType to get the DevicePopertyHarwareID.
I can then compare this string to the actual Hardware ID of the PCI bridge adapter and if it’s a match, use the Bus Interface Standard to write to the PCI Configuration Space.

I realize writing a Bus Filter Driver is the way to go but will this method work? Should I be able to see the transparent PCI Bridge adapter’s DO? I’m hoping I will since it’s enumerated and I can view it in the Device Manager window.