This patch series is the last of the 'struct pci_device' code conversions. The goal of this series is to replace the use of 'u16 bdf' with 'struct pci_device' in the boot priority code. At the end of this series the 'find_pci()' code, which was introduced in the beginning of the pci_device conversion, can be removed.
-Kevin
Kevin O'Connor (7): Push 'struct pci_device' into USB code (instead of using u16 bdf). Push use of 'struct pci_device' to bootprio_find_usb(). Push use of 'struct pci_device' to bootprio_find_pci_device(). Push use of 'struct pci_device' to bootprio_find_fdc_device(). Push use of 'struct pci_device' to bootprio_find_ata_device(). Push use of 'struct pci_device' to bootprio_find_pci_rom(). Remove now unneeded find_pci().
src/ata.c | 20 +++++++++++--------- src/ata.h | 1 + src/boot.c | 37 ++++++++++++------------------------- src/boot.h | 11 ++++++----- src/floppy.c | 2 +- src/optionroms.c | 4 ++-- src/usb-ehci.c | 40 +++++++++++++++------------------------- src/usb-ehci.h | 2 +- src/usb-msc.c | 4 ++-- src/usb-ohci.c | 5 +++-- src/usb-ohci.h | 2 +- src/usb-uhci.c | 5 +++-- src/usb-uhci.h | 2 +- src/usb.c | 6 +++--- src/usb.h | 2 +- src/virtio-blk.c | 7 ++++--- 16 files changed, 67 insertions(+), 83 deletions(-)
--- src/usb-ehci.c | 40 +++++++++++++++------------------------- src/usb-ehci.h | 2 +- src/usb-msc.c | 5 +++-- src/usb-ohci.c | 5 +++-- src/usb-ohci.h | 2 +- src/usb-uhci.c | 5 +++-- src/usb-uhci.h | 2 +- src/usb.c | 6 +++--- src/usb.h | 2 +- 9 files changed, 31 insertions(+), 38 deletions(-)
diff --git a/src/usb-ehci.c b/src/usb-ehci.c index 5a0eb3e..4e86427 100644 --- a/src/usb-ehci.c +++ b/src/usb-ehci.c @@ -16,17 +16,12 @@ #include "usb-uhci.h" // init_uhci #include "usb-ohci.h" // init_ohci
-struct companion_s { - u16 bdf; - u16 type; -}; - struct usb_ehci_s { struct usb_s usb; struct ehci_caps *caps; struct ehci_regs *regs; struct ehci_qh *async_qh; - struct companion_s companion[8]; + struct pci_device *companion[8]; int checkports; int legacycount; }; @@ -52,11 +47,11 @@ ehci_note_port(struct usb_ehci_s *cntl) // Start companion controllers. int i; for (i=0; i<ARRAY_SIZE(cntl->companion); i++) { - u16 type = cntl->companion[i].type; - if (type == USB_TYPE_UHCI) - uhci_init(cntl->companion[i].bdf, cntl->usb.busid + i); - else if (type == USB_TYPE_OHCI) - ohci_init(cntl->companion[i].bdf, cntl->usb.busid + i); + struct pci_device *pci = cntl->companion[i]; + if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_UHCI) + uhci_init(pci, cntl->usb.busid + i); + else if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_OHCI) + ohci_init(pci, cntl->usb.busid + i); else return; } @@ -249,11 +244,12 @@ fail: }
int -ehci_init(u16 bdf, int busid, int compbdf) +ehci_init(struct pci_device *pci, int busid, struct pci_device *comppci) { if (! CONFIG_USB_EHCI) return -1;
+ u16 bdf = pci->bdf; u32 baseaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0); struct ehci_caps *caps = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK); u32 hcc_params = readl(&caps->hccparams); @@ -265,7 +261,7 @@ ehci_init(u16 bdf, int busid, int compbdf) struct usb_ehci_s *cntl = malloc_tmphigh(sizeof(*cntl)); memset(cntl, 0, sizeof(*cntl)); cntl->usb.busid = busid; - cntl->usb.bdf = bdf; + cntl->usb.pci = pci; cntl->usb.type = USB_TYPE_EHCI; cntl->caps = caps; cntl->regs = (void*)caps + readb(&caps->caplength); @@ -281,19 +277,13 @@ ehci_init(u16 bdf, int busid, int compbdf) // Find companion controllers. int count = 0; for (;;) { - if (compbdf < 0 || compbdf >= bdf) + if (!comppci || comppci == pci) break; - u32 code = pci_config_readl(compbdf, PCI_CLASS_REVISION) >> 8; - if (code == PCI_CLASS_SERIAL_USB_UHCI) { - cntl->companion[count].bdf = compbdf; - cntl->companion[count].type = USB_TYPE_UHCI; - count++; - } else if (code == PCI_CLASS_SERIAL_USB_OHCI) { - cntl->companion[count].bdf = compbdf; - cntl->companion[count].type = USB_TYPE_OHCI; - count++; - } - compbdf = pci_next(compbdf+1, pci_bdf_to_bus(compbdf)); + if (pci_classprog(comppci) == PCI_CLASS_SERIAL_USB_UHCI) + cntl->companion[count++] = comppci; + else if (pci_classprog(comppci) == PCI_CLASS_SERIAL_USB_OHCI) + cntl->companion[count++] = comppci; + comppci = comppci->next; }
run_thread(configure_ehci, cntl); diff --git a/src/usb-ehci.h b/src/usb-ehci.h index bb8df52..1a2c6c7 100644 --- a/src/usb-ehci.h +++ b/src/usb-ehci.h @@ -2,7 +2,7 @@ #define __USB_EHCI_H
// usb-ehci.c -int ehci_init(u16 bdf, int busid, int compbdf); +int ehci_init(struct pci_device *pci, int busid, struct pci_device *comppci); struct usb_pipe; void ehci_free_pipe(struct usb_pipe *p); struct usb_pipe *ehci_alloc_control_pipe(struct usb_pipe *dummy); diff --git a/src/usb-msc.c b/src/usb-msc.c index 1aa57d1..a57e4d2 100644 --- a/src/usb-msc.c +++ b/src/usb-msc.c @@ -12,6 +12,7 @@ #include "blockcmd.h" // cdb_read #include "disk.h" // DTYPE_USB #include "boot.h" // boot_add_hd +#include "pci.h" // struct pci_device
struct usbdrive_s { struct drive_s drive; @@ -145,7 +146,7 @@ setup_drive_cdrom(struct disk_op_s *op, char *desc) op->drive_g->sectors = (u64)-1; struct usb_pipe *pipe = container_of( op->drive_g, struct usbdrive_s, drive)->bulkout; - int prio = bootprio_find_usb(pipe->cntl->bdf, pipe->path); + int prio = bootprio_find_usb(pipe->cntl->pci->bdf, pipe->path); boot_add_cd(op->drive_g, desc, prio); return 0; } @@ -173,7 +174,7 @@ setup_drive_hd(struct disk_op_s *op, char *desc) // Register with bcv system. struct usb_pipe *pipe = container_of( op->drive_g, struct usbdrive_s, drive)->bulkout; - int prio = bootprio_find_usb(pipe->cntl->bdf, pipe->path); + int prio = bootprio_find_usb(pipe->cntl->pci->bdf, pipe->path); boot_add_hd(op->drive_g, desc, prio);
return 0; diff --git a/src/usb-ohci.c b/src/usb-ohci.c index 72b9f68..317f200 100644 --- a/src/usb-ohci.c +++ b/src/usb-ohci.c @@ -204,16 +204,17 @@ free: }
void -ohci_init(u16 bdf, int busid) +ohci_init(struct pci_device *pci, int busid) { if (! CONFIG_USB_OHCI) return; struct usb_ohci_s *cntl = malloc_tmphigh(sizeof(*cntl)); memset(cntl, 0, sizeof(*cntl)); cntl->usb.busid = busid; - cntl->usb.bdf = bdf; + cntl->usb.pci = pci; cntl->usb.type = USB_TYPE_OHCI;
+ u16 bdf = pci->bdf; u32 baseaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0); cntl->regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK);
diff --git a/src/usb-ohci.h b/src/usb-ohci.h index 7dd2f09..c7670ff 100644 --- a/src/usb-ohci.h +++ b/src/usb-ohci.h @@ -2,7 +2,7 @@ #define __USB_OHCI_H
// usb-ohci.c -void ohci_init(u16 bdf, int busid); +void ohci_init(struct pci_device *pci, int busid); struct usb_pipe; void ohci_free_pipe(struct usb_pipe *p); struct usb_pipe *ohci_alloc_control_pipe(struct usb_pipe *dummy); diff --git a/src/usb-uhci.c b/src/usb-uhci.c index 40f83bb..6e45474 100644 --- a/src/usb-uhci.c +++ b/src/usb-uhci.c @@ -179,14 +179,15 @@ fail: }
void -uhci_init(u16 bdf, int busid) +uhci_init(struct pci_device *pci, int busid) { if (! CONFIG_USB_UHCI) return; + u16 bdf = pci->bdf; struct usb_uhci_s *cntl = malloc_tmphigh(sizeof(*cntl)); memset(cntl, 0, sizeof(*cntl)); cntl->usb.busid = busid; - cntl->usb.bdf = bdf; + cntl->usb.pci = pci; cntl->usb.type = USB_TYPE_UHCI; cntl->iobase = (pci_config_readl(bdf, PCI_BASE_ADDRESS_4) & PCI_BASE_ADDRESS_IO_MASK); diff --git a/src/usb-uhci.h b/src/usb-uhci.h index 3c2c298..b5f70f7 100644 --- a/src/usb-uhci.h +++ b/src/usb-uhci.h @@ -2,7 +2,7 @@ #define __USB_UHCI_H
// usb-uhci.c -void uhci_init(u16 bdf, int busid); +void uhci_init(struct pci_device *pci, int busid); struct usb_pipe; void uhci_free_pipe(struct usb_pipe *p); struct usb_pipe *uhci_alloc_control_pipe(struct usb_pipe *dummy); diff --git a/src/usb.c b/src/usb.c index 26d1017..1f69d16 100644 --- a/src/usb.c +++ b/src/usb.c @@ -442,7 +442,7 @@ usb_setup(void) for (;;) { if (pci_classprog(ehcipci) == PCI_CLASS_SERIAL_USB_EHCI) { // Found an ehci controller. - int ret = ehci_init(ehcipci->bdf, count++, pci->bdf); + int ret = ehci_init(ehcipci, count++, pci); if (ret) // Error break; @@ -461,8 +461,8 @@ usb_setup(void) }
if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_UHCI) - uhci_init(pci->bdf, count++); + uhci_init(pci, count++); else if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_OHCI) - ohci_init(pci->bdf, count++); + ohci_init(pci, count++); } } diff --git a/src/usb.h b/src/usb.h index 966e94b..8b2af40 100644 --- a/src/usb.h +++ b/src/usb.h @@ -21,8 +21,8 @@ struct usb_pipe { struct usb_s { struct usb_pipe *defaultpipe; struct mutex_s resetlock; + struct pci_device *pci; int busid; - u16 bdf; u8 type; u8 maxaddr; };
--- src/boot.c | 4 ++-- src/boot.h | 3 ++- src/usb-msc.c | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/boot.c b/src/boot.c index fcc95ab..58fb70b 100644 --- a/src/boot.c +++ b/src/boot.c @@ -193,14 +193,14 @@ int bootprio_find_named_rom(const char *name, int instance) return find_prio(desc); }
-int bootprio_find_usb(int bdf, u64 path) +int bootprio_find_usb(struct pci_device *pci, u64 path) { if (!CONFIG_BOOTORDER) return -1; // Find usb - for example: /pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0 int i; char desc[256], *p; - p = build_pci_path(desc, sizeof(desc), "usb", find_pci(bdf)); + p = build_pci_path(desc, sizeof(desc), "usb", pci); for (i=56; i>0; i-=8) { int port = (path >> i) & 0xff; if (port != 0xff) diff --git a/src/boot.h b/src/boot.h index a6f358f..6495002 100644 --- a/src/boot.h +++ b/src/boot.h @@ -12,11 +12,12 @@ void boot_add_hd(struct drive_s *drive_g, const char *desc, int prio); void boot_add_cd(struct drive_s *drive_g, const char *desc, int prio); void boot_add_cbfs(void *data, const char *desc, int prio); void boot_prep(void); +struct pci_device; int bootprio_find_pci_device(int bdf); int bootprio_find_ata_device(int bdf, int chanid, int slave); int bootprio_find_fdc_device(int bdf, int port, int fdid); int bootprio_find_pci_rom(int bdf, int instance); int bootprio_find_named_rom(const char *name, int instance); -int bootprio_find_usb(int bdf, u64 path); +int bootprio_find_usb(struct pci_device *pci, u64 path);
#endif // __BOOT_H diff --git a/src/usb-msc.c b/src/usb-msc.c index a57e4d2..13ef93e 100644 --- a/src/usb-msc.c +++ b/src/usb-msc.c @@ -12,7 +12,6 @@ #include "blockcmd.h" // cdb_read #include "disk.h" // DTYPE_USB #include "boot.h" // boot_add_hd -#include "pci.h" // struct pci_device
struct usbdrive_s { struct drive_s drive; @@ -146,7 +145,7 @@ setup_drive_cdrom(struct disk_op_s *op, char *desc) op->drive_g->sectors = (u64)-1; struct usb_pipe *pipe = container_of( op->drive_g, struct usbdrive_s, drive)->bulkout; - int prio = bootprio_find_usb(pipe->cntl->pci->bdf, pipe->path); + int prio = bootprio_find_usb(pipe->cntl->pci, pipe->path); boot_add_cd(op->drive_g, desc, prio); return 0; } @@ -174,7 +173,7 @@ setup_drive_hd(struct disk_op_s *op, char *desc) // Register with bcv system. struct usb_pipe *pipe = container_of( op->drive_g, struct usbdrive_s, drive)->bulkout; - int prio = bootprio_find_usb(pipe->cntl->pci->bdf, pipe->path); + int prio = bootprio_find_usb(pipe->cntl->pci, pipe->path); boot_add_hd(op->drive_g, desc, prio);
return 0;
--- src/boot.c | 4 ++-- src/boot.h | 2 +- src/virtio-blk.c | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 58fb70b..5c0e0bb 100644 --- a/src/boot.c +++ b/src/boot.c @@ -131,13 +131,13 @@ build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci) return p; }
-int bootprio_find_pci_device(int bdf) +int bootprio_find_pci_device(struct pci_device *pci) { if (!CONFIG_BOOTORDER) return -1; // Find pci device - for example: /pci@i0cf8/ethernet@5 char desc[256]; - build_pci_path(desc, sizeof(desc), "*", find_pci(bdf)); + build_pci_path(desc, sizeof(desc), "*", pci); return find_prio(desc); }
diff --git a/src/boot.h b/src/boot.h index 6495002..92af9da 100644 --- a/src/boot.h +++ b/src/boot.h @@ -13,7 +13,7 @@ void boot_add_cd(struct drive_s *drive_g, const char *desc, int prio); void boot_add_cbfs(void *data, const char *desc, int prio); void boot_prep(void); struct pci_device; -int bootprio_find_pci_device(int bdf); +int bootprio_find_pci_device(struct pci_device *pci); int bootprio_find_ata_device(int bdf, int chanid, int slave); int bootprio_find_fdc_device(int bdf, int port, int fdid); int bootprio_find_pci_rom(int bdf, int instance); diff --git a/src/virtio-blk.c b/src/virtio-blk.c index 4e3ef06..b1274fc 100644 --- a/src/virtio-blk.c +++ b/src/virtio-blk.c @@ -97,8 +97,9 @@ process_virtio_op(struct disk_op_s *op) }
static void -init_virtio_blk(u16 bdf) +init_virtio_blk(struct pci_device *pci) { + u16 bdf = pci->bdf; dprintf(1, "found virtio-blk at %x:%x\n", pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); struct virtiodrive_s *vdrive_g = malloc_fseg(sizeof(*vdrive_g)); @@ -153,7 +154,7 @@ init_virtio_blk(u16 bdf) char *desc = znprintf(MAXDESCSIZE, "Virtio disk PCI:%x:%x", pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf));
- boot_add_hd(&vdrive_g->drive, desc, bootprio_find_pci_device(bdf)); + boot_add_hd(&vdrive_g->drive, desc, bootprio_find_pci_device(pci));
vp_set_status(ioaddr, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK); @@ -178,6 +179,6 @@ virtio_blk_setup(void) if (pci->vendor != PCI_VENDOR_ID_REDHAT_QUMRANET || pci->device != PCI_DEVICE_ID_VIRTIO_BLK) continue; - init_virtio_blk(pci->bdf); + init_virtio_blk(pci); } }
--- src/boot.c | 6 +++--- src/boot.h | 2 +- src/floppy.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 5c0e0bb..f769339 100644 --- a/src/boot.c +++ b/src/boot.c @@ -155,16 +155,16 @@ int bootprio_find_ata_device(int bdf, int chanid, int slave) return find_prio(desc); }
-int bootprio_find_fdc_device(int bdf, int port, int fdid) +int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid) { if (!CONFIG_BOOTORDER) return -1; - if (bdf == -1) + if (!pci) // support only pci machine for now return -1; // Find floppy - for example: /pci@i0cf8/isa@1/fdc@03f1/floppy@0 char desc[256], *p; - p = build_pci_path(desc, sizeof(desc), "isa", find_pci(bdf)); + p = build_pci_path(desc, sizeof(desc), "isa", pci); snprintf(p, desc+sizeof(desc)-p, "/fdc@%04x/floppy@%x", port, fdid); return find_prio(desc); } diff --git a/src/boot.h b/src/boot.h index 92af9da..ae8ff89 100644 --- a/src/boot.h +++ b/src/boot.h @@ -15,7 +15,7 @@ void boot_prep(void); struct pci_device; int bootprio_find_pci_device(struct pci_device *pci); int bootprio_find_ata_device(int bdf, int chanid, int slave); -int bootprio_find_fdc_device(int bdf, int port, int fdid); +int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid); int bootprio_find_pci_rom(int bdf, int instance); int bootprio_find_named_rom(const char *name, int instance); int bootprio_find_usb(struct pci_device *pci, u64 path); diff --git a/src/floppy.c b/src/floppy.c index 8009af0..383744a 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -124,7 +124,7 @@ addFloppy(int floppyid, int ftype) return; char *desc = znprintf(MAXDESCSIZE, "Floppy [drive %c]", 'A' + floppyid); struct pci_device *pci = pci_find_class(PCI_CLASS_BRIDGE_ISA); /* isa-to-pci bridge */ - int prio = bootprio_find_fdc_device(pci->bdf, PORT_FD_BASE, floppyid); + int prio = bootprio_find_fdc_device(pci, PORT_FD_BASE, floppyid); boot_add_floppy(drive_g, desc, prio); }
--- src/ata.c | 20 +++++++++++--------- src/ata.h | 1 + src/boot.c | 6 +++--- src/boot.h | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/ata.c b/src/ata.c index 79bc76f..76e4f20 100644 --- a/src/ata.c +++ b/src/ata.c @@ -776,7 +776,7 @@ init_drive_atapi(struct atadrive_s *dummy, u16 *buffer)
// fill cdidmap if (iscd) { - int prio = bootprio_find_ata_device(adrive_g->chan_gf->pci_bdf, + int prio = bootprio_find_ata_device(adrive_g->chan_gf->pci_tmp, adrive_g->chan_gf->chanid, adrive_g->slave); boot_add_cd(&adrive_g->drive, desc, prio); @@ -826,7 +826,7 @@ init_drive_ata(struct atadrive_s *dummy, u16 *buffer) , (u32)adjsize, adjprefix); dprintf(1, "%s\n", desc);
- int prio = bootprio_find_ata_device(adrive_g->chan_gf->pci_bdf, + int prio = bootprio_find_ata_device(adrive_g->chan_gf->pci_tmp, adrive_g->chan_gf->chanid, adrive_g->slave); // Register with bcv system. @@ -941,7 +941,8 @@ ata_detect(void *data)
// Initialize an ata controller and detect its drives. static void -init_controller(int bdf, int irq, u32 port1, u32 port2, u32 master) +init_controller(struct pci_device *pci, int irq + , u32 port1, u32 port2, u32 master) { static int chanid = 0; struct ata_channel_s *chan_gf = malloc_fseg(sizeof(*chan_gf)); @@ -951,12 +952,13 @@ init_controller(int bdf, int irq, u32 port1, u32 port2, u32 master) } chan_gf->chanid = chanid++; chan_gf->irq = irq; - chan_gf->pci_bdf = bdf; + chan_gf->pci_bdf = pci ? pci->bdf : -1; + chan_gf->pci_tmp = pci; chan_gf->iobase1 = port1; chan_gf->iobase2 = port2; chan_gf->iomaster = master; dprintf(1, "ATA controller %d at %x/%x/%x (irq %d dev %x)\n" - , chanid, port1, port2, master, irq, bdf); + , chanid, port1, port2, master, irq, chan_gf->pci_bdf); run_thread(ata_detect, chan_gf); }
@@ -992,7 +994,7 @@ init_pciata(struct pci_device *pci, u8 prog_if) port2 = PORT_ATA1_CTRL_BASE; irq = IRQ_ATA1; } - init_controller(bdf, irq, port1, port2, master); + init_controller(pci, irq, port1, port2, master);
if (prog_if & 4) { port1 = (pci_config_readl(bdf, PCI_BASE_ADDRESS_2) @@ -1005,7 +1007,7 @@ init_pciata(struct pci_device *pci, u8 prog_if) port2 = PORT_ATA2_CTRL_BASE; irq = IRQ_ATA2; } - init_controller(bdf, irq, port1, port2, master ? master + 8 : 0); + init_controller(pci, irq, port1, port2, master ? master + 8 : 0); }
static void @@ -1037,9 +1039,9 @@ ata_init(void) if (!CONFIG_COREBOOT && !PCIDevices) { // No PCI devices found - probably a QEMU "-M isapc" machine. // Try using ISA ports for ATA controllers. - init_controller(-1, IRQ_ATA1 + init_controller(NULL, IRQ_ATA1 , PORT_ATA1_CMD_BASE, PORT_ATA1_CTRL_BASE, 0); - init_controller(-1, IRQ_ATA2 + init_controller(NULL, IRQ_ATA2 , PORT_ATA2_CMD_BASE, PORT_ATA2_CTRL_BASE, 0); return; } diff --git a/src/ata.h b/src/ata.h index 8fa2872..cfc6108 100644 --- a/src/ata.h +++ b/src/ata.h @@ -12,6 +12,7 @@ struct ata_channel_s { u8 irq; u8 chanid; int pci_bdf; + struct pci_device *pci_tmp; };
struct atadrive_s { diff --git a/src/boot.c b/src/boot.c index f769339..3fda39a 100644 --- a/src/boot.c +++ b/src/boot.c @@ -141,16 +141,16 @@ int bootprio_find_pci_device(struct pci_device *pci) return find_prio(desc); }
-int bootprio_find_ata_device(int bdf, int chanid, int slave) +int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave) { if (!CONFIG_BOOTORDER) return -1; - if (bdf == -1) + if (!pci) // support only pci machine for now return -1; // Find ata drive - for example: /pci@i0cf8/ide@1,1/drive@1/disk@0 char desc[256], *p; - p = build_pci_path(desc, sizeof(desc), "*", find_pci(bdf)); + p = build_pci_path(desc, sizeof(desc), "*", pci); snprintf(p, desc+sizeof(desc)-p, "/drive@%x/disk@%x", chanid, slave); return find_prio(desc); } diff --git a/src/boot.h b/src/boot.h index ae8ff89..78d4f3b 100644 --- a/src/boot.h +++ b/src/boot.h @@ -14,7 +14,7 @@ void boot_add_cbfs(void *data, const char *desc, int prio); void boot_prep(void); struct pci_device; int bootprio_find_pci_device(struct pci_device *pci); -int bootprio_find_ata_device(int bdf, int chanid, int slave); +int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave); int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid); int bootprio_find_pci_rom(int bdf, int instance); int bootprio_find_named_rom(const char *name, int instance);
--- src/boot.c | 4 ++-- src/boot.h | 2 +- src/optionroms.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 3fda39a..4e86477 100644 --- a/src/boot.c +++ b/src/boot.c @@ -169,13 +169,13 @@ int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid) return find_prio(desc); }
-int bootprio_find_pci_rom(int bdf, int instance) +int bootprio_find_pci_rom(struct pci_device *pci, int instance) { if (!CONFIG_BOOTORDER) return -1; // Find pci rom - for example: /pci@i0cf8/scsi@3:rom2 char desc[256], *p; - p = build_pci_path(desc, sizeof(desc), "*", find_pci(bdf)); + p = build_pci_path(desc, sizeof(desc), "*", pci); if (instance) snprintf(p, desc+sizeof(desc)-p, ":rom%d", instance); return find_prio(desc); diff --git a/src/boot.h b/src/boot.h index 78d4f3b..d776aa1 100644 --- a/src/boot.h +++ b/src/boot.h @@ -16,7 +16,7 @@ struct pci_device; int bootprio_find_pci_device(struct pci_device *pci); int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave); int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid); -int bootprio_find_pci_rom(int bdf, int instance); +int bootprio_find_pci_rom(struct pci_device *pci, int instance); int bootprio_find_named_rom(const char *name, int instance); int bootprio_find_usb(struct pci_device *pci, u64 path);
diff --git a/src/optionroms.c b/src/optionroms.c index 3d1a1e4..be02f2a 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -230,7 +230,7 @@ getRomPriority(u64 *sources, struct rom_header *rom, int instance) if (!source) return -1; if (source & RS_PCIROM) - return bootprio_find_pci_rom(source, instance); + return bootprio_find_pci_rom((void*)(u32)source, instance); return bootprio_find_named_rom(romfile_name(source), instance); }
@@ -379,7 +379,7 @@ init_pcirom(struct pci_device *pci, int isvga, u64 *sources) if (! rom) // No ROM present. return -1; - setRomSource(sources, rom, RS_PCIROM | bdf); + setRomSource(sources, rom, RS_PCIROM | (u32)pci); return init_optionrom(rom, bdf, isvga); }
--- src/boot.c | 13 ------------- 1 files changed, 0 insertions(+), 13 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 4e86477..119f290 100644 --- a/src/boot.c +++ b/src/boot.c @@ -98,22 +98,9 @@ find_prio(const char *glob)
#define FW_PCI_DOMAIN "/pci@i0cf8"
-static struct pci_device * -find_pci(u16 bdf) -{ - struct pci_device *pci; - foreachpci(pci) { - if (pci->bdf == bdf) - return pci; - } - return NULL; -} - static char * build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci) { - if (!pci) - return buf; // Build the string path of a bdf - for example: /pci@i0cf8/isa@1,2 char *p = buf; if (pci->parent) {