qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Fwd: Trying to write a new device / virtio-i2c ?


From: Paolo Bonzini
Subject: Re: [Qemu-devel] Fwd: Trying to write a new device / virtio-i2c ?
Date: Mon, 17 Feb 2014 14:19:35 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

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



reply via email to

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