qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Pratik Parvati <pratikp@vayavyalabs.com>, qemu-devel@nongnu.org
Subject: Re: sysbus_create_simple Vs qdev_create
Date: Tue, 14 Jul 2020 19:02:24 +0200	[thread overview]
Message-ID: <adb25c78-2edc-115a-5264-ca9f97864ec7@redhat.com> (raw)
In-Reply-To: <CA+aXn+HHXAmT6Ljj2tpovGAYSurHKSdtUL3y-89t31B0e7jpsA@mail.gmail.com>

Hi Pratik,

On 7/14/20 6:17 PM, Pratik Parvati wrote:
> Here is a brief context that might help you.
> I am referring hw/arm/versatilepb.c
> 
> The ARM PrimeCell UART (PL011) device created as follows
> 
> |dev = qdev_create(NULL, "pl011"); s = SYS_BUS_DEVICE(dev);
> qdev_prop_set_chr(dev, "chardev", chr); qdev_init_nofail(dev);
> sysbus_mmio_map(s, 0, addr); sysbus_connect_irq(s, 0, irq); |
> 
> Whereas the PL031 RTC device is created as
> 
> |/* Add PL031 Real Time Clock. */ sysbus_create_simple("pl031",
> 0x101e8000, pic[10]); |
> 
> What is the difference between these two devices creation?

Both devices inherit SysBusDevice, which itself inherits QDev.

You can create QDev objects with the qdev API, and
SysBusDevice objects with the sysbus API.

sysbus_create_simple() is a condensed helper, but only allow you
to pass qemu_irq objects, not a 'chardev' property. So for this
case you have to use the qdev API instead.

> How do I know
> which method to use while creating an object?

SysBusDevice are plugged onto a bus. QDev aren't.
The sysbus API results in smaller code, easier to review.

> 
> Thanks & Regards,
> 
> Pratik
> 
> 
> On Tue, Jul 14, 2020 at 9:39 PM Pratik Parvati <pratikp@vayavyalabs.com
> <mailto:pratikp@vayavyalabs.com>> wrote:
> 
>     Hi Support team,
> 
>     Can someone please guide me to understand the difference between
>     *sysbus_create_simple *and *qdev_create*?.
> 
>     I understand that these two methods are used to create a new device.
>     But, when to use these functions is not clear to me.
> 
>     Regards,
>     Pratik
> 



  reply	other threads:[~2020-07-14 17:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 16:09 sysbus_create_simple Vs qdev_create Pratik Parvati
2020-07-14 16:17 ` Pratik Parvati
2020-07-14 17:02   ` Philippe Mathieu-Daudé [this message]
2020-07-15  8:32     ` Markus Armbruster
2020-07-15 13:58       ` Pratik Parvati
2020-07-15 14:11         ` Peter Maydell
2020-07-15 14:37         ` Markus Armbruster
2020-07-16 22:21           ` Eduardo Habkost
2020-07-17  5:10             ` Markus Armbruster
2020-07-17 16:23               ` Eduardo Habkost
2020-07-17 16:30                 ` Daniel P. Berrangé
2020-07-17 17:15                   ` Peter Maydell
2020-07-20  7:39                     ` Markus Armbruster
2020-07-20  7:38                 ` Markus Armbruster
2020-07-20 15:59                   ` Eduardo Habkost
2020-07-21  6:00                     ` Markus Armbruster
2020-07-27 14:29                       ` Paolo Bonzini
2020-07-28  7:19                         ` Markus Armbruster
2020-07-28 17:38                           ` Paolo Bonzini
2020-07-28 22:47                             ` Eduardo Habkost
2020-07-29  9:54                               ` Paolo Bonzini
2020-07-29 13:18                                 ` Markus Armbruster
2020-07-29 16:08                                   ` Paolo Bonzini
2020-07-30 10:03                                     ` Markus Armbruster
2020-07-30 11:09                                       ` Paolo Bonzini
2020-07-30 12:36                                         ` Markus Armbruster
2020-07-30 13:38                                           ` Paolo Bonzini
2020-07-29 14:32                                 ` Eduardo Habkost
2020-07-29 16:01                                   ` Paolo Bonzini
2020-07-29 16:08                                     ` Eduardo Habkost
2020-07-29 16:14                                       ` Paolo Bonzini
2020-07-29  7:46                             ` Markus Armbruster

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=adb25c78-2edc-115a-5264-ca9f97864ec7@redhat.com \
    --to=philmd@redhat.com \
    --cc=pratikp@vayavyalabs.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).