Message ID | AANLkTinQPMv3uOx0lBa05-As9SpBtHzWuJKZ5Jo8RRgy@mail.gmail.com |
---|---|
State | New |
Headers | show |
diff --git a/hw/pcnet.c b/hw/pcnet.c index 5e75930..deb6f6a 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -1615,6 +1615,18 @@ static uint32_t pcnet_aprom_readb(void *opaque, uint32_t addr) return val; } +static IOPortWriteFunc * const pcnet_aprom_writes[] = { + pcnet_aprom_writeb, + NULL, + NULL, +}; + +static IOPortReadFunc * const pcnet_aprom_reads[] = { + pcnet_aprom_readb, + NULL, + NULL, +}; + void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val) {
Use pci_bar_map() instead of a mapping function. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> --- hw/pcnet.c | 62 +++++++++++++++++++++++++++++------------------------------ 1 files changed, 30 insertions(+), 32 deletions(-) PCNetState *s = opaque; @@ -1726,24 +1738,17 @@ static uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr) return val; } -static void pcnet_ioport_map(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) -{ - PCNetState *d = &DO_UPCAST(PCIPCNetState, pci_dev, pci_dev)->state; - -#ifdef PCNET_DEBUG_IO - printf("pcnet_ioport_map addr=0x%04"FMT_PCIBUS" size=0x%04"FMT_PCIBUS"\n", - addr, size); -#endif - - register_ioport_write(addr, 16, 1, pcnet_aprom_writeb, d); - register_ioport_read(addr, 16, 1, pcnet_aprom_readb, d); +static IOPortWriteFunc * const pcnet_ioport_writes[] = { + NULL, + pcnet_ioport_writew, + pcnet_ioport_writel, +}; - register_ioport_write(addr + 0x10, 0x10, 2, pcnet_ioport_writew, d); - register_ioport_read(addr + 0x10, 0x10, 2, pcnet_ioport_readw, d); - register_ioport_write(addr + 0x10, 0x10, 4, pcnet_ioport_writel, d); - register_ioport_read(addr + 0x10, 0x10, 4, pcnet_ioport_readl, d); -} +static IOPortReadFunc * const pcnet_ioport_reads[] = { + NULL, + pcnet_ioport_readw, + pcnet_ioport_readl, +}; static void pcnet_mmio_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) { @@ -1915,19 +1920,6 @@ static CPUReadMemoryFunc * const pcnet_mmio_read[] = { &pcnet_mmio_readl }; -static void pcnet_mmio_map(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) -{ - PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev, pci_dev); - -#ifdef PCNET_DEBUG_IO - printf("pcnet_mmio_map addr=0x%08"FMT_PCIBUS" 0x%08"FMT_PCIBUS"\n", - addr, size); -#endif - - cpu_register_physical_memory(addr, PCNET_PNPMMIO_SIZE, d->state.mmio_index); -} - static void pci_physical_memory_write(void *dma_opaque, target_phys_addr_t addr, uint8_t *buf, int len, int do_bswap) { @@ -1971,6 +1963,7 @@ static int pci_pcnet_init(PCIDevice *pci_dev) PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev, pci_dev); PCNetState *s = &d->state; uint8_t *pci_conf; + int io_index; #if 0 printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n", @@ -2010,10 +2003,15 @@ static int pci_pcnet_init(PCIDevice *pci_dev) /* TODO: use pci_dev, avoid cast below. */ pci_register_bar((PCIDevice *)d, 0, PCNET_IOPORT_SIZE, - PCI_BASE_ADDRESS_SPACE_IO, pcnet_ioport_map); + PCI_BASE_ADDRESS_SPACE_IO, NULL); + io_index = cpu_register_io(pcnet_aprom_reads, pcnet_aprom_writes, 16, s); + pci_bar_map((PCIDevice *)d, 0, 0, 0, 16, io_index); + io_index = cpu_register_io(pcnet_ioport_reads, pcnet_ioport_writes, 16, s); + pci_bar_map((PCIDevice *)d, 0, 1, 16, 16, io_index); pci_register_bar((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE, - PCI_BASE_ADDRESS_SPACE_MEMORY, pcnet_mmio_map); + PCI_BASE_ADDRESS_SPACE_MEMORY, NULL); + pci_bar_map((PCIDevice *)d, 1, 0, 0, PCNET_PNPMMIO_SIZE, s->mmio_index); s->irq = pci_dev->irq[0]; s->phys_mem_read = pci_physical_memory_read;