From: Scott Wood <scottwood@freescale.com>
To: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] memory: Add MemoryRegion get address space offset helper function
Date: Fri, 5 Sep 2014 10:31:47 -0500 [thread overview]
Message-ID: <1409931107.24184.191.camel@snotra.buserror.net> (raw)
In-Reply-To: <1409769375-22286-2-git-send-email-bogdan.purcareata@freescale.com>
On Wed, 2014-09-03 at 14:36 -0400, Bogdan Purcareata wrote:
> Adding this function would allow a MemoryRegion to compute its start address
> within the AddressSpace. This is done recursively based on mr->container.
>
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
> ---
> include/exec/memory.h | 8 ++++++++
> memory.c | 10 ++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index d165b27..7503819 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -444,6 +444,14 @@ struct Object *memory_region_owner(MemoryRegion *mr);
> uint64_t memory_region_size(MemoryRegion *mr);
>
> /**
> + * memory_region_get_address_space_offset: get a memory region's address
> + * within the address space
> + *
> + * @mr: the memory region being queried.
> + */
> +hwaddr memory_region_get_address_space_offset(MemoryRegion *mr);
Hmm, this seems familiar:
http://patchwork.ozlabs.org/patch/220385/
http://patchwork.ozlabs.org/patch/236764/
:-)
> +
> +/**
> * memory_region_is_ram: check whether a memory region is random access
> *
> * Returns %true is a memory region is random access.
> diff --git a/memory.c b/memory.c
> index ef0be1c..7445032 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1307,6 +1307,16 @@ uint64_t memory_region_size(MemoryRegion *mr)
> return int128_get64(mr->size);
> }
>
> +hwaddr memory_region_get_address_space_offset(MemoryRegion *mr)
> +{
> + MemoryRegion *p;
> + hwaddr result = 0x0;
> +
> + for (p = mr; p != NULL; result += p->addr, p = p->container);
> +
> + return result;
> +}
This would be more readable as:
while (mr) {
result += mr->addr;
mr = mr->container;
}
-Scott
next prev parent reply other threads:[~2014-09-05 17:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 18:36 [Qemu-devel] [PATCH 0/2] PPC: kvm: Fix incorrect remapping of in-kernel MPIC Bogdan Purcareata
2014-09-03 18:36 ` [Qemu-devel] [PATCH 1/2] memory: Add MemoryRegion get address space offset helper function Bogdan Purcareata
2014-09-05 15:31 ` Scott Wood [this message]
2014-09-03 18:36 ` [Qemu-devel] [PATCH 2/2] PPC: openpic_kvm: Filter region callbacks based on memory region offset Bogdan Purcareata
2014-09-05 15:47 ` [Qemu-devel] [Qemu-ppc] " Scott Wood
2014-09-10 11:40 ` bogdan.purcareata
2014-09-10 13:56 ` Alexander Graf
2014-09-11 10:14 ` bogdan.purcareata
2014-09-11 10:27 ` Alexander Graf
2014-09-05 9:07 ` [Qemu-devel] [Qemu-ppc] [PATCH 0/2] PPC: kvm: Fix incorrect remapping of in-kernel MPIC Alexander Graf
2014-09-05 9:08 ` Alexander Graf
2014-09-05 12:59 ` mihai.caraman
2014-09-05 14:31 ` mihai.caraman
2014-09-10 12:49 ` Alexander Graf
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=1409931107.24184.191.camel@snotra.buserror.net \
--to=scottwood@freescale.com \
--cc=bogdan.purcareata@freescale.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).