summaryrefslogtreecommitdiff
path: root/hw/pci.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-04-04 18:27:58 +0300
committerMichael S. Tsirkin <mst@redhat.com>2011-04-07 13:56:45 +0300
commit17cbcb0bf79c605aecaab3661dc8bad627e4cb3b (patch)
treeaaab24f7b5b9667e1711da2f2e55305126734510 /hw/pci.c
parentaf94482bcee9640d9f8a6aa06104d8456bbe0d7f (diff)
downloadqemu-17cbcb0bf79c605aecaab3661dc8bad627e4cb3b.tar.gz
pci: add pci_register_bar_simple() API
This is similar to pci_register_bar(), but automatically registers a single memory region spanning the entire BAR. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r--hw/pci.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/hw/pci.c b/hw/pci.c
index 3ee48715fc..410b67bace 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -866,6 +866,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
r->filtered_size = size;
r->type = type;
r->map_func = map_func;
+ r->ram_addr = IO_MEM_UNASSIGNED;
wmask = ~(size - 1);
addr = pci_bar(pci_dev, region_num);
@@ -884,6 +885,22 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
}
}
+static void pci_simple_bar_mapfunc(PCIDevice *pci_dev, int region_num,
+ pcibus_t addr, pcibus_t size, int type)
+{
+ cpu_register_physical_memory(addr, size,
+ pci_dev->io_regions[region_num].ram_addr);
+}
+
+void pci_register_bar_simple(PCIDevice *pci_dev, int region_num,
+ pcibus_t size, uint8_t attr, ram_addr_t ram_addr)
+{
+ pci_register_bar(pci_dev, region_num, size,
+ PCI_BASE_ADDRESS_SPACE_MEMORY | attr,
+ pci_simple_bar_mapfunc);
+ pci_dev->io_regions[region_num].ram_addr = ram_addr;
+}
+
static void pci_bridge_filter(PCIDevice *d, pcibus_t *addr, pcibus_t *size,
uint8_t type)
{