qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/3] qdev-ify isa pic
Date: Tue,  9 Jun 2009 13:00:59 +0200	[thread overview]
Message-ID: <1244545261-23679-1-git-send-email-kraxel@redhat.com> (raw)


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/i8259.c |   32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/hw/i8259.c b/hw/i8259.c
index 40f8bee..6c8b5c5 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -25,6 +25,7 @@
 #include "pc.h"
 #include "isa.h"
 #include "monitor.h"
+#include "sysbus.h"
 
 /* debug PIC */
 //#define DEBUG_PIC
@@ -54,6 +55,7 @@ typedef struct PicState {
 } PicState;
 
 struct PicState2 {
+    SysBusDevice busdev;
     /* 0 is master pic, 1 is slave pic */
     /* XXX: better separation between the two pics */
     PicState pics[2];
@@ -182,7 +184,8 @@ int64_t irq_time[16];
 
 static void i8259_set_irq(void *opaque, int irq, int level)
 {
-    PicState2 *s = opaque;
+    DeviceState *dev = opaque;
+    PicState2 *s = FROM_SYSBUS(PicState2, sysbus_from_qdev(dev));
 
 #if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT)
     if (level != irq_level[irq]) {
@@ -546,20 +549,37 @@ void irq_info(Monitor *mon)
 #endif
 }
 
-qemu_irq *i8259_init(qemu_irq parent_irq)
+static void i8259_initfn(SysBusDevice *sysdev)
 {
     PicState2 *s;
 
-    s = qemu_mallocz(sizeof(PicState2));
+    s = FROM_SYSBUS(PicState2, sysdev);
     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_out(&sysdev->qdev, &s->parent_irq, 1);
+    qdev_init_gpio_in(&sysdev->qdev, i8259_set_irq, 16);
+}
+
+static void i8259_register(void)
+{
+    sysbus_register_dev("i8259", sizeof(PicState2), i8259_initfn);
+}
+device_init(i8259_register);
+
+qemu_irq *i8259_init(qemu_irq parent_irq)
+{
+    DeviceState *dev;
+
+    dev = qdev_create(NULL, "i8259");
+    qdev_init(dev);
+
+    isa_pic = FROM_SYSBUS(PicState2, sysbus_from_qdev(dev));
+    qdev_connect_gpio_out(dev, 0, parent_irq);
+    return dev->gpio_in;
 }
 
 void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,
-- 
1.6.2.2

             reply	other threads:[~2009-06-09 11:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-09 11:00 Gerd Hoffmann [this message]
2009-06-09 11:01 ` [Qemu-devel] [PATCH 2/3] qdev: irq allocation in generic code Gerd Hoffmann
2009-06-09 11:01 ` [Qemu-devel] [PATCH 3/3] qdev: switch isa pic to generic irq allocation Gerd Hoffmann
2009-06-09 15:01 ` [Qemu-devel] [PATCH 1/3] qdev-ify isa pic Paul Brook
2009-06-09 15:24   ` Gerd Hoffmann
2009-06-09 15:32     ` Paul Brook
2009-06-09 15:51       ` Gerd Hoffmann
2009-06-09 15:58         ` Paul Brook
2009-06-10  7:32           ` Gerd Hoffmann
2009-06-10  9:43             ` Filip Navara
2009-06-10  9:50               ` Gerd Hoffmann
2009-06-10 14:29                 ` Paul Brook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1244545261-23679-1-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).