From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ME3Yp-0002KD-Lr for qemu-devel@nongnu.org; Tue, 09 Jun 2009 11:48:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ME3Yk-0002IN-3Z for qemu-devel@nongnu.org; Tue, 09 Jun 2009 11:48:26 -0400 Received: from [199.232.76.173] (port=46460 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ME3Yj-0002IK-Tj for qemu-devel@nongnu.org; Tue, 09 Jun 2009 11:48:21 -0400 Received: from mx2.redhat.com ([66.187.237.31]:42306) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ME3Yj-0004mW-Ca for qemu-devel@nongnu.org; Tue, 09 Jun 2009 11:48:21 -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 n59FmKOJ018656 for ; Tue, 9 Jun 2009 11:48:20 -0400 Date: Tue, 9 Jun 2009 18:48:18 +0300 From: Gleb Natapov Subject: Re: [Qemu-devel] [PATCHv2] Add rtc reset function. Message-ID: <20090609154818.GL5558@redhat.com> References: <20090609092605.GU27210@redhat.com> <20090609154533.GA9183@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090609154533.GA9183@amt.cnet> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: qemu-devel@nongnu.org On Tue, Jun 09, 2009 at 12:45:33PM -0300, Marcelo Tosatti wrote: > 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[]? I believe when this callback runs guest is already stopped, so there is not difference. -- Gleb.