modified pci_device_config() to support byteswapped config access functions

This commit is contained in:
Markus Fröschle
2013-11-08 06:45:51 +00:00
parent 519f3a9d0f
commit f164da60fc

View File

@@ -342,10 +342,13 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function)
mem_address = (mem_address + size - 1) & ~(size - 1); mem_address = (mem_address + size - 1) & ~(size - 1);
/* write it to the BAR */ /* write it to the BAR */
pci_write_config_longword(handle, PCIBAR0 + i, mem_address); pci_write_config_longword(handle, PCIBAR0 + i, swpl(mem_address));
/* read it back, just to be sure */ /* read it back, just to be sure */
value = swpl(pci_read_config_longword(handle, PCIBAR0 + i)); value = swpl(pci_read_config_longword(handle, PCIBAR0 + i));
xprintf("set PCIBAR%d on device 0x%02x to 0x%08x\r\n",
i, handle, value);
/* fill resource descriptor */ /* fill resource descriptor */
rd->next = sizeof(struct pci_rd); rd->next = sizeof(struct pci_rd);
@@ -366,9 +369,12 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function)
int size = ~(address & 0xfffffffc) + 1; int size = ~(address & 0xfffffffc) + 1;
io_address = (io_address + size - 1) & ~(size - 1); io_address = (io_address + size - 1) & ~(size - 1);
pci_write_config_longword(handle, PCIBAR0 + i, io_address); pci_write_config_longword(handle, PCIBAR0 + i, swpl(io_address));
value = swpl(pci_read_config_longword(handle, PCIBAR0 + i)); value = swpl(pci_read_config_longword(handle, PCIBAR0 + i));
xprintf("set PCIBAR%d on device 0x%02x to 0x%08x\r\n",
i, handle, value);
rd->next = sizeof(struct pci_rd); rd->next = sizeof(struct pci_rd);
rd->flags = FLG_IO | FLG_8BIT | FLG_16BIT | FLG_32BIT | 1; rd->flags = FLG_IO | FLG_8BIT | FLG_16BIT | FLG_32BIT | 1;
rd->start = io_address; rd->start = io_address;