qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When is SysBusDevice's num_mmios determined? and does SYS_BUS_DEVICE


From: Peter Maydell
Subject: Re: When is SysBusDevice's num_mmios determined? and does SYS_BUS_DEVICE macro allocate memory?
Date: Fri, 4 Jun 2021 10:02:40 +0100

On Fri, 4 Jun 2021 at 09:47, <ckim@etri.re.kr> wrote:

> The sysbus_mmio_map function checks if the given mmio range number (here 0) 
> is between 0 and num_mmios of the SyBusDevice.
>
> But when is the num_mmios value inside the struct SysBusDevice determined? I 
> couldn’t follow it up.

num_mmios starts at zero, and every time the device calls
sysbus_init_mmio() it is incremented. The assertion in
sysbus_mmio_map() is checking "did the caller ask for an
MMIO region which the device didn't create?".

> And SysBusDevice includes DeviceState, then does the
> s = SYS_BUS_DEVICE(dev) statement allocates the
> SysBusDevice on memory?

No. This is a typechecked cast of a pointer. It's equivalent
to "s = (SysBusDevice *)dev;" except that it will assert if
"dev" is not actually a pointer to an instance of SysBusDevice.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]