From patchwork Mon Oct 1 04:56:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ogilvie X-Patchwork-Id: 188220 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 4FC322C00E3 for ; Mon, 1 Oct 2012 15:38:39 +1000 (EST) Received: from localhost ([::1]:45832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIYAW-0000pq-UX for incoming@patchwork.ozlabs.org; Mon, 01 Oct 2012 01:03:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIY9I-0006e4-0N for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TIY9H-0007gs-46 for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:31 -0400 Received: from qmta07.emeryville.ca.mail.comcast.net ([76.96.30.64]:55605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIY9G-0007gj-Ui for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:31 -0400 Received: from omta19.emeryville.ca.mail.comcast.net ([76.96.30.76]) by qmta07.emeryville.ca.mail.comcast.net with comcast id 5gxn1k0051eYJf8A7h2Wj0; Mon, 01 Oct 2012 05:02:30 +0000 Received: from mmogilvi.homeip.net ([24.9.53.136]) by omta19.emeryville.ca.mail.comcast.net with comcast id 5gxV1k00J2wKXRC01gxWoK; Mon, 01 Oct 2012 04:57:30 +0000 Received: by mmogilvi.homeip.net (Postfix, from userid 501) id 765BF1E9601B; Sun, 30 Sep 2012 22:57:29 -0600 (MDT) From: Matthew Ogilvie To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2012 22:56:37 -0600 Message-Id: <1349067398-9578-8-git-send-email-mmogilvi_qemu@miniinfo.net> X-Mailer: git-send-email 1.7.10.2.484.gcd07cc5 In-Reply-To: <1349067398-9578-1-git-send-email-mmogilvi_qemu@miniinfo.net> References: <1349067398-9578-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.64 Cc: Paolo Bonzini , Jan Kiszka , Matthew Ogilvie , "Maciej W. Rozycki" , Avi Kivity Subject: [Qemu-devel] [PATCH v6 7/8] 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); }