From patchwork Thu Aug 2 16:04:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 174787 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 1971D2C007B for ; Fri, 3 Aug 2012 02:52:05 +1000 (EST) Received: from localhost ([::1]:36093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Swxtn-0005O3-F3 for incoming@patchwork.ozlabs.org; Thu, 02 Aug 2012 12:05:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwxtA-0003t5-4H for qemu-devel@nongnu.org; Thu, 02 Aug 2012 12:04:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Swxt9-0001wB-5f for qemu-devel@nongnu.org; Thu, 02 Aug 2012 12:04:40 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:55152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Swxt8-0001w2-V0 for qemu-devel@nongnu.org; Thu, 02 Aug 2012 12:04:39 -0400 Received: by wgbfm10 with SMTP id fm10so6532293wgb.10 for ; Thu, 02 Aug 2012 09:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=MZGs1aUXkYyJYGXuC5z9jhp4Sg9IIMCjLBdDklEBaeo=; b=Jk8MAbb/fxNL+MPMrFPrjaRASCR42wwZG6GeE2Yu5EdtwYvomMA6eI11YjhyfMokLs ukwwK0qVAB4Pk8dYAF6cg1V444RezDarBgvCyoAc0Kx+IefTtCuvpe7JKVEgMmVShVlN mfIwSOuRQge5U/CahB1uXy6fZkta39su9Plc/t8CG+bLC7Z2zxou5sJ8COSvUHWFvuoe 8tlLshHAzeo2jQxgzeApaui+uR5l/s17WM+H+j4J5EV0JNUXP9nCVPU3q9toXthw0Azy QdOY+mXbiplaAQ1/kTZsfoJE52ul1LZZIKghW2P0OmnryHVJMFsFk+1coQcNlAGb8VOH ZBOg== Received: by 10.50.159.135 with SMTP id xc7mr4726099igb.1.1343923477438; Thu, 02 Aug 2012 09:04:37 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id wm7sm13332071igb.6.2012.08.02.09.04.34 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Aug 2012 09:04:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 2 Aug 2012 18:04:07 +0200 Message-Id: <1343923453-13026-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343923453-13026-1-git-send-email-pbonzini@redhat.com> References: <1343923453-13026-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.53 Cc: yang.z.zhang@intel.com, aliguori@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH v3 04/10] RTC: Update interrupt state when interrupts are masked/unmasked 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 From: Yang Zhang If an interrupt flag is already set when the interrupt becomes enabled, raise an interrupt immediately, and vice versa if interrupts become disabled. Signed-off-by: Yang Zhang Signed-off-by: Paolo Bonzini --- hw/mc146818rtc.c | 9 +++++++++ hw/mc146818rtc_regs.h | 1 + 2 files changed, 10 insertions(+) diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 175ddac..b41eb4b 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -221,6 +221,15 @@ static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data) rtc_set_time(s); } } + /* if an interrupt flag is already set when the interrupt + * becomes enabled, raise an interrupt immediately. */ + if (data & s->cmos_data[RTC_REG_C] & REG_C_MASK) { + s->cmos_data[RTC_REG_C] |= REG_C_IRQF; + qemu_irq_raise(s->irq); + } else { + s->cmos_data[RTC_REG_C] &= ~REG_C_IRQF; + qemu_irq_lower(s->irq); + } s->cmos_data[RTC_REG_B] = data; periodic_timer_update(s, qemu_get_clock_ns(rtc_clock)); break; diff --git a/hw/mc146818rtc_regs.h b/hw/mc146818rtc_regs.h index 3ab3770..fc10076 100644 --- a/hw/mc146818rtc_regs.h +++ b/hw/mc146818rtc_regs.h @@ -58,5 +58,6 @@ #define REG_C_IRQF 0x80 #define REG_C_PF 0x40 #define REG_C_AF 0x20 +#define REG_C_MASK 0x70 #endif