qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 09/14] Further transformation: use common vga_init()


From: Zachary Amsden
Subject: [Qemu-devel] [PATCH 09/14] Further transformation: use common vga_init() which allows either I/O port or memory mapped based control.
Date: Thu, 30 Jul 2009 00:15:07 -1000

Signed-off-by: Zachary Amsden <address@hidden>
---
 hw/vga.c        |   40 +++++++++++++---------------------------
 hw/vga_int.h    |    3 ++-
 hw/vmware_vga.c |    2 +-
 3 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index 52fb1c4..907cdb7 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2341,24 +2341,6 @@ static void vga_ioport_init(VGAState *s)
 #endif /* CONFIG_BOCHS_VBE */
 }
 
-/* used by both ISA and PCI */
-void vga_init(VGAState *s)
-{
-    int vga_io_memory;
-
-    qemu_register_reset(vga_reset, 0, s);
-    register_savevm("vga", 0, 2, vga_save, vga_load, s);
-
-    s->bank_offset = 0;
-
-    vga_ioport_init(s);
-
-    vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);
-    cpu_register_physical_memory(isa_mem_base + 0x000a0000, 0x20000,
-                                 vga_io_memory);
-    qemu_register_coalesced_mmio(isa_mem_base + 0x000a0000, 0x20000);
-}
-
 /* Memory mapped interface */
 static uint32_t vga_mm_readb (void *opaque, target_phys_addr_t addr)
 {
@@ -2417,8 +2399,8 @@ static CPUWriteMemoryFunc *vga_mm_write_ctrl[] = {
     &vga_mm_writel,
 };
 
-static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
-                        target_phys_addr_t ctrl_base, int it_shift)
+void vga_init(VGAState *s, target_phys_addr_t vram_base,
+              target_phys_addr_t ctrl_base, int it_shift)
 {
     int s_ioport_ctrl, vga_io_memory;
 
@@ -2426,13 +2408,17 @@ static void vga_mm_init(VGAState *s, target_phys_addr_t 
vram_base,
     register_savevm("vga", 0, 2, vga_save, vga_load, s);
 
     s->bank_offset = 0;
-
     s->it_shift = it_shift;
-    s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, 
vga_mm_write_ctrl, s);
 
-    vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);
+    /* Pass ctrl_base to setup memory mapped I/O control */
+    if (ctrl_base) {
+        s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, 
vga_mm_write_ctrl, s);
+        cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
+    } else {
+        vga_ioport_init(s);
+    }
 
-    cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
+    vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);
     cpu_register_physical_memory(vram_base, 0x20000, vga_io_memory);
     qemu_register_coalesced_mmio(vram_base, 0x20000);
 }
@@ -2444,7 +2430,7 @@ int isa_vga_init(void)
     s = qemu_mallocz(sizeof(VGAState));
 
     vga_common_init(s, VGA_RAM_SIZE);
-    vga_init(s);
+    vga_init(s, isa_mem_base + 0xa0000, 0, -1);
 
     s->ds = graphic_console_init(s->update, s->invalidate,
                                  s->screen_dump, s->text_update, s);
@@ -2465,7 +2451,7 @@ int isa_vga_mm_init(target_phys_addr_t vram_base,
     s = qemu_mallocz(sizeof(VGAState));
 
     vga_common_init(s, VGA_RAM_SIZE);
-    vga_mm_init(s, vram_base, ctrl_base, it_shift);
+    vga_init(s, vram_base, ctrl_base, it_shift);
 
     s->ds = graphic_console_init(s->update, s->invalidate,
                                  s->screen_dump, s->text_update, s);
@@ -2504,7 +2490,7 @@ int pci_vga_init(PCIBus *bus,
     s = &d->vga_state;
 
     vga_common_init(s, VGA_RAM_SIZE);
-    vga_init(s);
+    vga_init(s, isa_mem_base + 0xa0000, 0, -1);
 
     s->ds = graphic_console_init(s->update, s->invalidate,
                                  s->screen_dump, s->text_update, s);
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 83b69ef..f072663 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -190,7 +190,8 @@ static inline int c6_to_8(int v)
 }
 
 void vga_common_init(VGAState *s, int vga_ram_size);
-void vga_init(VGAState *s);
+void vga_init(VGAState *s, target_phys_addr_t vram_base,
+                     target_phys_addr_t ctrl_base, int it_shift);
 void vga_reset(void *s);
 
 void vga_dirty_log_start(VGAState *s);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index accdac4..d81d263 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1130,7 +1130,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int 
vga_ram_size)
 
 #ifdef EMBED_STDVGA
     vga_common_init((VGAState *) s, vga_ram_size);
-    vga_init((VGAState *) s);
+    vga_init((VGAState *) s, isa_mem_base + 0xa0000, 0, -1);
 #else
     s->vram_size = vga_ram_size;
     s->vram_offset = qemu_ram_alloc(vga_ram_size);
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]