From: "Michael S. Tsirkin" Subject: [PATCH RFC 2/3] pci-testdev: add subregion Date: Sun, 30 Aug 2015 12:20:17 +0300 Message-ID: <1440926395-23540-3-git-send-email-mst@redhat.com> References: <1440926395-23540-1-git-send-email-mst@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: pbonzini@redhat.com, kvm@vger.kernel.org, Gonglei , Markus Armbruster To: qemu-devel@nongnu.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50513 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751714AbbH3JU1 (ORCPT ); Sun, 30 Aug 2015 05:20:27 -0400 Content-Disposition: inline In-Reply-To: <1440926395-23540-1-git-send-email-mst@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Make mmio a subregion of the BAR. This will allow mapping rom within the same BAR down the road. Signed-off-by: Michael S. Tsirkin --- hw/misc/pci-testdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c index 6edc1cd..94141a3 100644 --- a/hw/misc/pci-testdev.c +++ b/hw/misc/pci-testdev.c @@ -83,6 +83,7 @@ typedef struct PCITestDevState { /*< public >*/ MemoryRegion mmio; + MemoryRegion mbar; MemoryRegion portio; IOTest *tests; int current; @@ -248,9 +249,13 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp) memory_region_init_io(&d->mmio, OBJECT(d), &pci_testdev_mmio_ops, d, "pci-testdev-mmio", IOTEST_MEMSIZE * 2); + memory_region_init(&d->mbar, OBJECT(d), + "pci-testdev-mmio", IOTEST_MEMSIZE * 2); memory_region_init_io(&d->portio, OBJECT(d), &pci_testdev_pio_ops, d, "pci-testdev-portio", IOTEST_IOSIZE * 2); - pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio); + + memory_region_add_subregion_overlap(&d->mbar, 0, &d->mmio, 1 /* prio */); + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mbar); pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &d->portio); d->current = -1; -- MST