qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Fabien Chouteau <chouteau@adacore.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Alexander Graf <agraf@suse.de>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] GSoC mentor summit QEMU users session
Date: Wed, 02 Nov 2011 19:17:54 +0100	[thread overview]
Message-ID: <4EB18952.4080403@siemens.com> (raw)
In-Reply-To: <4EB18172.1020905@adacore.com>

On 2011-11-02 18:44, Fabien Chouteau wrote:
> On 31/10/2011 14:12, Peter Maydell wrote:
>> On 29 October 2011 14:52, Alexander Graf <agraf@suse.de> wrote:
>>> A lot of people seem to also have code that doesn't make sense
>>> upstream, for example implementing a one-off device that only
>>> really matters for their own devboard which nobody else owns.
>>> For such cases, having a plugin framework would be handy. I
>>> interestingly enough got into the same discussion on LinuxCon
>>> with some QEMU downstreams.
>>
>> If we get the qdev rework done then I think we're probably in
>> a better position to have a plugin framework for devices. (There
>> are some issues about API and ABI stability guarantees, of course.)
>>
> 
> Interesting, we have a "plug-in" implementation in our Qemu branch. It

We have a "plugin" model here as well. It's really simple: the plugin is
loaded dynamically into the QEMU process and can access any global
function and variable. Of course, this breaks regularly.

> allows a plug-ins to register io_areas, read and write callback, trigger
> interrupts, etc...
> 
> Qemu provides this interface to the plug-in:
> 
> struct QemuPlugin_Emulator
> {
>     uint64_t (*get_time)(QemuPlugin_ClockType clock);
> 
> 
>     uint32_t (*add_event)(uint64_t              expire_time,
>                           QemuPlugin_ClockType  clock,
>                           uint32_t              event_id,
>                           EventCallback         event,
>                           void                 *opaque);
> 
>     uint32_t (*remove_event)(QemuPlugin_ClockType clock,
>                              uint32_t             event_id);
> 
>     uint32_t (*set_irq)(uint32_t line, uint32_t level);
> 
>     uint32_t (*dma_read)(void          *dest,
>                          target_addr_t  addr,
>                          int            size);
> 
>     uint32_t (*dma_write)(void          *src,
>                           target_addr_t  addr,
>                           int            size);
> 
>     uint32_t (*attach_device)(QemuPlugin_DeviceInfo *dev);
> 
>     uint32_t version;
> };
> 
> and the plug-in provides this interface to Qemu:
> 
> typedef uint32_t io_read_fn(void *opaque, target_addr_t addr, uint32_t size);
> 
> typedef void     io_write_fn(void          *opaque,
>                              target_addr_t  addr,
>                              uint32_t       size,
>                              uint32_t       val);
> 
> typedef void reset_fn(void *opaque);
> typedef void init_fn(void *opaque);
> typedef void exit_fn(void *opaque);
> 
> typedef struct QemuPlugin_DeviceInfo
> {
>     uint32_t version;
> 
>     uint32_t vendor_id;
>     uint32_t device_id;
>     char     name[NAME_LENGTH];
>     char     desc[DESC_LENGTH];
> 
>     void *opaque;
> 
>     io_read_fn  *io_read;
>     io_write_fn *io_write;
> 
>     reset_fn *pdevice_reset;
>     init_fn  *pdevice_init;
>     exit_fn  *pdevice_exit;
> 
>     uint32_t nr_iomem;
>     struct QemuPlugin_IOMemory
>     {
>         target_addr_t base;
>         target_addr_t size;
>     } iomem[MAX_IOMEM];
> } QemuPlugin_DeviceInfo;
> 

To implement, e.g., a custom PCI device, you still need a stub in QEMU
with that model. But you want access to the PCI layer, the MSI services,
etc. anyway - unless you plan to reinvent all that wheels.

Another example: How do you model a USB device this way?

IOW, we need a plugin model that can interact with other components at
their interface level, not only through a central, naturally restricted one.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  reply	other threads:[~2011-11-02 18:18 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-29 13:52 [Qemu-devel] GSoC mentor summit QEMU users session Alexander Graf
2011-10-31 13:12 ` Peter Maydell
2011-11-01  0:08   ` Alexander Graf
2011-11-01  1:35     ` Peter Maydell
2011-11-01  4:29       ` Alexander Graf
2011-11-01 10:05   ` Gerd Hoffmann
2011-11-01 23:11     ` Chris Johns
2011-11-02 17:44   ` Fabien Chouteau
2011-11-02 18:17     ` Jan Kiszka [this message]
2011-11-02 18:29       ` Anthony Liguori
2011-11-02 18:34         ` Alexander Graf
2011-11-02 18:46           ` Jan Kiszka
2011-11-02 18:47             ` Alexander Graf
2011-11-02 19:07               ` Peter Maydell
2011-11-02 19:27                 ` Alexander Graf
2011-11-02 19:35                   ` Anthony Liguori
2011-11-02 20:24                     ` Blue Swirl
2011-11-02 20:42                       ` Anthony Liguori
2011-11-03  7:34                         ` Markus Armbruster
2011-11-03  7:46                     ` Markus Armbruster
2011-11-03  8:36                       ` Andreas Färber
2011-11-04 15:47                         ` Alexander Graf
2011-11-02 18:50             ` Anthony Liguori
2011-11-02 18:52               ` Jan Kiszka
2011-11-02 18:51           ` Anthony Liguori
2011-11-03  7:38             ` Stefan Hajnoczi
2011-11-03  7:44           ` Markus Armbruster
2011-11-01 14:28 ` Andreas Färber
2011-11-01 14:50   ` Anthony Liguori
2011-11-02 17:39 ` Fabien Chouteau
2011-11-03  7:44   ` Stefan Hajnoczi
2011-11-03  9:35     ` Fabien Chouteau
2011-11-04  8:36       ` Stefan Hajnoczi
2011-11-04  9:53         ` Fabien Chouteau
2011-11-04 12:04           ` Stefan Hajnoczi
2011-11-04 14:36             ` Fabien Chouteau
2011-11-04 18:45         ` Lluís Vilanova
2011-11-07 10:16           ` Fabien Chouteau
2011-11-07 11:50             ` Lluís Vilanova
2011-11-07 13:51               ` Fabien Chouteau
2011-11-07 14:17                 ` Lluís Vilanova

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=4EB18952.4080403@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=agraf@suse.de \
    --cc=chouteau@adacore.com \
    --cc=peter.maydell@linaro.org \
    --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).