From patchwork Thu Jan 12 00:04:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 135535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E73FFB6F65 for ; Thu, 12 Jan 2012 11:06:07 +1100 (EST) Received: from localhost ([::1]:41607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rl8BB-0008UE-Lg for incoming@patchwork.ozlabs.org; Wed, 11 Jan 2012 19:06:05 -0500 Received: from eggs.gnu.org ([140.186.70.92]:45843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rl8B5-0008U7-6P for qemu-devel@nongnu.org; Wed, 11 Jan 2012 19:06:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rl8B3-00032H-TP for qemu-devel@nongnu.org; Wed, 11 Jan 2012 19:05:59 -0500 Received: from mout.web.de ([212.227.15.4]:49340) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rl8B3-00032D-II for qemu-devel@nongnu.org; Wed, 11 Jan 2012 19:05:57 -0500 Received: from envy.site ([84.148.30.46]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0MWRkA-1SDEkF0GkM-00Xfh4; Thu, 12 Jan 2012 01:05:45 +0100 Message-ID: <4F0E2371.2010105@web.de> Date: Thu, 12 Jan 2012 01:04:01 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: Alexander Graf , =?ISO-8859-15?Q?Herv=E9_Poussineau?= References: <1309092433-4385-2-git-send-email-hpoussin@reactos.org> In-Reply-To: <1309092433-4385-2-git-send-email-hpoussin@reactos.org> X-Forwarded-Message-Id: <1309092433-4385-2-git-send-email-hpoussin@reactos.org> X-Provags-ID: V02:K0:qSoaAhN5Wn7lopPCeWnJKZoAyPDiCPLvVL32DLkFtp7 BqDJnjVu3cd0Xg7uCSt2zfHdQUmfm/ZzwMK2MiuYmmaOdek8P5 oSvO+L+b/e4/2pAFXcewCYDlOQljWEz8k3KZk9YZE0s7idIkjO Mi99k1bLKHm701gRkU838bMmehqMLO2YHiJXW5EriISAXWn1d4 eZ5DnWvDY0dIzxuiOKftA== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.15.4 Cc: qemu-devel Developers Subject: [Qemu-devel] Fwd: [PATCH 1/5] i8259: qdev-ify creation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Alex, I have this in my mailbox, but I'm still waiting for an SoB. Hervé? Regards, Andreas -------- Original-Nachricht -------- Betreff: [PATCH 1/5] i8259: qdev-ify creation Datum: Sun, 26 Jun 2011 14:47:09 +0200 Von: Hervé Poussineau An: andreas.faerber@web.de Kopie (CC): Hervé Poussineau --- hw/i8259.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 49 insertions(+), 4 deletions(-) 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" /* debug PIC */ //#define DEBUG_PIC @@ -524,16 +525,60 @@ void irq_info(Monitor *mon) qemu_irq *i8259_init(qemu_irq parent_irq) { - PicState2 *s; + DeviceState *dev; + dev = 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 = opaque; + PicState2 *s = &sysbus->state; + i8259_set_irq(s, line, level); +} + +static int i8259_sysbus_init(SysBusDevice *dev) +{ + SysBusPicState2 *sysbus = FROM_SYSBUS(SysBusPicState2, dev); + PicState2 *s = &sysbus->state; + + if (isa_pic) { + return 1; + } - s = qemu_mallocz(sizeof(PicState2)); pic_init1(0x20, 0x4d0, &s->pics[0]); pic_init1(0xa0, 0x4d1, &s->pics[1]); s->pics[0].elcr_mask = 0xf8; s->pics[1].elcr_mask = 0xde; - s->parent_irq = parent_irq; s->pics[0].pics_state = s; s->pics[1].pics_state = s; isa_pic = 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 = { + .qdev.name = "i8259", + .qdev.size = sizeof(SysBusPicState2), + .init = i8259_sysbus_init, + .qdev.props = (Property[]) { + DEFINE_PROP_END_OF_LIST() + }, +}; + +static void i8259_register_devices(void) +{ + sysbus_register_withprop(&i8259_sysbus_info); } + +device_init(i8259_register_devices)