diff mbox

[22/34] vga-pci: convert to pci_bar_map

Message ID AANLkTim6ngmH4GmtXpKrcbfCgyU3cVn9S3-ucW0MPd93@mail.gmail.com
State New
Headers show

Commit Message

Blue Swirl July 22, 2010, 10 p.m. UTC
Use pci_bar_map() and post_map_func instead of a mapping function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/vga-pci.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
diff mbox

Patch

diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index 216071f..c627a79 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -52,14 +52,12 @@  static void vga_map(PCIDevice *pci_dev, int region_num,
 {
     PCIVGAState *d = (PCIVGAState *)pci_dev;
     VGACommonState *s = &d->vga;
-    if (region_num == PCI_ROM_SLOT) {
-        cpu_register_physical_memory(addr, s->bios_size, s->bios_offset);
-    } else {
-        cpu_register_physical_memory(addr, s->vram_size, s->vram_offset);
-        s->map_addr = addr;
-        s->map_end = addr + s->vram_size;
-        vga_dirty_log_start(s);
-    }
+
+    assert(region_num != PCI_ROM_SLOT);
+
+    s->map_addr = addr;
+    s->map_end = addr + s->vram_size;
+    vga_dirty_log_start(s);
 }

 static void pci_vga_write_config(PCIDevice *d,
@@ -92,8 +90,9 @@  static int pci_vga_initfn(PCIDevice *dev)
      pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA);

      /* XXX: VGA_RAM_SIZE must be a power of two */
-     pci_register_bar(&d->dev, 0, VGA_RAM_SIZE,
-                      PCI_BASE_ADDRESS_MEM_PREFETCH, vga_map, NULL);
+     pci_register_bar(&d->dev, 0, VGA_RAM_SIZE, PCI_BASE_ADDRESS_MEM_PREFETCH,
+                      NULL, vga_map);
+     pci_bar_map(&d->dev, 0, 0, 0, s->vram_size, s->vram_offset);

      if (s->bios_size) {
         unsigned int bios_total_size;
@@ -102,7 +101,8 @@  static int pci_vga_initfn(PCIDevice *dev)
         while (bios_total_size < s->bios_size)
             bios_total_size <<= 1;
         pci_register_bar(&d->dev, PCI_ROM_SLOT, bios_total_size,
-                         PCI_BASE_ADDRESS_MEM_PREFETCH, vga_map, NULL);
+                         PCI_BASE_ADDRESS_MEM_PREFETCH, NULL, NULL);
+        pci_bar_map(&d->dev, PCI_ROM_SLOT, 0, 0, s->bios_size, s->bios_offset);
      }

     vga_init_vbe(s);