4.115
Last change
on this file since e53daed was
e53daed,
checked in by Daniel Hellstrom <daniel@…>, on 04/09/15 at 14:09:42
|
LIBPCI: updated license to rtems.org
|
-
Property mode set to
100644
|
File size:
1017 bytes
|
Rev | Line | |
---|
[a31845f7] | 1 | /* PCI Help function, Find a PCI device by VENDOR/DEVICE ID |
---|
| 2 | * |
---|
[71e8a5c] | 3 | * COPYRIGHT (c) 2010 Cobham Gaisler AB. |
---|
[a31845f7] | 4 | * |
---|
| 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
[e53daed] | 7 | * http://www.rtems.org/license/LICENSE. |
---|
[a31845f7] | 8 | */ |
---|
| 9 | |
---|
| 10 | #include <pci.h> |
---|
| 11 | #include <pci/cfg.h> |
---|
| 12 | |
---|
| 13 | struct compare_info { |
---|
| 14 | int index; |
---|
| 15 | uint16_t vendor; |
---|
| 16 | uint16_t device; |
---|
| 17 | }; |
---|
| 18 | |
---|
| 19 | static int compare_dev_id(struct pci_dev *dev, void *arg) |
---|
| 20 | { |
---|
| 21 | struct compare_info *info = arg; |
---|
| 22 | |
---|
| 23 | if ((dev->vendor != info->vendor) || (dev->device != info->device)) |
---|
| 24 | return 0; |
---|
| 25 | if (info->index-- == 0) |
---|
| 26 | return (int)dev; |
---|
| 27 | else |
---|
| 28 | return 0; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | /* Find a Device in PCI device tree located in RAM */ |
---|
| 32 | int pci_find_dev(uint16_t ven, uint16_t dev, int index, struct pci_dev **ppdev) |
---|
| 33 | { |
---|
| 34 | struct compare_info info; |
---|
| 35 | int result; |
---|
| 36 | |
---|
| 37 | info.index = index; |
---|
| 38 | info.vendor = ven; |
---|
| 39 | info.device = dev; |
---|
| 40 | |
---|
| 41 | result = pci_for_each_dev(compare_dev_id, &info); |
---|
| 42 | if (ppdev) |
---|
| 43 | *ppdev = (struct pci_dev *)result; |
---|
| 44 | if (result == 0) |
---|
| 45 | return -1; |
---|
| 46 | else |
---|
| 47 | return 0; |
---|
| 48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.