[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 10/33] memory: add memory_region_is_mapped() API
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v4 10/33] memory: add memory_region_is_mapped() API |
Date: |
Mon, 2 Jun 2014 15:25:06 +0200 |
which allows to check if MemoryRegion is already mapped.
Signed-off-by: Igor Mammedov <address@hidden>
---
v2:
simplify check, just by checking if MR has parent
---
include/exec/memory.h | 8 ++++++++
memory.c | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 1d55ad9..ab11c32 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -848,6 +848,14 @@ void memory_region_set_alias_offset(MemoryRegion *mr,
bool memory_region_present(MemoryRegion *parent, hwaddr addr);
/**
+ * memory_region_is_mapped: returns true if #MemoryRegion is mapped
+ * into any address space.
+ *
+ * @mr: a #MemoryRegion which should be checked if it's mapped
+ */
+bool memory_region_is_mapped(MemoryRegion *mr);
+
+/**
* memory_region_find: translate an address/size relative to a
* MemoryRegion into a #MemoryRegionSection.
*
diff --git a/memory.c b/memory.c
index 3f1df23..2c952ea 100644
--- a/memory.c
+++ b/memory.c
@@ -492,7 +492,7 @@ static AddressSpace
*memory_region_to_address_space(MemoryRegion *mr)
return as;
}
}
- abort();
+ return NULL;
}
/* Render a memory region into the global view. Ranges in @view obscure
@@ -1569,6 +1569,11 @@ bool memory_region_present(MemoryRegion *parent, hwaddr
addr)
return true;
}
+bool memory_region_is_mapped(MemoryRegion *mr)
+{
+ return mr->parent ? true : false;
+}
+
MemoryRegionSection memory_region_find(MemoryRegion *mr,
hwaddr addr, uint64_t size)
{
@@ -1586,6 +1591,9 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr,
}
as = memory_region_to_address_space(root);
+ if (!as) {
+ return ret;
+ }
range = addrrange_make(int128_make64(addr), int128_make64(size));
view = address_space_get_flatview(as);
--
1.7.1
- [Qemu-devel] [PATCH v4 01/33] pc: create custom generic PC machine type, (continued)
- [Qemu-devel] [PATCH v4 07/33] qdev: hotplug for buss-less devices, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 09/33] pc: implement pc-dimm device abstraction, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 08/33] qdev: expose DeviceState.hotplugged field as a property, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 06/33] vl.c: extend -m option to support options for memory hotplug, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 11/33] pc-dimm: do not allow to set already used memdev, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 10/33] memory: add memory_region_is_mapped() API,
Igor Mammedov <=
- [Qemu-devel] [PATCH v4 12/33] pc: initialize memory hotplug address space, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 13/33] pc: exit QEMU if number of slots more than supported 256, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 14/33] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 15/33] pc: exit QEMU if compat machine doesn't support memory hotlpug, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 17/33] pc-dimm: add busy address check and address auto-allocation, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 16/33] pc: add memory hotplug handler to PC_MACHINE, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 18/33] pc-dimm: add busy slot check and slot auto-allocation, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 19/33] acpi: rename cpu_hotplug_defs.h to pc-hotplug.h, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 20/33] acpi: memory hotplug ACPI hardware implementation, Igor Mammedov, 2014/06/02
- [Qemu-devel] [PATCH v4 21/33] trace: add acpi memory hotplug IO region events, Igor Mammedov, 2014/06/02