]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
inmates: pci: allow pci_find_device to discover multiple devices
authorHenning Schild <henning.schild@siemens.com>
Fri, 19 Sep 2014 14:35:26 +0000 (16:35 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 25 Sep 2014 13:47:08 +0000 (15:47 +0200)
Systems can have more than one PCI device with the same vendor/device
id pair. Change the discovery helper to allow searching for more than
just the first bdf.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates/demos/x86/e1000-demo.c
inmates/demos/x86/pci-demo.c
inmates/lib/pci.c
inmates/lib/x86/inmate.h

index 5225ee1468cc8b79f8df5da1421ff47d9b0f019b..49d9a36b8cfca04efb29279ce2313b58a4cd81c6 100644 (file)
@@ -175,7 +175,7 @@ void inmate_main(void)
 
        printk_uart_base = UART_BASE;
 
-       bdf = pci_find_device(PCI_ID_ANY, PCI_ID_ANY);
+       bdf = pci_find_device(PCI_ID_ANY, PCI_ID_ANY, 0);
        if (bdf < 0) {
                printk("No device found!\n");
                return;
index 8412793ea331d66cac8ea2c591c231b862aafc14..fb85bc28bd064b2b7e457fe4b3457bd52bf9f871 100644 (file)
@@ -50,7 +50,7 @@ void inmate_main(void)
        int_init();
        int_set_handler(IRQ_VECTOR, irq_handler);
 
-       bdf = pci_find_device(PCI_ID_ANY, PCI_ID_ANY);
+       bdf = pci_find_device(PCI_ID_ANY, PCI_ID_ANY, 0);
        if (bdf < 0) {
                printk("No device found!\n");
                return;
index af82d21deeb3934d718426a398b9b175b01b10a2..180062dbc1872b432ac3baa849ea1943066993b0 100644 (file)
  * the COPYING file in the top-level directory.
  */
 
-int pci_find_device(u16 vendor, u16 device)
+int pci_find_device(u16 vendor, u16 device, u16 start_bdf)
 {
        unsigned int bdf;
        u16 id;
 
-       for (bdf = 0; bdf < 0x10000; bdf++) {
+       for (bdf = start_bdf; bdf < 0x10000; bdf++) {
                id = pci_read_config(bdf, PCI_CFG_VENDOR_ID, 2);
                if (id == PCI_ID_ANY || (vendor != PCI_ID_ANY && vendor != id))
                        continue;
index cccf0259978ceb200b2b5dc69187316062802059..07321c01bb79c5ecb8770fb2d45724d50efbc169 100644 (file)
@@ -226,7 +226,7 @@ void map_range(void *start, unsigned long size, enum map_type map_type);
 u32 pci_read_config(u16 bdf, unsigned int addr, unsigned int size);
 void pci_write_config(u16 bdf, unsigned int addr, u32 value,
                      unsigned int size);
-int pci_find_device(u16 vendor, u16 device);
+int pci_find_device(u16 vendor, u16 device, u16 start_bdf);
 int pci_find_cap(u16 bdf, u16 cap);
 void pci_msi_set_vector(u16 bdf, unsigned int vector);
 #endif