From: Paolo Bonzini <pbonzini@redhat.com>
To: Alex David <alex.daerf@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Fwd: Trying to write a new device / virtio-i2c ?
Date: Mon, 17 Feb 2014 14:19:35 +0100 [thread overview]
Message-ID: <53020C67.5040603@redhat.com> (raw)
In-Reply-To: <CAA17Vo9Js3f1B=dGcx-DHjBxVM6ciaYdZGoyQh0YfnYikN4XcA@mail.gmail.com>
Il 17/02/2014 14:11, Alex David ha scritto:
> I've tried using tmp105. As my linux isn't 64bits, i'm using
> qemu-system-i386... It crashes my computer when I use it with my linux
> image (it's a debian .qcow2..., easy to do some tests...).
You mean crashes your host?
> I will most probably need a chardev anyways, I will need to read/write
> data when I want to.
Depends on how much data. If it's just one or two ints, like tmp105,
QOM would work too. qmp-shell talks to QEMU via a simple JSON protocol,
and it has simple Python bindings too.
> static const TypeInfo mydevice_i2c_type_info = {
> .name = TYPE_MYDEVICE_I2C,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(MYDEVICEI2CState),
> .instance_init = MYDEVICE_i2c_init,
> .class_init = mydevice_i2c_class_init,
> };
>
> I will be able to add a chardev using the properties, right ?
Yes, using dc->props.
> Does this seems ok for you ? So far, I understood the "props" are needed
> for when I'm gonna declare the device at QEMU launch.
> I am not sure if it's needed (my i2c-0 should be created anyways), but
> in that case, how do I "plug" it on my socket on the host ?
Your device is not i2c-0. i2c-0 is provided by the PC board. Your
device will get one address, e.g. 0x42, on the i2c bus. You'll be able
to access it with i2cget and i2cset using "0" as the bus address (for
i2c-0) and 0x42 as the device address on bus 0.
So you'll indeed have to do something like "-chardev socket,id=foo
-device myi2c,address=0x42,chr=foo" if you go for sockets, or just
"-device myi2c,address=0x42" if you go for QOM. The "chr" property
should go into dc->props, while "address" is provided by the abstract
class TYPE_I2C_SLAVE.
Paolo
next prev parent reply other threads:[~2014-02-17 13:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 13:26 [Qemu-devel] Trying to write a new device / virtio-i2c ? Alex David
2014-02-14 15:26 ` Stefan Hajnoczi
2014-02-14 15:58 ` Paolo Bonzini
2014-02-14 16:31 ` Andreas Färber
2014-02-14 16:45 ` Paolo Bonzini
2014-02-17 8:35 ` Alex David
2014-02-17 9:19 ` Paolo Bonzini
[not found] ` <CAA17Vo9E9D-jPa3gwhsui3i=APz1FM-41jbK+zpOm2tWf7swdw@mail.gmail.com>
2014-02-17 9:38 ` [Qemu-devel] Fwd: " Alex David
2014-02-17 9:55 ` Paolo Bonzini
[not found] ` <CAA17Vo_cBCbKkqDu2zQ0DW2FoAyVqxVXGtNGArJ1tnk6N9AUqA@mail.gmail.com>
2014-02-17 10:38 ` Paolo Bonzini
2014-02-17 12:23 ` Alex David
2014-02-17 13:11 ` Alex David
2014-02-17 13:19 ` Paolo Bonzini [this message]
2014-02-17 13:32 ` Alex David
2014-02-17 14:30 ` Paolo Bonzini
2014-02-17 15:33 ` Alex David
2014-02-17 16:11 ` Paolo Bonzini
2014-02-18 12:48 ` Alex David
2014-02-18 13:05 ` Paolo Bonzini
2014-02-18 13:44 ` Alex David
2014-02-18 13:47 ` Paolo Bonzini
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=53020C67.5040603@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.daerf@gmail.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).