reading pci cfg space from kernel module - Linux

This is a discussion on reading pci cfg space from kernel module - Linux ; What is the standard kernel module api for reading/writing PCI configuration space? I'm using a 2.6 SMP kernel. It seems i should be using pci_config_read_dword but i dont see how to specify the bus/dev/fn/ in struct pci_dev. How do i ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: reading pci cfg space from kernel module

  1. reading pci cfg space from kernel module

    What is the standard kernel module api for reading/writing PCI configuration
    space? I'm using a 2.6 SMP kernel. It seems i should be using
    pci_config_read_dword but i dont see how to specify the bus/dev/fn/
    in struct pci_dev. How do i initialize that structure? Whats the
    correct way (which vars) to specify the bus dev/fn?
    Is there a more preferred api i should be using?
    Any simple examples reading device/vendor id would be very helpful
    Thanks
    Eric


  2. Re: reading pci cfg space from kernel module

    On Oct 25, 5:51 pm, Eric wrote:
    > What is the standard kernel module api for reading/writing PCI configuration
    > space? I'm using a 2.6 SMP kernel. It seems i should be using
    > pci_config_read_dword but i dont see how to specify the bus/dev/fn/
    > in struct pci_dev. How do i initialize that structure?


    pci_dev comes from a call to pci_get_device() which takes the
    vendor ID and device ID as parameters.

    A word of warning on using the pci_config_read_ functions:
    You will want to get most of the config space info from the
    pci_dev structure itself rather than reading the config
    registers on the card. Especially the interrupt and BARs.
    The values for these can be changed by the OS without
    updating the card's registers.

    > Any simple examples reading device/vendor id would be very helpful


    grep for the above function in the kernel source and you'll
    see lots of examples. The Ethernet drivers are good ones.

    Steve


  3. Re: reading pci cfg space from kernel module

    steve_schefter@hotmail.com wrote:

    > On Oct 25, 5:51 pm, Eric wrote:
    >> What is the standard kernel module api for reading/writing PCI
    >> configuration space? I'm using a 2.6 SMP kernel. It seems i should be
    >> using pci_config_read_dword but i dont see how to specify the bus/dev/fn/
    >> in struct pci_dev. How do i initialize that structure?

    >
    > pci_dev comes from a call to pci_get_device() which takes the
    > vendor ID and device ID as parameters.
    >
    > A word of warning on using the pci_config_read_ functions:
    > You will want to get most of the config space info from the
    > pci_dev structure itself rather than reading the config
    > registers on the card. Especially the interrupt and BARs.
    > The values for these can be changed by the OS without
    > updating the card's registers.
    >
    >> Any simple examples reading device/vendor id would be very helpful

    >
    > grep for the above function in the kernel source and you'll
    > see lots of examples. The Ethernet drivers are good ones.
    >
    > Steve

    ok - thanks
    Eric


+ Reply to Thread