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
Re: reading pci cfg space from kernel module
On Oct 25, 5:51 pm, Eric <No...@invalid.com> wrote:[color=blue]
> 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?[/color]
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.
[color=blue]
> Any simple examples reading device/vendor id would be very helpful[/color]
grep for the above function in the kernel source and you'll
see lots of examples. The Ethernet drivers are good ones.
Steve
Re: reading pci cfg space from kernel module
[email]steve_schefter@hotmail.com[/email] wrote:
[color=blue]
> On Oct 25, 5:51 pm, Eric <No...@invalid.com> wrote:[color=green]
>> 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?[/color]
>
> 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.
>[color=green]
>> Any simple examples reading device/vendor id would be very helpful[/color]
>
> grep for the above function in the kernel source and you'll
> see lots of examples. The Ethernet drivers are good ones.
>
> Steve[/color]
ok - thanks
Eric