qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/3] Add PhysicalMemoryRegion type
Date: Sun, 24 May 2009 12:29:33 +0300	[thread overview]
Message-ID: <1243157375-14329-2-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1243157375-14329-1-git-send-email-avi@redhat.com>

A PhysicalMemoryRegion represents a region in the physical address space.
Cuurently supported operations include creation and destruction.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 cpu-all.h |   13 +++++++++++++
 exec.c    |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 0df54b6..dc9c8b7 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -893,6 +893,19 @@ extern ram_addr_t last_ram_offset;
 typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
 typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
 
+typedef struct PhysicalMemoryRegion PhysicalMemoryRegion;
+
+PhysicalMemoryRegion *physical_memory_region_register(
+    target_phys_addr_t start_addr,
+    target_phys_addr_t size,
+    ram_addr_t ram_addr);
+PhysicalMemoryRegion *physical_memory_region_register_offset(
+    target_phys_addr_t start_addr,
+    target_phys_addr_t size,
+    ram_addr_t ram_addr,
+    ram_addr_t region_offset);
+void physical_memory_region_unregister(PhysicalMemoryRegion *pmr);
+
 void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
                                          ram_addr_t size,
                                          ram_addr_t phys_offset,
diff --git a/exec.c b/exec.c
index c5c9280..03c03dc 100644
--- a/exec.c
+++ b/exec.c
@@ -2418,6 +2418,48 @@ void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
     }
 }
 
+struct PhysicalMemoryRegion {
+    target_phys_addr_t start_addr;
+    target_phys_addr_t size;
+    ram_addr_t ram_addr;
+    ram_addr_t region_offset;
+};
+
+PhysicalMemoryRegion *physical_memory_region_register(
+    target_phys_addr_t start_addr,
+    target_phys_addr_t size,
+    ram_addr_t ram_addr)
+{
+    return physical_memory_region_register_offset(start_addr, size, ram_addr, 0);
+}
+
+PhysicalMemoryRegion *physical_memory_region_register_offset(
+    target_phys_addr_t start_addr,
+    target_phys_addr_t size,
+    ram_addr_t ram_addr,
+    ram_addr_t region_offset)
+{
+    PhysicalMemoryRegion *pmr = (PhysicalMemoryRegion *)qemu_malloc(sizeof(*pmr));
+
+    pmr->start_addr = start_addr;
+    pmr->size = size;
+    pmr->ram_addr = ram_addr;
+    pmr->region_offset = region_offset;
+
+    cpu_register_physical_memory_offset(start_addr, size, ram_addr, region_offset);
+
+    return pmr;
+}
+
+void physical_memory_region_unregister(PhysicalMemoryRegion *pmr)
+{
+    if (kvm_enabled()) {
+        kvm_uncoalesce_mmio_region(pmr->start_addr, pmr->size);
+    }
+    cpu_register_physical_memory(pmr->start_addr, pmr->size, IO_MEM_UNASSIGNED);
+    qemu_free(pmr);
+}
+
 /* XXX: temporary until new memory mapping API */
 ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr)
 {
-- 
1.6.0.6

  reply	other threads:[~2009-05-24 13:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-24  9:29 [Qemu-devel] [PATCH 0/3] Object-based physical memory management Avi Kivity
2009-05-24  9:29 ` Avi Kivity [this message]
2009-05-27 14:16   ` [Qemu-devel] [PATCH 1/3] Add PhysicalMemoryRegion type Christoph Hellwig
2009-05-27 15:07     ` Avi Kivity
2009-05-24  9:29 ` [Qemu-devel] [PATCH 2/3] Add PCI memory region registration Avi Kivity
2009-05-27 14:08   ` Anthony Liguori
2009-05-27 15:02     ` Avi Kivity
2009-05-27 15:11       ` Anthony Liguori
2009-05-27 15:24         ` Avi Kivity
2009-05-27 22:33           ` Anthony Liguori
2009-05-31 11:02             ` Christoph Hellwig
2009-05-31 11:50               ` Avi Kivity
2009-05-31 11:47             ` Avi Kivity
2009-05-31 13:52               ` Anthony Liguori
2009-05-31 13:03             ` Avi Kivity
2009-05-24  9:29 ` [Qemu-devel] [PATCH 3/3] Convert RTL8139 to use PCI memory regitration facility Avi Kivity
2009-05-27 14:08 ` [Qemu-devel] [PATCH 0/3] Object-based physical memory management Anthony Liguori
2009-05-27 14:54   ` Avi Kivity

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=1243157375-14329-2-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --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).