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 07/24] gt64xxx.c: convert to memory API
Date: Mon, 15 Aug 2011 17:17:21 +0300	[thread overview]
Message-ID: <1313417858-6454-8-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/gt64xxx.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
index d541558..6af9782 100644
--- a/hw/gt64xxx.c
+++ b/hw/gt64xxx.c
@@ -227,7 +227,7 @@
 #define PCI_MAPPING_ENTRY(regname)            \
     target_phys_addr_t regname ##_start;      \
     target_phys_addr_t regname ##_length;     \
-    int regname ##_handle
+    MemoryRegion regname ##_mem
 
 typedef struct GT64120State {
     SysBusDevice busdev;
@@ -269,9 +269,9 @@ static void gt64120_isd_mapping(GT64120State *s)
     target_phys_addr_t start = s->regs[GT_ISD] << 21;
     target_phys_addr_t length = 0x1000;
 
-    if (s->ISD_length)
-        cpu_register_physical_memory(s->ISD_start, s->ISD_length,
-                                     IO_MEM_UNASSIGNED);
+    if (s->ISD_length) {
+        memory_region_del_subregion(get_system_memory(), &s->ISD_mem);
+    }
     check_reserved_space(&start, &length);
     length = 0x1000;
     /* Map new address */
@@ -279,7 +279,7 @@ static void gt64120_isd_mapping(GT64120State *s)
             length, start, s->ISD_handle);
     s->ISD_start = start;
     s->ISD_length = length;
-    cpu_register_physical_memory(s->ISD_start, s->ISD_length, s->ISD_handle);
+    memory_region_add_subregion(get_system_memory(), s->ISD_start, &s->ISD_mem);
 }
 
 static void gt64120_pci_mapping(GT64120State *s)
@@ -290,7 +290,8 @@ static void gt64120_pci_mapping(GT64120State *s)
       /* Unmap old IO address */
       if (s->PCI0IO_length)
       {
-        cpu_register_physical_memory(s->PCI0IO_start, s->PCI0IO_length, IO_MEM_UNASSIGNED);
+          memory_region_del_subregion(get_system_memory(), &s->PCI0IO_mem);
+          memory_region_destroy(&s->PCI0IO_mem);
       }
       /* Map new IO address */
       s->PCI0IO_start = s->regs[GT_PCI0IOLD] << 21;
@@ -301,7 +302,7 @@ static void gt64120_pci_mapping(GT64120State *s)
 }
 
 static void gt64120_writel (void *opaque, target_phys_addr_t addr,
-                            uint32_t val)
+                            uint64_t val, unsigned size)
 {
     GT64120State *s = opaque;
     uint32_t saddr;
@@ -579,8 +580,8 @@ static void gt64120_writel (void *opaque, target_phys_addr_t addr,
     }
 }
 
-static uint32_t gt64120_readl (void *opaque,
-                               target_phys_addr_t addr)
+static uint64_t gt64120_readl (void *opaque,
+                               target_phys_addr_t addr, unsigned size)
 {
     GT64120State *s = opaque;
     uint32_t val;
@@ -851,16 +852,10 @@ static uint32_t gt64120_readl (void *opaque,
     return val;
 }
 
-static CPUWriteMemoryFunc * const gt64120_write[] = {
-    &gt64120_writel,
-    &gt64120_writel,
-    &gt64120_writel,
-};
-
-static CPUReadMemoryFunc * const gt64120_read[] = {
-    &gt64120_readl,
-    &gt64120_readl,
-    &gt64120_readl,
+static const MemoryRegionOps isd_mem_ops = {
+    .read = gt64120_readl,
+    .write = gt64120_writel,
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static int gt64120_pci_map_irq(PCIDevice *pci_dev, int irq_num)
@@ -1097,8 +1092,7 @@ PCIBus *gt64120_register(qemu_irq *pic)
                                   get_system_memory(),
                                   get_system_io(),
                                   PCI_DEVFN(18, 0), 4);
-    d->ISD_handle = cpu_register_io_memory(gt64120_read, gt64120_write, d,
-                                           DEVICE_NATIVE_ENDIAN);
+    memory_region_init_io(&d->ISD_mem, &isd_mem_ops, d, "isd-mem", 0x1000);
 
     pci_create_simple(d->pci.bus, PCI_DEVFN(0, 0), "gt64120_pci");
     return d->pci.bus;
-- 
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 ` Avi Kivity [this message]
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 ` [Qemu-devel] [PATCH v2 18/24] versatile_pci: convert to memory API Avi Kivity
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-8-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).