qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>, qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH v2 18/24] versatile_pci: convert to memory API
Date: Mon, 15 Aug 2011 17:17:32 +0300	[thread overview]
Message-ID: <1313417858-6454-19-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1313417858-6454-1-git-send-email-avi@redhat.com>

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/versatile_pci.c |   92 ++++++++++++++++++++++++---------------------------
 1 files changed, 43 insertions(+), 49 deletions(-)

diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c
index e1d5c0b..98e56f1 100644
--- a/hw/versatile_pci.c
+++ b/hw/versatile_pci.c
@@ -16,7 +16,9 @@ typedef struct {
     SysBusDevice busdev;
     qemu_irq irq[4];
     int realview;
-    int mem_config;
+    MemoryRegion mem_config;
+    MemoryRegion mem_config2;
+    MemoryRegion isa;
 } PCIVPBState;
 
 static inline uint32_t vpb_pci_config_addr(target_phys_addr_t addr)
@@ -24,55 +26,24 @@ static inline uint32_t vpb_pci_config_addr(target_phys_addr_t addr)
     return addr & 0xffffff;
 }
 
-static void pci_vpb_config_writeb (void *opaque, target_phys_addr_t addr,
-                                   uint32_t val)
+static void pci_vpb_config_write(void *opaque, target_phys_addr_t addr,
+                                 uint64_t val, unsigned size)
 {
-    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 1);
+    pci_data_write(opaque, vpb_pci_config_addr(addr), val, size);
 }
 
-static void pci_vpb_config_writew (void *opaque, target_phys_addr_t addr,
-                                   uint32_t val)
-{
-    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 2);
-}
-
-static void pci_vpb_config_writel (void *opaque, target_phys_addr_t addr,
-                                   uint32_t val)
-{
-    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 4);
-}
-
-static uint32_t pci_vpb_config_readb (void *opaque, target_phys_addr_t addr)
-{
-    uint32_t val;
-    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 1);
-    return val;
-}
-
-static uint32_t pci_vpb_config_readw (void *opaque, target_phys_addr_t addr)
-{
-    uint32_t val;
-    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 2);
-    return val;
-}
-
-static uint32_t pci_vpb_config_readl (void *opaque, target_phys_addr_t addr)
+static uint64_t pci_vpb_config_read(void *opaque, target_phys_addr_t addr,
+                                    unsigned size)
 {
     uint32_t val;
-    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 4);
+    val = pci_data_read(opaque, vpb_pci_config_addr(addr), size);
     return val;
 }
 
-static CPUWriteMemoryFunc * const pci_vpb_config_write[] = {
-    &pci_vpb_config_writeb,
-    &pci_vpb_config_writew,
-    &pci_vpb_config_writel,
-};
-
-static CPUReadMemoryFunc * const pci_vpb_config_read[] = {
-    &pci_vpb_config_readb,
-    &pci_vpb_config_readw,
-    &pci_vpb_config_readl,
+static const MemoryRegionOps pci_vpb_config_ops = {
+    .read = pci_vpb_config_read,
+    .write = pci_vpb_config_write,
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static int pci_vpb_map_irq(PCIDevice *d, int irq_num)
@@ -87,17 +58,35 @@ static void pci_vpb_set_irq(void *opaque, int irq_num, int level)
     qemu_set_irq(pic[irq_num], level);
 }
 
+
 static void pci_vpb_map(SysBusDevice *dev, target_phys_addr_t base)
 {
     PCIVPBState *s = (PCIVPBState *)dev;
     /* Selfconfig area.  */
-    cpu_register_physical_memory(base + 0x01000000, 0x1000000, s->mem_config);
+    memory_region_add_subregion(get_system_memory(), base + 0x01000000,
+                                &s->mem_config);
+    /* Normal config area.  */
+    memory_region_add_subregion(get_system_memory(), base + 0x02000000,
+                                &s->mem_config2);
+
+    if (s->realview) {
+        /* IO memory area.  */
+        memory_region_add_subregion(get_system_memory(), base + 0x03000000,
+                                    &s->isa);
+    }
+}
+
+static void pci_vpb_unmap(SysBusDevice *dev, target_phys_addr_t base)
+{
+    PCIVPBState *s = (PCIVPBState *)dev;
+    /* Selfconfig area.  */
+    memory_region_del_subregion(get_system_memory(), &s->mem_config);
     /* Normal config area.  */
-    cpu_register_physical_memory(base + 0x02000000, 0x1000000, s->mem_config);
+    memory_region_del_subregion(get_system_memory(), &s->mem_config2);
 
     if (s->realview) {
         /* IO memory area.  */
-        isa_mmio_init(base + 0x03000000, 0x00100000);
+        memory_region_del_subregion(get_system_memory(), &s->isa);
     }
 }
 
@@ -117,10 +106,15 @@ static int pci_vpb_init(SysBusDevice *dev)
 
     /* ??? Register memory space.  */
 
-    s->mem_config = cpu_register_io_memory(pci_vpb_config_read,
-                                           pci_vpb_config_write, bus,
-                                           DEVICE_LITTLE_ENDIAN);
-    sysbus_init_mmio_cb(dev, 0x04000000, pci_vpb_map);
+    memory_region_init_io(&s->mem_config, &pci_vpb_config_ops, bus,
+                          "pci-vpb-selfconfig", 0x1000000);
+    memory_region_init_io(&s->mem_config2, &pci_vpb_config_ops, bus,
+                          "pci-vpb-config", 0x1000000);
+    if (s->realview) {
+        isa_mmio_setup(&s->isa, 0x0100000);
+    }
+
+    sysbus_init_mmio_cb2(dev, pci_vpb_map, pci_vpb_unmap);
 
     pci_create_simple(bus, -1, "versatile_pci_host");
     return 0;
-- 
1.7.5.3

  parent reply	other threads:[~2011-08-15 14:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-15 14:17 [Qemu-devel] [PATCH v2 00/24] Memory API batch 4: more conversions Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 01/24] apb_pci: convert to memory API Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 02/24] apic: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 03/24] arm_gic: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 04/24] arm_sysctl: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 05/24] arm_timer: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 06/24] armv7m: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 07/24] gt64xxx.c: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 08/24] tusb6010: move declarations to new file tusb6010.h Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 09/24] omap_gpmc/nseries/tusb6010: convert to memory API Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 10/24] onenand: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 11/24] pcie_host: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 12/24] ppc405_uc: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 13/24] ppc4xx_sdram: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 14/24] stellaris_enet: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 15/24] sysbus: add a variant of sysbus_init_mmio_cb with an unmap callback Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 16/24] sh_pci: convert to memory API Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 17/24] arm11mpcore: use sysbus_init_mmio_cb2 Avi Kivity
2011-08-15 14:17 ` Avi Kivity [this message]
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 19/24] ppce500_pci: convert to sysbus_init_mmio_cb2() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 20/24] sysbus: remove sysbus_init_mmio_cb() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 21/24] isa: add isa_address_space() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 22/24] pci: add pci_address_space() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 23/24] vga: drop get_system_memory() from vga devices and derivatives Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 24/24] 440fx: fix PAM, PCI holes Avi Kivity
2011-08-22  7:38 ` [Qemu-devel] [PATCH v2 00/24] Memory API batch 4: more conversions Avi Kivity
2011-08-22 16:33 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1313417858-6454-19-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).