diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-02-03 03:03:15 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-02-03 10:38:20 -0500 |
commit | 7b67300f7d9db7dcf855e201db2f0da8f318e40d (patch) | |
tree | 140ff3110ad5ac93e0e812b855a6fd55b7633262 | |
parent | 01a30dc7e38859125f4120e4f10f26af4049daf7 (diff) | |
download | seabios-hppa-7b67300f7d9db7dcf855e201db2f0da8f318e40d.zip seabios-hppa-7b67300f7d9db7dcf855e201db2f0da8f318e40d.tar.gz seabios-hppa-7b67300f7d9db7dcf855e201db2f0da8f318e40d.tar.bz2 |
pci: Implement '%pP' printf handler for 'struct pci_device' pointers
Handle '%pP' format descriptions as a pointer to a 'struct pci_device'
and display it in bus:device.function (%02x:%02x.%x) format.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | src/fw/pciinit.c | 25 | ||||
-rw-r--r-- | src/hw/ahci.c | 5 | ||||
-rw-r--r-- | src/hw/esp-scsi.c | 8 | ||||
-rw-r--r-- | src/hw/lsi-scsi.c | 8 | ||||
-rw-r--r-- | src/hw/megasas.c | 8 | ||||
-rw-r--r-- | src/hw/pci.c | 6 | ||||
-rw-r--r-- | src/hw/pvscsi.c | 8 | ||||
-rw-r--r-- | src/hw/usb-ehci.c | 4 | ||||
-rw-r--r-- | src/hw/usb-ohci.c | 4 | ||||
-rw-r--r-- | src/hw/usb-uhci.c | 4 | ||||
-rw-r--r-- | src/hw/usb-xhci.c | 7 | ||||
-rw-r--r-- | src/hw/virtio-blk.c | 39 | ||||
-rw-r--r-- | src/hw/virtio-pci.c | 11 | ||||
-rw-r--r-- | src/hw/virtio-scsi.c | 13 | ||||
-rw-r--r-- | src/optionroms.c | 19 | ||||
-rw-r--r-- | src/output.c | 18 |
16 files changed, 74 insertions, 113 deletions
diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 6b1c902..8e6716d 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -306,12 +306,11 @@ void pci_resume(void) static void pci_bios_init_device(struct pci_device *pci) { - u16 bdf = pci->bdf; - dprintf(1, "PCI: init bdf=%02x:%02x.%x id=%04x:%04x\n" - , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf) - , pci->vendor, pci->device); + dprintf(1, "PCI: init bdf=%pP id=%04x:%04x\n" + , pci, pci->vendor, pci->device); /* map the interrupt */ + u16 bdf = pci->bdf; int pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN); if (pin != 0) pci_config_writeb(bdf, PCI_INTERRUPT_LINE, pci_slot_get_irq(pci, pin)); @@ -341,9 +340,7 @@ static void pci_enable_default_vga(void) foreachpci(pci) { if (is_pci_vga(pci)) { - dprintf(1, "PCI: Using %02x:%02x.%x for primary VGA\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf)); + dprintf(1, "PCI: Using %pP for primary VGA\n", pci); return; } } @@ -354,9 +351,7 @@ static void pci_enable_default_vga(void) return; } - dprintf(1, "PCI: Enabling %02x:%02x.%x for primary VGA\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf)); + dprintf(1, "PCI: Enabling %pP for primary VGA\n", pci); pci_config_maskw(pci->bdf, PCI_COMMAND, 0, PCI_COMMAND_IO | PCI_COMMAND_MEMORY); @@ -364,9 +359,7 @@ static void pci_enable_default_vga(void) while (pci->parent) { pci = pci->parent; - dprintf(1, "PCI: Setting VGA enable on bridge %02x:%02x.%x\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf)); + dprintf(1, "PCI: Setting VGA enable on bridge %pP\n", pci); pci_config_maskw(pci->bdf, PCI_BRIDGE_CONTROL, 0, PCI_BRIDGE_CTL_VGA); pci_config_maskw(pci->bdf, PCI_COMMAND, 0, @@ -821,17 +814,17 @@ static int pci_bios_init_root_regions_mem(struct pci_bus *bus) static void pci_region_map_one_entry(struct pci_region_entry *entry, u64 addr) { - u16 bdf = entry->dev->bdf; if (entry->bar >= 0) { - dprintf(1, "PCI: map device bdf=%02x:%02x.%x" + dprintf(1, "PCI: map device bdf=%pP" " bar %d, addr %08llx, size %08llx [%s]\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf), + entry->dev, entry->bar, addr, entry->size, region_type_name[entry->type]); pci_set_io_region_addr(entry->dev, entry->bar, addr, entry->is64); return; } + u16 bdf = entry->dev->bdf; u64 limit = addr + entry->size - 1; if (entry->type == PCI_REGION_TYPE_IO) { pci_config_writeb(bdf, PCI_IO_BASE, addr >> PCI_IO_SHIFT); diff --git a/src/hw/ahci.c b/src/hw/ahci.c index 5401cca..bd21bf6 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -584,9 +584,8 @@ ahci_controller_setup(struct pci_device *pci) ctrl->pci_tmp = pci; ctrl->iobase = iobase; ctrl->irq = pci_config_readb(pci->bdf, PCI_INTERRUPT_LINE); - dprintf(1, "AHCI controller at %02x:%02x.%x, iobase %p, irq %d\n" - , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf) - , pci_bdf_to_fn(pci->bdf), ctrl->iobase, ctrl->irq); + dprintf(1, "AHCI controller at %pP, iobase %p, irq %d\n" + , pci, ctrl->iobase, ctrl->irq); pci_enable_busmaster(pci); diff --git a/src/hw/esp-scsi.c b/src/hw/esp-scsi.c index cf2cc11..9abc361 100644 --- a/src/hw/esp-scsi.c +++ b/src/hw/esp-scsi.c @@ -168,9 +168,7 @@ esp_scsi_add_lun(struct pci_device *pci, u32 iobase, u8 target, u8 lun) llun->lun = lun; llun->iobase = iobase; - char *name = znprintf(16, "esp %02x:%02x.%x %d:%d", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), target, lun); + char *name = znprintf(16, "esp %pP %d:%d", pci, target, lun); int prio = bootprio_find_scsi_device(pci, target, lun); int ret = scsi_drive_setup(&llun->drive, name, prio); free(name); @@ -197,9 +195,7 @@ init_esp_scsi(struct pci_device *pci) return; pci_enable_busmaster(pci); - dprintf(1, "found esp at %02x:%02x.%x, io @ %x\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), iobase); + dprintf(1, "found esp at %pP, io @ %x\n", pci, iobase); // reset outb(ESP_CMD_RESET, iobase + ESP_CMD); diff --git a/src/hw/lsi-scsi.c b/src/hw/lsi-scsi.c index 2629b5f..5d872a2 100644 --- a/src/hw/lsi-scsi.c +++ b/src/hw/lsi-scsi.c @@ -147,9 +147,7 @@ lsi_scsi_add_lun(struct pci_device *pci, u32 iobase, u8 target, u8 lun) llun->lun = lun; llun->iobase = iobase; - char *name = znprintf(16, "lsi %02x:%02x.%x %d:%d", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), target, lun); + char *name = znprintf(16, "lsi %pP %d:%d", pci, target, lun); int prio = bootprio_find_scsi_device(pci, target, lun); int ret = scsi_drive_setup(&llun->drive, name, prio); free(name); @@ -177,9 +175,7 @@ init_lsi_scsi(struct pci_device *pci) return; pci_enable_busmaster(pci); - dprintf(1, "found lsi53c895a at %02x:%02x.%x, io @ %x\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), iobase); + dprintf(1, "found lsi53c895a at %pP, io @ %x\n", pci, iobase); // reset outb(LSI_ISTAT0_SRST, iobase + LSI_REG_ISTAT0); diff --git a/src/hw/megasas.c b/src/hw/megasas.c index 31426e7..71af3c3 100644 --- a/src/hw/megasas.c +++ b/src/hw/megasas.c @@ -224,9 +224,7 @@ megasas_add_lun(struct pci_device *pci, u32 iobase, u8 target, u8 lun) free(mlun); return -1; } - name = znprintf(36, "MegaRAID SAS (PCI %02x:%02x.%x) LD %d:%d", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), target, lun); + name = znprintf(36, "MegaRAID SAS (PCI %pP) LD %d:%d", pci, target, lun); prio = bootprio_find_scsi_device(pci, target, lun); ret = scsi_drive_setup(&mlun->drive, name, prio); free(name); @@ -367,9 +365,7 @@ init_megasas(struct pci_device *pci) return; pci_enable_busmaster(pci); - dprintf(1, "found MegaRAID SAS at %02x:%02x.%x, io @ %x\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), iobase); + dprintf(1, "found MegaRAID SAS at %pP, io @ %x\n", pci, iobase); // reset if (megasas_transition_to_ready(pci, iobase) == 0) diff --git a/src/hw/pci.c b/src/hw/pci.c index 76c293c..1576787 100644 --- a/src/hw/pci.c +++ b/src/hw/pci.c @@ -162,10 +162,8 @@ pci_probe_devices(void) if (secbus > MaxPCIBus) MaxPCIBus = secbus; } - dprintf(4, "PCI device %02x:%02x.%x (vd=%04x:%04x c=%04x)\n" - , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf) - , pci_bdf_to_fn(bdf) - , dev->vendor, dev->device, dev->class); + dprintf(4, "PCI device %pP (vd=%04x:%04x c=%04x)\n" + , dev, dev->vendor, dev->device, dev->class); } } dprintf(1, "Found %d PCI devices (max PCI bus is %02x)\n", count, MaxPCIBus); diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c index 101a9c5..b1dd03f 100644 --- a/src/hw/pvscsi.c +++ b/src/hw/pvscsi.c @@ -272,9 +272,7 @@ pvscsi_add_lun(struct pci_device *pci, void *iobase, plun->iobase = iobase; plun->ring_dsc = ring_dsc; - char *name = znprintf(16, "pvscsi %02x:%02x.%x %d:%d", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), target, lun); + char *name = znprintf(16, "pvscsi %pP %d:%d", pci, target, lun); int prio = bootprio_find_scsi_device(pci, target, lun); int ret = scsi_drive_setup(&plun->drive, name, prio); free(name); @@ -303,9 +301,7 @@ init_pvscsi(struct pci_device *pci) return; pci_enable_busmaster(pci); - dprintf(1, "found pvscsi at %02x:%02x.%x, io @ %p\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - pci_bdf_to_fn(pci->bdf), iobase); + dprintf(1, "found pvscsi at %pP, io @ %p\n", pci, iobase); pvscsi_write_cmd_desc(iobase, PVSCSI_CMD_ADAPTER_RESET, NULL, 0); diff --git a/src/hw/usb-ehci.c b/src/hw/usb-ehci.c index 57ce5a8..1d1eb57 100644 --- a/src/hw/usb-ehci.c +++ b/src/hw/usb-ehci.c @@ -315,9 +315,7 @@ ehci_controller_setup(struct pci_device *pci) cntl->regs->ctrldssegment = 0; PendingEHCI++; - dprintf(1, "EHCI init on dev %02x:%02x.%x (regs=%p)\n" - , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf) - , pci_bdf_to_fn(pci->bdf), cntl->regs); + dprintf(1, "EHCI init on dev %pP (regs=%p)\n", pci, cntl->regs); pci_enable_busmaster(pci); diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c index 3d55d48..b586575 100644 --- a/src/hw/usb-ohci.c +++ b/src/hw/usb-ohci.c @@ -282,9 +282,7 @@ ohci_controller_setup(struct pci_device *pci) cntl->usb.type = USB_TYPE_OHCI; cntl->regs = regs; - dprintf(1, "OHCI init on dev %02x:%02x.%x (regs=%p)\n" - , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf) - , pci_bdf_to_fn(pci->bdf), cntl->regs); + dprintf(1, "OHCI init on dev %pP (regs=%p)\n", pci, cntl->regs); pci_enable_busmaster(pci); diff --git a/src/hw/usb-uhci.c b/src/hw/usb-uhci.c index 3b949e4..ed7c39a 100644 --- a/src/hw/usb-uhci.c +++ b/src/hw/usb-uhci.c @@ -258,9 +258,7 @@ uhci_controller_setup(struct pci_device *pci) cntl->usb.type = USB_TYPE_UHCI; cntl->iobase = iobase; - dprintf(1, "UHCI init on dev %02x:%02x.%x (io=%x)\n" - , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf) - , pci_bdf_to_fn(pci->bdf), cntl->iobase); + dprintf(1, "UHCI init on dev %pP (io=%x)\n", pci, cntl->iobase); pci_enable_busmaster(pci); diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index af09592..6c1720d 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -552,11 +552,10 @@ xhci_controller_setup(struct pci_device *pci) xhci->usb.pci = pci; xhci->usb.type = USB_TYPE_XHCI; - dprintf(1, "XHCI init on dev %02x:%02x.%x: regs @ %p, %d ports, %d slots" + dprintf(1, "XHCI init on dev %pP: regs @ %p, %d ports, %d slots" ", %d byte contexts\n" - , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf) - , pci_bdf_to_fn(pci->bdf), xhci->caps - , xhci->ports, xhci->slots, xhci->context64 ? 64 : 32); + , pci, xhci->caps, xhci->ports, xhci->slots + , xhci->context64 ? 64 : 32); if (xhci->xcap) { u32 off; diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c index 20a79eb..cd0cbe9 100644 --- a/src/hw/virtio-blk.c +++ b/src/hw/virtio-blk.c @@ -95,10 +95,8 @@ virtio_blk_process_op(struct disk_op_s *op) static void init_virtio_blk(struct pci_device *pci) { - u16 bdf = pci->bdf; u8 status = VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER; - dprintf(1, "found virtio-blk at %x:%x\n", pci_bdf_to_bus(bdf), - pci_bdf_to_dev(bdf)); + dprintf(1, "found virtio-blk at %pP\n", pci); struct virtiodrive_s *vdrive = malloc_fseg(sizeof(*vdrive)); if (!vdrive) { warn_noalloc(); @@ -106,12 +104,11 @@ init_virtio_blk(struct pci_device *pci) } memset(vdrive, 0, sizeof(*vdrive)); vdrive->drive.type = DTYPE_VIRTIO_BLK; - vdrive->drive.cntl_id = bdf; + vdrive->drive.cntl_id = pci->bdf; vp_init_simple(&vdrive->vp, pci); if (vp_find_vq(&vdrive->vp, 0, &vdrive->vq) < 0 ) { - dprintf(1, "fail to find vq for virtio-blk %x:%x\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + dprintf(1, "fail to find vq for virtio-blk %pP\n", pci); goto fail; } @@ -121,8 +118,7 @@ init_virtio_blk(struct pci_device *pci) u64 version1 = 1ull << VIRTIO_F_VERSION_1; u64 blk_size = 1ull << VIRTIO_BLK_F_BLK_SIZE; if (!(features & version1)) { - dprintf(1, "modern device without virtio_1 feature bit: %x:%x\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + dprintf(1, "modern device without virtio_1 feature bit: %pP\n", pci); goto fail; } @@ -131,8 +127,7 @@ init_virtio_blk(struct pci_device *pci) status |= VIRTIO_CONFIG_S_FEATURES_OK; vp_set_status(vp, status); if (!(vp_get_status(vp) & VIRTIO_CONFIG_S_FEATURES_OK)) { - dprintf(1, "device didn't accept features: %x:%x\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + dprintf(1, "device didn't accept features: %pP\n", pci); goto fail; } @@ -145,14 +140,12 @@ init_virtio_blk(struct pci_device *pci) vdrive->drive.blksize = DISK_SECTOR_SIZE; } if (vdrive->drive.blksize != DISK_SECTOR_SIZE) { - dprintf(1, "virtio-blk %x:%x block size %d is unsupported\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), - vdrive->drive.blksize); + dprintf(1, "virtio-blk %pP block size %d is unsupported\n", + pci, vdrive->drive.blksize); goto fail; } - dprintf(3, "virtio-blk %x:%x blksize=%d sectors=%u\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), - vdrive->drive.blksize, (u32)vdrive->drive.sectors); + dprintf(3, "virtio-blk %pP blksize=%d sectors=%u\n", + pci, vdrive->drive.blksize, (u32)vdrive->drive.sectors); vdrive->drive.pchs.cylinder = vp_read(&vp->device, struct virtio_blk_config, cylinders); @@ -169,14 +162,12 @@ init_virtio_blk(struct pci_device *pci) cfg.blk_size : DISK_SECTOR_SIZE; vdrive->drive.sectors = cfg.capacity; - dprintf(3, "virtio-blk %x:%x blksize=%d sectors=%u\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), - vdrive->drive.blksize, (u32)vdrive->drive.sectors); + dprintf(3, "virtio-blk %pP blksize=%d sectors=%u\n", + pci, vdrive->drive.blksize, (u32)vdrive->drive.sectors); if (vdrive->drive.blksize != DISK_SECTOR_SIZE) { - dprintf(1, "virtio-blk %x:%x block size %d is unsupported\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), - vdrive->drive.blksize); + dprintf(1, "virtio-blk %pP block size %d is unsupported\n", + pci, vdrive->drive.blksize); goto fail; } vdrive->drive.pchs.cylinder = cfg.cylinders; @@ -184,9 +175,7 @@ init_virtio_blk(struct pci_device *pci) vdrive->drive.pchs.sector = cfg.sectors; } - char *desc = znprintf(MAXDESCSIZE, "Virtio disk PCI:%x:%x", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); - + char *desc = znprintf(MAXDESCSIZE, "Virtio disk PCI:%pP", pci); boot_add_hd(&vdrive->drive, desc, bootprio_find_pci_device(pci)); status |= VIRTIO_CONFIG_S_DRIVER_OK; diff --git a/src/hw/virtio-pci.c b/src/hw/virtio-pci.c index f1e30a2..378d901 100644 --- a/src/hw/virtio-pci.c +++ b/src/hw/virtio-pci.c @@ -252,10 +252,9 @@ void vp_init_simple(struct vp_device *vp, struct pci_device *pci) return; vp_cap->memaddr = addr + offset; } - dprintf(3, "pci dev %x:%x virtio cap at 0x%x type %d " + dprintf(3, "pci dev %pP virtio cap at 0x%x type %d " "bar %d at 0x%08x off +0x%04x [%s]\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf), - vp_cap->cap, type, vp_cap->bar, vp_cap->ioaddr, offset, + pci, vp_cap->cap, type, vp_cap->bar, vp_cap->ioaddr, offset, vp_cap->is_io ? "io" : "mmio"); } @@ -263,12 +262,10 @@ void vp_init_simple(struct vp_device *vp, struct pci_device *pci) } if (vp->common.cap && vp->notify.cap && vp->isr.cap && vp->device.cap) { - dprintf(1, "pci dev %x:%x using modern (1.0) virtio mode\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf)); + dprintf(1, "pci dev %pP using modern (1.0) virtio mode\n", pci); vp->use_modern = 1; } else { - dprintf(1, "pci dev %x:%x using legacy (0.9.5) virtio mode\n", - pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf)); + dprintf(1, "pci dev %pP using legacy (0.9.5) virtio mode\n", pci); vp->legacy.bar = 0; vp->legacy.ioaddr = pci_enable_iobar(pci, PCI_BASE_ADDRESS_0); if (!vp->legacy.ioaddr) diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c index 80afd04..f7f01cd 100644 --- a/src/hw/virtio-scsi.c +++ b/src/hw/virtio-scsi.c @@ -134,9 +134,7 @@ virtio_scsi_scan_target(struct pci_device *pci, struct vp_device *vp, static void init_virtio_scsi(struct pci_device *pci) { - u16 bdf = pci->bdf; - dprintf(1, "found virtio-scsi at %x:%x\n", pci_bdf_to_bus(bdf), - pci_bdf_to_dev(bdf)); + dprintf(1, "found virtio-scsi at %pP\n", pci); struct vring_virtqueue *vq = NULL; struct vp_device *vp = malloc_high(sizeof(*vp)); if (!vp) { @@ -150,8 +148,7 @@ init_virtio_scsi(struct pci_device *pci) u64 features = vp_get_features(vp); u64 version1 = 1ull << VIRTIO_F_VERSION_1; if (!(features & version1)) { - dprintf(1, "modern device without virtio_1 feature bit: %x:%x\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + dprintf(1, "modern device without virtio_1 feature bit: %pP\n", pci); goto fail; } @@ -159,15 +156,13 @@ init_virtio_scsi(struct pci_device *pci) status |= VIRTIO_CONFIG_S_FEATURES_OK; vp_set_status(vp, status); if (!(vp_get_status(vp) & VIRTIO_CONFIG_S_FEATURES_OK)) { - dprintf(1, "device didn't accept features: %x:%x\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + dprintf(1, "device didn't accept features: %pP\n", pci); goto fail; } } if (vp_find_vq(vp, 2, &vq) < 0 ) { - dprintf(1, "fail to find vq for virtio-scsi %x:%x\n", - pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + dprintf(1, "fail to find vq for virtio-scsi %pP\n", pci); goto fail; } diff --git a/src/optionroms.c b/src/optionroms.c index c81eff2..a389dd9 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -243,9 +243,7 @@ copy_rom(struct rom_header *rom) static struct rom_header * map_pcirom(struct pci_device *pci) { - u16 bdf = pci->bdf; - dprintf(6, "Attempting to map option rom on dev %02x:%02x.%x\n" - , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf)); + dprintf(6, "Attempting to map option rom on dev %pP\n", pci); if ((pci->header_type & 0x7f) != PCI_HEADER_TYPE_NORMAL) { dprintf(6, "Skipping non-normal pci device (type=%x)\n" @@ -253,6 +251,7 @@ map_pcirom(struct pci_device *pci) return NULL; } + u16 bdf = pci->bdf; u32 orig = pci_config_readl(bdf, PCI_ROM_ADDRESS); pci_config_writel(bdf, PCI_ROM_ADDRESS, ~PCI_ROM_ADDRESS_ENABLE); u32 sz = pci_config_readl(bdf, PCI_ROM_ADDRESS); @@ -274,10 +273,8 @@ map_pcirom(struct pci_device *pci) struct rom_header *rom = (void*)orig; for (;;) { - dprintf(5, "Inspecting possible rom at %p (vd=%04x:%04x" - " bdf=%02x:%02x.%x)\n" - , rom, pci->vendor, pci->device - , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf)); + dprintf(5, "Inspecting possible rom at %p (vd=%04x:%04x bdf=%pP)\n" + , rom, pci->vendor, pci->device, pci); if (rom->signature != OPTION_ROM_SIGNATURE) { dprintf(6, "No option rom signature (got %x)\n", rom->signature); goto fail; @@ -314,10 +311,8 @@ fail: static void init_pcirom(struct pci_device *pci, int isvga, u64 *sources) { - u16 bdf = pci->bdf; - dprintf(4, "Attempting to init PCI bdf %02x:%02x.%x (vd %04x:%04x)\n" - , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf) - , pci->vendor, pci->device); + dprintf(4, "Attempting to init PCI bdf %pP (vd %04x:%04x)\n" + , pci, pci->vendor, pci->device); char fname[17]; snprintf(fname, sizeof(fname), "pci%04x,%04x.rom" @@ -332,7 +327,7 @@ init_pcirom(struct pci_device *pci, int isvga, u64 *sources) // No ROM present. return; setRomSource(sources, rom, RS_PCIROM | (u32)pci); - init_optionrom(rom, bdf, isvga); + init_optionrom(rom, pci->bdf, isvga); } diff --git a/src/output.c b/src/output.c index 8a88388..9a8a130 100644 --- a/src/output.c +++ b/src/output.c @@ -10,6 +10,7 @@ #include "bregs.h" // struct bregs #include "config.h" // CONFIG_* #include "biosvar.h" // GET_GLOBAL +#include "hw/pci.h" // pci_bdf_to_bus #include "hw/serialio.h" // serial_debug_putc #include "malloc.h" // malloc_tmp #include "output.h" // dprintf @@ -194,6 +195,17 @@ putprettyhex(struct putcinfo *action, u32 val, int width, char padchar) puthex(action, val, count); } +// Output 'struct pci_device' BDF as %02x:%02x.%x +static void +put_pci_device(struct putcinfo *action, struct pci_device *pci) +{ + puthex(action, pci_bdf_to_bus(pci->bdf), 2); + putc(action, ':'); + puthex(action, pci_bdf_to_dev(pci->bdf), 2); + putc(action, '.'); + puthex(action, pci_bdf_to_fn(pci->bdf), 1); +} + static inline int isdigit(u8 c) { @@ -260,6 +272,12 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) break; case 'p': val = va_arg(args, s32); + if (!MODESEGMENT && GET_GLOBAL(*(u8*)(n+1)) == 'P') { + // %pP is 'struct pci_device' printer + put_pci_device(action, (void*)val); + n++; + break; + } putc(action, '0'); putc(action, 'x'); puthex(action, val, 8); |