qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH v8 08/18] i8259: Completely privatize PicState
Date: Thu, 19 Jan 2012 12:25:00 +0100	[thread overview]
Message-ID: <9aa78c425f6cd6a57ec53dd1a76233a080dc83b6.1326972302.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1326972302.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1326972302.git.jan.kiszka@siemens.com>

Use DeviceState instead of PicState in the public i8259 API. This is
cleaner and allows to reorganize the PIC data structures for KVM reuse.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/i8259.c |   17 +++++++++++------
 hw/pc.h    |    7 +++----
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/hw/i8259.c b/hw/i8259.c
index 7331e0e..cfaa35c 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -40,6 +40,8 @@
 //#define DEBUG_IRQ_LATENCY
 //#define DEBUG_IRQ_COUNT
 
+typedef struct PicState PicState;
+
 struct PicState {
     ISADevice dev;
     uint8_t last_irr; /* edge detection */
@@ -76,7 +78,7 @@ static uint64_t irq_count[16];
 #ifdef DEBUG_IRQ_LATENCY
 static int64_t irq_time[16];
 #endif
-PicState *isa_pic;
+DeviceState *isa_pic;
 static PicState *slave_pic;
 
 /* return the highest priority found in mask (highest = smallest
@@ -206,8 +208,9 @@ static void pic_intack(PicState *s, int irq)
     pic_update_irq(s);
 }
 
-int pic_read_irq(PicState *s)
+int pic_read_irq(DeviceState *d)
 {
+    PicState *s = DO_UPCAST(PicState, dev.qdev, d);
     int irq, irq2, intno;
 
     irq = pic_get_irq(s);
@@ -269,7 +272,7 @@ static void pic_init_reset(PicState *s)
 
 static void pic_reset(DeviceState *dev)
 {
-    PicState *s = container_of(dev, PicState, dev.qdev);
+    PicState *s = DO_UPCAST(PicState, dev.qdev, dev);
 
     pic_init_reset(s);
     s->elcr = 0;
@@ -399,8 +402,10 @@ static uint64_t pic_ioport_read(void *opaque, target_phys_addr_t addr,
     return ret;
 }
 
-int pic_get_output(PicState *s)
+int pic_get_output(DeviceState *d)
 {
+    PicState *s = DO_UPCAST(PicState, dev.qdev, d);
+
     return (pic_get_irq(s) >= 0);
 }
 
@@ -491,7 +496,7 @@ void pic_info(Monitor *mon)
         return;
     }
     for (i = 0; i < 2; i++) {
-        s = i == 0 ? isa_pic : slave_pic;
+        s = i == 0 ? DO_UPCAST(PicState, dev.qdev, isa_pic) : slave_pic;
         monitor_printf(mon, "pic%d: irr=%02x imr=%02x isr=%02x hprio=%d "
                        "irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n",
                        i, s->irr, s->imr, s->isr, s->priority_add,
@@ -538,7 +543,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
         irq_set[i] = qdev_get_gpio_in(&dev->qdev, i);
     }
 
-    isa_pic = DO_UPCAST(PicState, dev, dev);
+    isa_pic = &dev->qdev;
 
     dev = isa_create(bus, "isa-i8259");
     qdev_prop_set_uint32(&dev->qdev, "iobase", 0xa0);
diff --git a/hw/pc.h b/hw/pc.h
index 13e41f1..ece069a 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -62,11 +62,10 @@ bool parallel_mm_init(MemoryRegion *address_space,
 
 /* i8259.c */
 
-typedef struct PicState PicState;
-extern PicState *isa_pic;
+extern DeviceState *isa_pic;
 qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);
-int pic_read_irq(PicState *s);
-int pic_get_output(PicState *s);
+int pic_read_irq(DeviceState *d);
+int pic_get_output(DeviceState *d);
 void pic_info(Monitor *mon);
 void irq_info(Monitor *mon);
 
-- 
1.7.3.4

  parent reply	other threads:[~2012-01-19 11:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-19 11:24 [Qemu-devel] [PATCH v8 00/18] uq/master: Introduce basic irqchip support Jan Kiszka
2012-01-19 11:24 ` [Qemu-devel] [PATCH v8 01/18] msi: Generalize msix_supported to msi_supported Jan Kiszka
2012-01-19 11:24 ` [Qemu-devel] [PATCH v8 02/18] kvm: Move kvmclock into hw/kvm folder Jan Kiszka
2012-01-19 11:24 ` [Qemu-devel] [PATCH v8 03/18] apic: Stop timer on reset Jan Kiszka
2012-01-19 11:24 ` [Qemu-devel] [PATCH v8 04/18] apic: Inject external NMI events via LINT1 Jan Kiszka
2012-01-19 11:24 ` [Qemu-devel] [PATCH v8 05/18] apic: Introduce apic_report_irq_delivered Jan Kiszka
2012-01-19 11:24 ` [Qemu-devel] [PATCH v8 06/18] apic: Factor out base class for KVM reuse Jan Kiszka
2012-01-19 11:24 ` [Qemu-devel] [PATCH v8 07/18] apic: Open-code timer save/restore Jan Kiszka
2012-01-19 11:25 ` Jan Kiszka [this message]
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 09/18] i8259: Factor out base class for KVM reuse Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 10/18] ioapic: Drop post-load irr initialization Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 11/18] ioapic: Factor out base class for KVM reuse Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 12/18] memory: Introduce memory_region_init_reservation Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 13/18] kvm: Introduce core services for in-kernel irqchip support Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 14/18] kvm: x86: Establish IRQ0 override control Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 15/18] kvm: x86: Add user space part for in-kernel APIC Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 16/18] kvm: x86: Add user space part for in-kernel i8259 Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 17/18] kvm: x86: Add user space part for in-kernel IOAPIC Jan Kiszka
2012-01-19 11:25 ` [Qemu-devel] [PATCH v8 18/18] kvm: Activate in-kernel irqchip support Jan Kiszka
2012-01-19 18:08   ` Marcelo Tosatti
2012-01-19 18:54     ` Jan Kiszka
2012-01-24 14:05       ` Avi Kivity
2012-01-24 14:10         ` Jan Kiszka
2012-01-24 14:13           ` Avi Kivity
2012-01-24 15:34             ` Anthony Liguori
2012-01-24 15:33         ` Anthony Liguori

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=9aa78c425f6cd6a57ec53dd1a76233a080dc83b6.1326972302.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@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).