From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ME43R-0005SO-1V for qemu-devel@nongnu.org; Tue, 09 Jun 2009 12:20:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ME43M-0005Om-5n for qemu-devel@nongnu.org; Tue, 09 Jun 2009 12:20:04 -0400 Received: from [199.232.76.173] (port=36520 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ME43M-0005Oe-0e for qemu-devel@nongnu.org; Tue, 09 Jun 2009 12:20:00 -0400 Received: from mx2.redhat.com ([66.187.237.31]:38102) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ME3Ws-0003kZ-45 for qemu-devel@nongnu.org; Tue, 09 Jun 2009 11:46:26 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n59FkFmH018231 for ; Tue, 9 Jun 2009 11:46:15 -0400 Date: Tue, 9 Jun 2009 12:45:33 -0300 From: Marcelo Tosatti Subject: Re: [Qemu-devel] [PATCHv2] Add rtc reset function. Message-ID: <20090609154533.GA9183@amt.cnet> References: <20090609092605.GU27210@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090609092605.GU27210@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org On Tue, Jun 09, 2009 at 12:26:05PM +0300, Gleb Natapov wrote: > On reset: > Periodic Interrupt Enable (PIE) bit is cleared to zero > Alarm Interrupt Enable (AIE) bit is cleared to zero > Update ended Interrupt Flag (UF) bit is cleared to zero > Interrupt Request status Flag (IRQF) bit is cleared to zero > Periodic Interrupt Flag (PF) bit is cleared to zero > Alarm Interrupt Flag (AF) bit is cleared to zero > Square Wave output Enable (SQWE) zero > > Signed-off-by: Gleb Natapov > diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c > index 888b85a..8c446e1 100644 > --- a/hw/mc146818rtc.c > +++ b/hw/mc146818rtc.c > @@ -57,6 +57,11 @@ > #define REG_B_SQWE 0x08 > #define REG_B_DM 0x04 > > +#define REG_C_UF 0x10 > +#define REG_C_IRQF 0x80 > +#define REG_C_PF 0x40 > +#define REG_C_AF 0x20 > + > struct RTCState { > uint8_t cmos_data[128]; > uint8_t cmos_index; > @@ -568,6 +573,21 @@ static int rtc_load_td(QEMUFile *f, void *opaque, int version_id) > } > #endif > > +static void rtc_reset(void *opaque) > +{ > + RTCState *s = opaque; > + > + s->cmos_data[RTC_REG_B] &= ~(REG_B_PIE | REG_B_AIE | REG_B_SQWE); > + s->cmos_data[RTC_REG_C] &= ~(REG_C_UF | REG_C_IRQF | REG_C_PF | REG_C_AF); > + > + qemu_irq_lower(s->irq); > + > +#ifdef TARGET_I386 > + if (rtc_td_hack) > + s->irq_coalesced = 0; > +#endif > +} Don't you need to cancel the timer before clearing cmos_data[]?