From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8DL0-0008IG-Kx for qemu-devel@nongnu.org; Sun, 24 May 2009 09:02:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8DKw-0008Gd-LS for qemu-devel@nongnu.org; Sun, 24 May 2009 09:02:02 -0400 Received: from [199.232.76.173] (port=33933 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8DDp-0005fh-4A for qemu-devel@nongnu.org; Sun, 24 May 2009 08:54:37 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49165) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M8A1T-000147-AD for qemu-devel@nongnu.org; Sun, 24 May 2009 05:29:39 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4O9Tc4b008265 for ; Sun, 24 May 2009 05:29:38 -0400 From: Avi Kivity Date: Sun, 24 May 2009 12:29:33 +0300 Message-Id: <1243157375-14329-2-git-send-email-avi@redhat.com> In-Reply-To: <1243157375-14329-1-git-send-email-avi@redhat.com> References: <1243157375-14329-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] Add PhysicalMemoryRegion type List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org A PhysicalMemoryRegion represents a region in the physical address space. Cuurently supported operations include creation and destruction. Signed-off-by: Avi Kivity --- 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