Patchwork [18/34] cirrus_vga: convert to pci_bar_map

login
register
mail settings
Submitter Blue Swirl
Date July 22, 2010, 9:59 p.m.
Message ID <AANLkTilsBN4Z4zHII5HJs_N4GMUFlZ_WngOXsEiLOcLk@mail.gmail.com>
Download mbox | patch
Permalink /patch/59671/
State New
Headers show

Comments

Blue Swirl - July 22, 2010, 9:59 p.m.
Use pci_bar_map() and post_map_func instead of a mapping function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/cirrus_vga.c |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)

     s->vga.lfb_end = ((addr + VGA_RAM_SIZE) + TARGET_PAGE_SIZE - 1) &
TARGET_PAGE_MASK;
@@ -3160,15 +3154,6 @@ static void cirrus_pci_lfb_map(PCIDevice *d,
int region_num,
     vga_dirty_log_start(&s->vga);
 }

-static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
-				pcibus_t addr, pcibus_t size, int type)
-{
-    CirrusVGAState *s = &DO_UPCAST(PCICirrusVGAState, dev, d)->cirrus_vga;
-
-    cpu_register_physical_memory(addr, CIRRUS_PNPMMIO_SIZE,
-				 s->cirrus_mmio_io_addr);
-}
-
 static void pci_cirrus_write_config(PCIDevice *d,
                                     uint32_t address, uint32_t val, int len)
 {
@@ -3205,11 +3190,16 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
      /* memory #1 memory-mapped I/O */
      /* XXX: s->vga.vram_size must be a power of two */
      pci_register_bar((PCIDevice *)d, 0, 0x2000000,
-                      PCI_BASE_ADDRESS_MEM_PREFETCH, cirrus_pci_lfb_map, NULL);
+                      PCI_BASE_ADDRESS_MEM_PREFETCH, NULL, cirrus_pci_lfb_map);
+     pci_bar_map((PCIDevice *)d, 0, 0, 0, s->vga.vram_size,
+                 s->cirrus_linear_io_addr);
+     pci_bar_map((PCIDevice *)d, 0, 1, 0x1000000, 0x400000,
+                 s->cirrus_linear_bitblt_io_addr);
      if (device_id == CIRRUS_ID_CLGD5446) {
          pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
-                          PCI_BASE_ADDRESS_SPACE_MEMORY, cirrus_pci_mmio_map,
-                          NULL);
+                          PCI_BASE_ADDRESS_SPACE_MEMORY, NULL, NULL);
+         pci_bar_map((PCIDevice *)d, 1, 0, 0, CIRRUS_PNPMMIO_SIZE,
+                     s->cirrus_mmio_io_addr);
      }
      return 0;
 }

Patch

diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 7c14361..a9ccb69 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3144,12 +3144,6 @@  static void cirrus_pci_lfb_map(PCIDevice *d,
int region_num,
 {
     CirrusVGAState *s = &DO_UPCAST(PCICirrusVGAState, dev, d)->cirrus_vga;

-    /* XXX: add byte swapping apertures */
-    cpu_register_physical_memory(addr, s->vga.vram_size,
-				 s->cirrus_linear_io_addr);
-    cpu_register_physical_memory(addr + 0x1000000, 0x400000,
-				 s->cirrus_linear_bitblt_io_addr);
-
     s->vga.map_addr = s->vga.map_end = 0;
     s->vga.lfb_addr = addr & TARGET_PAGE_MASK;