From patchwork Mon Jan 16 15:55:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 136294 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 87F7D1007D1 for ; Tue, 17 Jan 2012 03:20:04 +1100 (EST) Received: from localhost ([::1]:48131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmovU-0002Ol-GU for incoming@patchwork.ozlabs.org; Mon, 16 Jan 2012 10:56:52 -0500 Received: from eggs.gnu.org ([140.186.70.92]:54710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmouv-0000bt-Tp for qemu-devel@nongnu.org; Mon, 16 Jan 2012 10:56:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rmouh-0002mH-1B for qemu-devel@nongnu.org; Mon, 16 Jan 2012 10:56:17 -0500 Received: from david.siemens.de ([192.35.17.14]:17419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmoug-0002k1-JB for qemu-devel@nongnu.org; Mon, 16 Jan 2012 10:56:02 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id q0GFtseY026128; Mon, 16 Jan 2012 16:55:54 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q0GFtql0023489; Mon, 16 Jan 2012 16:55:54 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Mon, 16 Jan 2012 16:55:42 +0100 Message-Id: <85bf914d2a2968be3873dcda86fcf104c4b322a7.1326729350.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.14 Cc: Blue Swirl , Anthony Liguori , qemu-devel , kvm@vger.kernel.org, "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v7 08/18] i8259: Completely privatize PicState 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 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 --- 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);