Signed-off-by: Anthony Liguori <aligu...@us.ibm.com> --- hw/usb-uhci.c | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 434070e..0d049d8 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -1047,17 +1047,34 @@ static void uhci_frame_timer(void *opaque) qemu_mod_timer(s->frame_timer, expire_time); } -static void uhci_map(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) +static uint32_t uhci_ioport_read(PCIDevice *dev, pcibus_t addr, int size) { - UHCIState *s = (UHCIState *)pci_dev; - - register_ioport_write(addr, 32, 2, uhci_ioport_writew, s); - register_ioport_read(addr, 32, 2, uhci_ioport_readw, s); - register_ioport_write(addr, 32, 4, uhci_ioport_writel, s); - register_ioport_read(addr, 32, 4, uhci_ioport_readl, s); - register_ioport_write(addr, 32, 1, uhci_ioport_writeb, s); - register_ioport_read(addr, 32, 1, uhci_ioport_readb, s); + UHCIState *s = DO_UPCAST(UHCIState, dev, dev); + uint32_t value; + + if (size == 1) { + value = uhci_ioport_readb(s, addr); + } else if (size == 2) { + value = uhci_ioport_readw(s, addr); + } else { + value = uhci_ioport_readl(s, addr); + } + + return value; +} + +static void uhci_ioport_write(PCIDevice *dev, pcibus_t addr, int size, + uint32_t value) +{ + UHCIState *s = DO_UPCAST(UHCIState, dev, dev); + + if (size == 1) { + uhci_ioport_writeb(s, addr, value); + } else if (size == 2) { + uhci_ioport_writew(s, addr, value); + } else { + uhci_ioport_writel(s, addr, value); + } } static int usb_uhci_common_initfn(UHCIState *s) @@ -1084,8 +1101,8 @@ static int usb_uhci_common_initfn(UHCIState *s) /* Use region 4 for consistency with real hardware. BSD guests seem to rely on this. */ - pci_register_bar(&s->dev, 4, 0x20, - PCI_BASE_ADDRESS_SPACE_IO, uhci_map); + pci_register_io_region(&s->dev, 4, 0x20, PCI_BASE_ADDRESS_SPACE_IO, + uhci_ioport_read, uhci_ioport_write); return 0; } -- 1.6.5.2