From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlFrs-0004C1-Pa for qemu-devel@nongnu.org; Thu, 12 Jan 2012 03:18:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlFro-00080j-3i for qemu-devel@nongnu.org; Thu, 12 Jan 2012 03:18:40 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45171 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlFrn-00080Z-Qt for qemu-devel@nongnu.org; Thu, 12 Jan 2012 03:18:36 -0500 Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=iso-8859-1 From: Alexander Graf In-Reply-To: <4F0E9550.2090702@siemens.com> Date: Thu, 12 Jan 2012 09:18:33 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <7FA9DB36-4A2F-4F15-AD67-AB77952F76F6@suse.de> References: <1309092433-4385-2-git-send-email-hpoussin@reactos.org> <4F0E2371.2010105@web.de> <4F0E8D2E.8050502@siemens.com> <4F0E9317.2010704@siemens.com> <4F0E9550.2090702@siemens.com> Subject: Re: [Qemu-devel] [PATCH 1/5] i8259: qdev-ify creation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: =?iso-8859-1?Q?Andreas_F=E4rber?= , =?iso-8859-1?Q?Herv=E9_Poussineau?= , qemu-devel Developers On 12.01.2012, at 09:09, Jan Kiszka wrote: > On 2012-01-12 09:05, Alexander Graf wrote: >>=20 >> On 12.01.2012, at 09:00, Jan Kiszka wrote: >>=20 >>> On 2012-01-12 08:58, Alexander Graf wrote: >>>>=20 >>>> On 12.01.2012, at 08:35, Jan Kiszka wrote: >>>>=20 >>>>> On 2012-01-12 01:04, Andreas F=E4rber wrote: >>>>>> Alex, >>>>>>=20 >>>>>> I have this in my mailbox, but I'm still waiting for an SoB. = Herv=E9? >>>>>>=20 >>>>>> Regards, >>>>>> Andreas >>>>>>=20 >>>>>> -------- Original-Nachricht -------- >>>>>> Betreff: [PATCH 1/5] i8259: qdev-ify creation >>>>>> Datum: Sun, 26 Jun 2011 14:47:09 +0200 >>>>>> Von: Herv=E9 Poussineau >>>>>> An: andreas.faerber@web.de >>>>>> Kopie (CC): Herv=E9 Poussineau >>>>>>=20 >>>>>> --- >>>>>> hw/i8259.c | 53 = +++++++++++++++++++++++++++++++++++++++++++++++++---- >>>>>> 1 files changed, 49 insertions(+), 4 deletions(-) >>>>>>=20 >>>>>> diff --git a/hw/i8259.c b/hw/i8259.c >>>>>> index 84d330d..59e8bd6 100644 >>>>>> --- a/hw/i8259.c >>>>>> +++ b/hw/i8259.c >>>>>> @@ -26,6 +26,7 @@ >>>>>> #include "isa.h" >>>>>> #include "monitor.h" >>>>>> #include "qemu-timer.h" >>>>>> +#include "sysbus.h" >>>>>>=20 >>>>>> /* debug PIC */ >>>>>> //#define DEBUG_PIC >>>>>> @@ -524,16 +525,60 @@ void irq_info(Monitor *mon) >>>>>>=20 >>>>>> qemu_irq *i8259_init(qemu_irq parent_irq) >>>>>> { >>>>>> - PicState2 *s; >>>>>> + DeviceState *dev; >>>>>> + dev =3D qdev_create(NULL, "i8259"); >>>>>> + qdev_init_nofail(dev); >>>>>> + qdev_connect_gpio_out(dev, 0, parent_irq); >>>>>> + >>>>>> + return dev->gpio_in; >>>>>> +} >>>>>> + >>>>>> +typedef struct SysBusPicState2 { >>>>>> + SysBusDevice busdev; >>>>>> + PicState2 state; >>>>>> +} SysBusPicState2; >>>>>> + >>>>>> +static void i8259_set_irq_sysbus(void *opaque, int line, int = level) >>>>>> +{ >>>>>> + SysBusPicState2 *sysbus =3D opaque; >>>>>> + PicState2 *s =3D &sysbus->state; >>>>>> + i8259_set_irq(s, line, level); >>>>>> +} >>>>>> + >>>>>> +static int i8259_sysbus_init(SysBusDevice *dev) >>>>>> +{ >>>>>> + SysBusPicState2 *sysbus =3D FROM_SYSBUS(SysBusPicState2, = dev); >>>>>> + PicState2 *s =3D &sysbus->state; >>>>>> + >>>>>> + if (isa_pic) { >>>>>> + return 1; >>>>>> + } >>>>>>=20 >>>>>> - s =3D qemu_mallocz(sizeof(PicState2)); >>>>>> pic_init1(0x20, 0x4d0, &s->pics[0]); >>>>>> pic_init1(0xa0, 0x4d1, &s->pics[1]); >>>>>> s->pics[0].elcr_mask =3D 0xf8; >>>>>> s->pics[1].elcr_mask =3D 0xde; >>>>>> - s->parent_irq =3D parent_irq; >>>>>> s->pics[0].pics_state =3D s; >>>>>> s->pics[1].pics_state =3D s; >>>>>> isa_pic =3D s; >>>>>> - return qemu_allocate_irqs(i8259_set_irq, s, 16); >>>>>> + >>>>>> + qdev_init_gpio_in(&dev->qdev, i8259_set_irq_sysbus, 16); >>>>>> + qdev_init_gpio_out(&dev->qdev, &s->parent_irq, 1); >>>>>> + return 0; >>>>>> +} >>>>>> + >>>>>> +static SysBusDeviceInfo i8259_sysbus_info =3D { >>>>>> + .qdev.name =3D "i8259", >>>>>> + .qdev.size =3D sizeof(SysBusPicState2), >>>>>> + .init =3D i8259_sysbus_init, >>>>>> + .qdev.props =3D (Property[]) { >>>>>> + DEFINE_PROP_END_OF_LIST() >>>>>> + }, >>>>>> +}; >>>>>> + >>>>>> +static void i8259_register_devices(void) >>>>>> +{ >>>>>> + sysbus_register_withprop(&i8259_sysbus_info); >>>>>> } >>>>>> + >>>>>> +device_init(i8259_register_devices) >>>>>=20 >>>>> This is obsolete. The i8259 has been significantly refactored = (into two >>>>> ISA devices) and qdev'ified some moons ago. >>>>=20 >>>> The reason we were discussing this was a circular dependency on = PREP. >>>>=20 >>>> The PIC is sitting on the ISA bus. >>>> The ISA bus is behind a PCI-ISA bridge >>>> the PCI-ISA bridge is behind a PCI host controller >>>> the PCI host controller needs interrupt lines in its initialization = which are attached to the PIC >>>>=20 >>>> Any good ideas on how to resolve this? :) >>>=20 >>> As we do this always: Split up initialization and IRQ line wiring. >>=20 >> Well, yes, the theory is obvious. How would this look like in = practice? To create a PIC device I need a bus: >>=20 >> dev =3D isa_create(bus, "isa-i8259"); >>=20 >> But to create the bus, I need an interrupt line, which I only get = after I created the PIC device. >=20 > ISA bus creation and IRQ assignment are split up IIRC. So you're saying we should do the same for PCI? To create an ISA bus that sits behind a PCI device I first need to = create a PCI bus which is exposed by the host bridge which then again = needs interrupt lines. I'm still puzzled how we would pass on irq lines then. I mean setting = them after init means that during init we can't instantiate other = devices that we can wire up to anything, right? Alex