Kevin O'Connor (4): Make sure virtio-blk is fully compiled out if not wanted. Minor ata cleanups. Minor - compile out usb-msc code if CONFIG_USB_MSC not set. Improve optionrom debugging statements.
src/ata.c | 14 ++++++++++---- src/optionroms.c | 12 +++++++----- src/pci.h | 10 ++++++++++ src/usb-msc.c | 2 ++ src/virtio-blk.c | 4 +++- 5 files changed, 32 insertions(+), 10 deletions(-)
Add check for CONFIG_VIRTIO_BLK in process_virtio_op. Don't enable virtio when coreboot enabled. --- src/virtio-blk.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/virtio-blk.c b/src/virtio-blk.c index 7f9b3d2..16d9ad8 100644 --- a/src/virtio-blk.c +++ b/src/virtio-blk.c @@ -68,6 +68,8 @@ virtio_blk_read(struct disk_op_s *op) int process_virtio_op(struct disk_op_s *op) { + if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT) + return 0; switch (op->command) { case CMD_READ: return virtio_blk_read(op); @@ -162,7 +164,7 @@ void virtio_blk_setup(void) { ASSERT32FLAT(); - if (! CONFIG_VIRTIO_BLK) + if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT) return;
dprintf(3, "init virtio-blk\n");
Eliminate process_atapi_op() code if CONFIG_ATA not set. Use PCI_BASE_ADDRESS_IO_MASK instead of hardcoding it. --- src/ata.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/ata.c b/src/ata.c index 42bb691..346c340 100644 --- a/src/ata.c +++ b/src/ata.c @@ -662,6 +662,8 @@ fail: int process_atapi_op(struct disk_op_s *op) { + if (!CONFIG_ATA) + return 0; switch (op->command) { case CMD_READ: return cdb_read(op); @@ -984,8 +986,10 @@ ata_init(void)
u32 port1, port2, irq; if (prog_if & 1) { - port1 = pci_config_readl(bdf, PCI_BASE_ADDRESS_0) & ~3; - port2 = pci_config_readl(bdf, PCI_BASE_ADDRESS_1) & ~3; + port1 = (pci_config_readl(bdf, PCI_BASE_ADDRESS_0) + & PCI_BASE_ADDRESS_IO_MASK); + port2 = (pci_config_readl(bdf, PCI_BASE_ADDRESS_1) + & PCI_BASE_ADDRESS_IO_MASK); irq = pciirq; } else { port1 = PORT_ATA1_CMD_BASE; @@ -996,8 +1000,10 @@ ata_init(void) count++;
if (prog_if & 4) { - port1 = pci_config_readl(bdf, PCI_BASE_ADDRESS_2) & ~3; - port2 = pci_config_readl(bdf, PCI_BASE_ADDRESS_3) & ~3; + port1 = (pci_config_readl(bdf, PCI_BASE_ADDRESS_2) + & PCI_BASE_ADDRESS_IO_MASK); + port2 = (pci_config_readl(bdf, PCI_BASE_ADDRESS_3) + & PCI_BASE_ADDRESS_IO_MASK); irq = pciirq; } else { port1 = PORT_ATA2_CMD_BASE;
--- src/usb-msc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/usb-msc.c b/src/usb-msc.c index e91d916..52fb58a 100644 --- a/src/usb-msc.c +++ b/src/usb-msc.c @@ -111,6 +111,8 @@ fail: int process_usb_op(struct disk_op_s *op) { + if (!CONFIG_USB_MSC) + return 0; switch (op->command) { case CMD_READ: return cdb_read(op);
Display device/vendor ids in traditional format. --- src/optionroms.c | 12 +++++++----- src/pci.h | 10 ++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/optionroms.c b/src/optionroms.c index ad88e0c..f144d83 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -307,8 +307,10 @@ map_pcirom(u16 bdf, u32 vendev)
struct rom_header *rom = (void*)orig; for (;;) { - dprintf(5, "Inspecting possible rom at %p (dv=%08x bdf=%x)\n" - , rom, vendev, bdf); + dprintf(5, "Inspecting possible rom at %p (vd=%04x:%04x" + " bdf=%02x:%02x.%x)\n" + , rom, pci_vd_to_ven(vendev), pci_vd_to_dev(vendev) + , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf)); if (rom->signature != OPTION_ROM_SIGNATURE) { dprintf(6, "No option rom signature (got %x)\n", rom->signature); goto fail; @@ -319,7 +321,7 @@ map_pcirom(u16 bdf, u32 vendev) goto fail; }
- u32 vd = (pci->device << 16) | pci->vendor; + u32 vd = pci_vd(pci->vendor, pci->device); if (vd == vendev && pci->type == PCIROM_CODETYPE_X86) // A match break; @@ -346,9 +348,9 @@ static int init_pcirom(u16 bdf, int isvga) { u32 vendev = pci_config_readl(bdf, PCI_VENDOR_ID); - dprintf(4, "Attempting to init PCI bdf %02x:%02x.%x (dev/ven %08x)\n" + 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) - , vendev); + , pci_vd_to_ven(vendev), pci_vd_to_dev(vendev)); struct rom_header *rom = lookup_hardcode(vendev); if (! rom) rom = map_pcirom(bdf, vendev); diff --git a/src/pci.h b/src/pci.h index eea5b09..8a21c06 100644 --- a/src/pci.h +++ b/src/pci.h @@ -22,6 +22,16 @@ static inline u16 pci_to_bdf(int bus, int dev, int fn) { return (bus<<8) | (dev<<3) | fn; }
+static inline u32 pci_vd(u16 vendor, u16 device) { + return (device << 16) | vendor; +} +static inline u16 pci_vd_to_ven(u32 vd) { + return vd & 0xffff; +} +static inline u16 pci_vd_to_dev(u32 vd) { + return vd >> 16; +} + void pci_config_writel(u16 bdf, u32 addr, u32 val); void pci_config_writew(u16 bdf, u32 addr, u16 val); void pci_config_writeb(u16 bdf, u32 addr, u8 val);