[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] object owner argument of memory_region_init_ram
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] object owner argument of memory_region_init_ram |
Date: |
Wed, 23 Jan 2019 07:10:37 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
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