qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: ksourav <sourav.jb1988@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Subject: Re: [Qemu-devel] object owner argument of memory_region_init_ram
Date: Wed, 23 Jan 2019 07:10:37 +0100	[thread overview]
Message-ID: <628a94ba-2202-6a15-865b-16d52653288d@redhat.com> (raw)
In-Reply-To: <CAAJhNetR-8z37JuOmFDRuq3JfG_S03VDZkciqiKh_kieoqxQ1g@mail.gmail.com>

On 2019-01-23 04:07, ksourav wrote:
> Hi All,
> 
> I am trying to learn how qemu implements different soc.
> While reading the source code, I found that in some socs, object owner
> is passed as NULL to the routine memory_region_init_ram() (for example
> in nrf51 soc) and in some socs(for example in Allwinner A10) an
> object(non NULL) is passed to memory_region_initi_ram().
> When I checked docs/devel/memory.txt, I found below lines.
> "For regions that "have no owner" (NULL is passed at creation time), the
> machine object is actually used as the owner."
> Is the machine object refers to the actual board instance that will
> use the soc? For example microbit in case of nrf51 soc ?
> Is there any reason of not passing object as owner or in other words,
> when do we pass NULL or an object to memory_region_initi_ram() ?

I'm not an expert here, but when you look at the description of
memory_region_init_ram() in include/exec/memory.h:

 * @owner: the object that tracks the region's reference count (must be
 *         TYPE_DEVICE or a subclass of TYPE_DEVICE, or NULL)

So if you're calling memory_region_init_ram() from a device's
instance_init() or realize() function, you should use the current device
state as owner. But if you want to call the function from a
MachineClass->init function instead already, you don't have a
DeviceState* yet, so you have to use NULL there.

 HTH,
  Thomas

  reply	other threads:[~2019-01-23  6:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-23  3:07 [Qemu-devel] object owner argument of memory_region_init_ram ksourav
2019-01-23  6:10 ` Thomas Huth [this message]
2019-01-23 10:53   ` [Qemu-devel] [Qemu-arm] " Peter Maydell
2019-01-23 15:50     ` ksourav
2019-01-25 12:40       ` Thomas Huth

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=628a94ba-2202-6a15-865b-16d52653288d@redhat.com \
    --to=thuth@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sourav.jb1988@gmail.com \
    /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).