From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 23/66] memory: introduce memory_region_present
Date: Thu, 4 Jul 2013 17:13:19 +0200 [thread overview]
Message-ID: <1372950842-32422-24-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1372950842-32422-1-git-send-email-pbonzini@redhat.com>
This new API will avoid having too many memory_region_ref/unref
in paths that currently use memory_region_find.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/acpi/piix4.c | 6 +++---
hw/isa/lpc_ich9.c | 8 ++++----
include/exec/memory.h | 12 ++++++++++++
memory.c | 9 +++++++++
4 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 3b95c69..10fc925 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -388,10 +388,10 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)
pci_conf = s->dev.config;
pci_conf[0x5f] = 0x10 |
- (memory_region_find(io_as, 0x378, 1).mr ? 0x80 : 0);
+ (memory_region_present(io_as, 0x378) ? 0x80 : 0);
pci_conf[0x63] = 0x60;
- pci_conf[0x67] = (memory_region_find(io_as, 0x3f8, 1).mr ? 0x08 : 0) |
- (memory_region_find(io_as, 0x2f8, 1).mr ? 0x90 : 0);
+ pci_conf[0x67] = (memory_region_present(io_as, 0x3f8) ? 0x08 : 0) |
+ (memory_region_present(io_as, 0x2f8) ? 0x90 : 0);
}
static int piix4_pm_initfn(PCIDevice *dev)
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 82f8ea6..f704c42 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -481,19 +481,19 @@ static void ich9_lpc_machine_ready(Notifier *n, void *opaque)
uint8_t *pci_conf;
pci_conf = s->d.config;
- if (memory_region_find(io_as, 0x3f8, 1).mr) {
+ if (memory_region_present(io_as, 0x3f8)) {
/* com1 */
pci_conf[0x82] |= 0x01;
}
- if (memory_region_find(io_as, 0x2f8, 1).mr) {
+ if (memory_region_present(io_as, 0x2f8)) {
/* com2 */
pci_conf[0x82] |= 0x02;
}
- if (memory_region_find(io_as, 0x378, 1).mr) {
+ if (memory_region_present(io_as, 0x378)) {
/* lpt */
pci_conf[0x82] |= 0x04;
}
- if (memory_region_find(io_as, 0x3f0, 1).mr) {
+ if (memory_region_present(io_as, 0x3f0)) {
/* floppy */
pci_conf[0x82] |= 0x08;
}
diff --git a/include/exec/memory.h b/include/exec/memory.h
index d2466a7..c8d0bf4 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -837,6 +837,18 @@ void memory_region_set_alias_offset(MemoryRegion *mr,
hwaddr offset);
/**
+ * memory_region_present: translate an address/size relative to a
+ * MemoryRegion into a #MemoryRegionSection.
+ *
+ * Answer whether a #MemoryRegion within @parent covers the address
+ * @addr.
+ *
+ * @parent: a MemoryRegion within which @addr is a relative address
+ * @addr: the area within @parent to be searched
+ */
+bool memory_region_present(MemoryRegion *parent, hwaddr addr);
+
+/**
* memory_region_find: translate an address/size relative to a
* MemoryRegion into a #MemoryRegionSection.
*
diff --git a/memory.c b/memory.c
index e04d519..24027c5 100644
--- a/memory.c
+++ b/memory.c
@@ -1478,6 +1478,15 @@ static FlatRange *address_space_lookup(AddressSpace *as, AddrRange addr)
sizeof(FlatRange), cmp_flatrange_addr);
}
+bool memory_region_present(MemoryRegion *parent, hwaddr addr)
+{
+ MemoryRegion *mr = memory_region_find(parent, addr, 1).mr;
+ if (!mr) {
+ return false;
+ }
+ return true;
+}
+
MemoryRegionSection memory_region_find(MemoryRegion *mr,
hwaddr addr, uint64_t size)
{
--
1.8.1.4
next prev parent reply other threads:[~2013-07-04 15:15 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 15:12 [Qemu-devel] [PULL 00/66] Memory API changes for 1.6: ownership, I/O ports, RCU preparation Paolo Bonzini
2013-07-04 15:12 ` [Qemu-devel] [PATCH 01/66] int128: optimize and add test cases Paolo Bonzini
2013-07-04 15:12 ` [Qemu-devel] [PATCH 02/66] scsi: keep device alive while it has requests Paolo Bonzini
2013-07-04 15:12 ` [Qemu-devel] [PATCH 03/66] dma: keep a device alive while it has SGLists Paolo Bonzini
2013-07-04 15:51 ` Jan Kiszka
2013-07-04 15:59 ` Jan Kiszka
2013-07-04 16:00 ` Paolo Bonzini
2013-07-04 16:17 ` Jan Kiszka
2013-07-04 15:13 ` [Qemu-devel] [PATCH 04/66] adlib: replace register_ioport* Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 05/66] applesmc: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 06/66] wdt_ib700: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 07/66] i82374: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 08/66] prep: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 09/66] vt82c686: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 10/66] Privatize register_ioport_read/write Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 11/66] isa: implement isa_is_ioport_assigned via memory_region_find Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 12/66] vmware-vga: Accept unaligned I/O accesses Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 13/66] xen: Mark fixed platform I/O as unaligned Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 14/66] ioport: Switch dispatching to memory core layer Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 15/66] ioport: Remove unused old dispatching services Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 16/66] vmport: Disentangle read handler type from portio Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 17/66] ioport: Move portio types to ioport.h Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 19/66] memory: destroy phys_sections one by one Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 20/66] exec: simplify destruction of the phys map Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 21/66] memory: add getter for owner Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 22/66] memory: add ref/unref Paolo Bonzini
2013-07-04 15:13 ` Paolo Bonzini [this message]
2013-07-04 15:13 ` [Qemu-devel] [PATCH 24/66] memory: add ref/unref calls Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 25/66] exec: check MRU in qemu_ram_addr_from_host Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 26/66] exec: move qemu_ram_addr_from_host_nofail to cputlb.c Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 27/66] memory: return MemoryRegion from qemu_ram_addr_from_host Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 28/66] exec: reorganize address_space_map Paolo Bonzini
2013-07-08 8:21 ` Peter Maydell
2013-07-04 15:13 ` [Qemu-devel] [PATCH 29/66] memory: ref/unref memory across address_space_map/unmap Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 30/66] escc: rename struct to ESCCState Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 31/66] vga: pass owner to vga_init Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 32/66] vga: pass owner to vga_common_init Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 33/66] vga: pass owner to cirrus_init_common Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 34/66] vga: pass owner to vga_init_vbe Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 35/66] vga: pass owner to vga_init_io Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 36/66] vga: set owner in vga_update_memory_access Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 37/66] ne2000: pass device to ne2000_setup_io, use it as owner Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 38/66] vfio: pass device to vfio_mmap_bar and use it to set owner Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 39/66] spapr_iommu: pass device to spapr_tce_new_table " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 40/66] pam: pass device to init_pam " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 41/66] piolist: add owner argument to initialization functions and pass devices Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 42/66] hw/a*: pass owner to memory_region_init* functions Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 43/66] hw/block: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 44/66] hw/c*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 45/66] hw/d*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 46/66] hw/gpio: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 47/66] hw/i*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 48/66] hw/m*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 49/66] hw/n*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 50/66] hw/p*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 51/66] hw/s*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 52/66] hw/t*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 53/66] hw/[u-x]*: " Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 54/66] add a header file for atomic operations Paolo Bonzini
2013-10-20 16:20 ` Peter Maydell
2013-10-21 6:06 ` Paolo Bonzini
2013-10-21 13:53 ` Peter Maydell
2013-10-22 5:45 ` Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 55/66] memory: access FlatView from a local variable Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 56/66] memory: use a new FlatView pointer on every topology update Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 57/66] memory: add reference counting to FlatView Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 58/66] qom: Use atomics for object refcounting Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 59/66] exec: change well-known physical sections to macros Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 60/66] exec: separate current memory map from the one being built Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 61/66] memory: move MemoryListener declaration earlier Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 62/66] exec: move listener from AddressSpaceDispatch to AddressSpace Paolo Bonzini
2013-07-04 15:13 ` [Qemu-devel] [PATCH 63/66] exec: separate current radix tree from the one being built Paolo Bonzini
2013-07-04 15:14 ` [Qemu-devel] [PATCH 64/66] exec: put memory map in AddressSpaceDispatch Paolo Bonzini
2013-07-04 15:14 ` [Qemu-devel] [PATCH 65/66] exec: remove cur_map Paolo Bonzini
2013-07-04 15:14 ` [Qemu-devel] [PATCH 66/66] exec: change some APIs to take AddressSpaceDispatch Paolo Bonzini
2013-07-04 15:52 ` [Qemu-devel] [PULL 00/66] Memory API changes for 1.6: ownership, I/O ports, RCU preparation Paolo Bonzini
2013-07-04 16:08 ` Paolo Bonzini
2013-07-08 13:20 ` 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=1372950842-32422-24-git-send-email-pbonzini@redhat.com \
--to=pbonzini@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).