On 05/01/2012 09:00 AM, Peter Maydell wrote:
On 1 May 2012 14:50, Anthony Liguori<anth...@codemonkey.ws>  wrote:
On 05/01/2012 03:49 PM, Peter Maydell wrote:
When QOM supports (1) exporting gpio signals and


This is trivial.  It'll come in as soon as 1.2 opens up.

You need to get it through code review first...

Obviously.


(just as a random example, this commit:
https://github.com/aliguori/qemu/commit/46483049813fca2c23fb7cd04eeab89905500c4c
is going down the wrong path because it's incorrectly introducing
knowledge of device internals to the utility i8259_init()
function.)

Eh?

Do you mean:

-    qdev_connect_gpio_out(&dev->qdev, 0, irq_set[2]);
+    pin_connect_qemu_irq(&s->int_out[0], irq_set[2]);

There are three ways to do this:

1) pin_connect_qemu_irq(i8259_get_int_out(s), irq_set[2]);

2) pin_connect_qemu_irq(&s->int_out[0], irq_set[2]);

3) pin_connect_qemu_irq(PIN(object_get_child(s, "int_out[0]")), irq_set[2]);

Having converted a lot of devices by hand, I prefer (2). I'd like to move to a model of:

typedef struct PICDevice
{
    DeviceState parent;

    Pin int_out[0];
    MemoryRegion io;

    /*< private >*/
    PICState *priv;
} PICDevice;

This let's us use (2), while still embedding devices and keeping the gory state details private to the implementation.

Regards,

Anthony Liguori


-- PMM


Reply via email to