From patchwork Mon Sep 10 01:27:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ogilvie X-Patchwork-Id: 182778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 15B352C008E for ; Mon, 10 Sep 2012 11:49:59 +1000 (EST) Received: from localhost ([::1]:32821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAsou-0006Ao-Dj for incoming@patchwork.ozlabs.org; Sun, 09 Sep 2012 21:29:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAsoL-0004Q8-Ni for qemu-devel@nongnu.org; Sun, 09 Sep 2012 21:29:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TAsoK-0003Ca-1c for qemu-devel@nongnu.org; Sun, 09 Sep 2012 21:29:13 -0400 Received: from qmta01.emeryville.ca.mail.comcast.net ([76.96.30.16]:51301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAsoJ-0003CO-Rr for qemu-devel@nongnu.org; Sun, 09 Sep 2012 21:29:11 -0400 Received: from omta19.emeryville.ca.mail.comcast.net ([76.96.30.76]) by qmta01.emeryville.ca.mail.comcast.net with comcast id xC8n1j0051eYJf8A1DVBpk; Mon, 10 Sep 2012 01:29:11 +0000 Received: from mmogilvi.homeip.net ([24.9.53.136]) by omta19.emeryville.ca.mail.comcast.net with comcast id xDV91j00P2wKXRC01DVAKE; Mon, 10 Sep 2012 01:29:10 +0000 Received: by mmogilvi.homeip.net (Postfix, from userid 501) id 68E7F1E9601C; Sun, 9 Sep 2012 19:29:09 -0600 (MDT) From: Matthew Ogilvie To: qemu-devel@nongnu.org Date: Sun, 9 Sep 2012 19:27:46 -0600 Message-Id: <1347240466-6152-7-git-send-email-mmogilvi_qemu@miniinfo.net> X-Mailer: git-send-email 1.7.10.2.484.gcd07cc5 In-Reply-To: <1347240466-6152-1-git-send-email-mmogilvi_qemu@miniinfo.net> References: <1347240466-6152-1-git-send-email-mmogilvi_qemu@miniinfo.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.96.30.16 Cc: Paolo Bonzini , Jan Kiszka , Matthew Ogilvie , "Maciej W. Rozycki" Subject: [Qemu-devel] [PATCH v5 6/6] i8259: refactor pic_set_irq level logic 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 No change in functionality. Clarify that the only difference between level triggered and edge triggered interrupts is on the leading edge. Signed-off-by: Matthew Ogilvie --- hw/i8259.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/hw/i8259.c b/hw/i8259.c index c011787..1ba9b3a 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -140,26 +140,18 @@ static void pic_set_irq(void *opaque, int irq, int level) } #endif - if (s->elcr & mask) { - /* level triggered */ - if (level) { + if (level) { + if ((s->last_irr & mask) == 0 || /* edge for edge triggered */ + (s->elcr & mask)) { /* or level triggered */ s->irr |= mask; - s->last_irr |= mask; - } else { - s->irr &= ~mask; - s->last_irr &= ~mask; } + s->last_irr |= mask; } else { - /* edge triggered */ - if (level) { - if ((s->last_irr & mask) == 0) { - s->irr |= mask; - } - s->last_irr |= mask; - } else { - s->irr &= ~mask; - s->last_irr &= ~mask; - } + /* Dropping level clears the interrupt regardless of edge trigger + * vs level trigger. + */ + s->irr &= ~mask; + s->last_irr &= ~mask; } pic_update_irq(s); }