From patchwork Wed Sep 28 11:01:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 116756 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 15F04B6F8A for ; Wed, 28 Sep 2011 21:08:31 +1000 (EST) Received: from localhost ([::1]:34192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8ru6-0007vO-Mc for incoming@patchwork.ozlabs.org; Wed, 28 Sep 2011 07:02:18 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8rtA-0004pb-6g for qemu-devel@nongnu.org; Wed, 28 Sep 2011 07:01:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8rt3-0004GP-UB for qemu-devel@nongnu.org; Wed, 28 Sep 2011 07:01:19 -0400 Received: from thoth.sbs.de ([192.35.17.2]:15763) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8rt3-0004FV-Aj for qemu-devel@nongnu.org; Wed, 28 Sep 2011 07:01:13 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id p8SB1BoU005516; Wed, 28 Sep 2011 13:01:11 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p8SB18W4017664; Wed, 28 Sep 2011 13:01:10 +0200 From: Jan Kiszka To: Anthony Liguori , qemu-devel Date: Wed, 28 Sep 2011 13:01:02 +0200 Message-Id: <2f0c57d93dbceda9fbf4000ab8421c46d9b71903.1317207666.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.2 Cc: Blue Swirl Subject: [Qemu-devel] [PATCH 16/22] i8259: Replace PicState::pics_state with master flag 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 This reflects how real PICs indentify their role (in non-buffered mode): Pass the state of the /SP input on pic_init and use it instead of pics_state to differentiate between master and slave mode. Signed-off-by: Jan Kiszka --- hw/i8259.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/i8259.c b/hw/i8259.c index bbb12cf..9a4f112 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -59,7 +59,7 @@ typedef struct PicState { uint8_t elcr; /* PIIX edge/trigger selection*/ uint8_t elcr_mask; qemu_irq int_out; - PicState2 *pics_state; + bool master; /* reflects /SP input pin */ MemoryRegion base_io; MemoryRegion elcr_io; } PicState; @@ -107,8 +107,9 @@ static int pic_get_irq(PicState *s) mask = s->isr; if (s->special_mask) mask &= ~s->imr; - if (s->special_fully_nested_mode && s == &s->pics_state->pics[0]) + if (s->special_fully_nested_mode && s->master) { mask &= ~(1 << 2); + } cur_priority = get_priority(s, mask); if (priority < cur_priority) { /* higher priority found: an irq should be generated */ @@ -126,8 +127,7 @@ static void pic_update_irq(PicState *s) irq = pic_get_irq(s); if (irq >= 0) { DPRINTF("pic%d: imr=%x irr=%x padd=%d\n", - s == &s->pics_state->pics[0] ? 0 : 1, s->imr, s->irr, - s->priority_add); + s->master ? 0 : 1, s->imr, s->irr, s->priority_add); qemu_irq_raise(s->int_out); } else { qemu_irq_lower(s->int_out); @@ -449,9 +449,11 @@ static const MemoryRegionOps pic_elcr_ioport_ops = { }; /* XXX: add generic master/slave system */ -static void pic_init(int io_addr, int elcr_addr, PicState *s, qemu_irq int_out) +static void pic_init(int io_addr, int elcr_addr, PicState *s, qemu_irq int_out, + bool master) { s->int_out = int_out; + s->master = master; memory_region_init_io(&s->base_io, &pic_base_ioport_ops, s, "pic", 2); memory_region_init_io(&s->elcr_io, &pic_elcr_ioport_ops, s, "elcr", 1); @@ -507,12 +509,10 @@ qemu_irq *i8259_init(qemu_irq parent_irq) s = g_malloc0(sizeof(PicState2)); irqs = qemu_allocate_irqs(i8259_set_irq, s, 16); - pic_init(0x20, 0x4d0, &s->pics[0], parent_irq); - pic_init(0xa0, 0x4d1, &s->pics[1], irqs[2]); + pic_init(0x20, 0x4d0, &s->pics[0], parent_irq, true); + pic_init(0xa0, 0x4d1, &s->pics[1], irqs[2], false); s->pics[0].elcr_mask = 0xf8; s->pics[1].elcr_mask = 0xde; - s->pics[0].pics_state = s; - s->pics[1].pics_state = s; isa_pic = s; return irqs; }