From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=35269 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OODgU-0006uO-VD for qemu-devel@nongnu.org; Mon, 14 Jun 2010 13:42:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OODfS-0006b6-Ub for qemu-devel@nongnu.org; Mon, 14 Jun 2010 13:41:51 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:39899) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OODfS-0006al-QH for qemu-devel@nongnu.org; Mon, 14 Jun 2010 13:41:50 -0400 Received: by pwj8 with SMTP id 8so3048374pwj.4 for ; Mon, 14 Jun 2010 10:41:49 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Blue Swirl Date: Mon, 14 Jun 2010 17:41:28 +0000 Message-ID: Subject: Re: [Qemu-devel] [PATCH v2 2/7] ioapic: convert to qdev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel On Mon, Jun 14, 2010 at 9:33 AM, Markus Armbruster wrot= e: > Blue Swirl writes: > >> Convert to qdev. >> >> Signed-off-by: Blue Swirl >> --- >> =C2=A0hw/apic.h =C2=A0 =C2=A0| =C2=A0 =C2=A02 -- >> =C2=A0hw/ioapic.c =C2=A0| =C2=A0 45 ++++++++++++++++++++++++++++++------= --------- >> =C2=A0hw/pc.h =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A04 +++- >> =C2=A0hw/pc_piix.c | =C2=A0 19 ++++++++++++++++++- >> =C2=A04 files changed, 51 insertions(+), 19 deletions(-) >> >> diff --git a/hw/apic.h b/hw/apic.h >> index e1954f4..dc41400 100644 >> --- a/hw/apic.h >> +++ b/hw/apic.h >> @@ -1,7 +1,6 @@ >> =C2=A0#ifndef APIC_H >> =C2=A0#define APIC_H >> >> -typedef struct IOAPICState IOAPICState; >> =C2=A0void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint8_t delivery_mode, >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint8_t vector_num, uint8_t polarity, >> @@ -10,7 +9,6 @@ int apic_init(CPUState *env); >> =C2=A0int apic_accept_pic_intr(CPUState *env); >> =C2=A0void apic_deliver_pic_intr(CPUState *env, int level); >> =C2=A0int apic_get_interrupt(CPUState *env); >> -qemu_irq *ioapic_init(void); >> =C2=A0void apic_reset_irq_delivered(void); >> =C2=A0int apic_get_irq_delivered(void); >> >> diff --git a/hw/ioapic.c b/hw/ioapic.c >> index e3f8a46..0336dbd 100644 >> --- a/hw/ioapic.c >> +++ b/hw/ioapic.c >> @@ -25,6 +25,7 @@ >> =C2=A0#include "apic.h" >> =C2=A0#include "qemu-timer.h" >> =C2=A0#include "host-utils.h" >> +#include "sysbus.h" >> >> =C2=A0//#define DEBUG_IOAPIC >> >> @@ -35,7 +36,6 @@ >> =C2=A0#define DPRINTF(fmt, ...) >> =C2=A0#endif >> >> -#define IOAPIC_NUM_PINS =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x18 >> =C2=A0#define IOAPIC_LVT_MASKED =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(1<<16) >> >> =C2=A0#define IOAPIC_TRIGGER_EDGE =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00 >> @@ -50,7 +50,10 @@ >> =C2=A0#define IOAPIC_DM_SIPI =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0x5 >> =C2=A0#define IOAPIC_DM_EXTINT =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= 0x7 >> >> +typedef struct IOAPICState IOAPICState; >> + >> =C2=A0struct IOAPICState { >> + =C2=A0 =C2=A0SysBusDevice busdev; >> =C2=A0 =C2=A0 =C2=A0uint8_t id; >> =C2=A0 =C2=A0 =C2=A0uint8_t ioregsel; >> >> @@ -209,12 +212,14 @@ static const VMStateDescription vmstate_ioapic =3D= { >> =C2=A0 =C2=A0 =C2=A0} >> =C2=A0}; >> >> -static void ioapic_reset(void *opaque) >> +static void ioapic_reset(DeviceState *d) >> =C2=A0{ >> - =C2=A0 =C2=A0IOAPICState *s =3D opaque; >> + =C2=A0 =C2=A0IOAPICState *s =3D container_of(d, IOAPICState, busdev.qd= ev); > > DO_UPCAST()? =C2=A0I hate it, but it's what the other devices do... Both are used: grep container_of hw/*.[ch]|wc -l 81 grep DO_UPCAST hw/*.[ch]|wc -l 246