qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] mc146818rtc: Make PF independent of PIE


From: Jason Thorpe
Subject: [PATCH v2] mc146818rtc: Make PF independent of PIE
Date: Sat, 19 Jun 2021 12:38:49 -0700

Make the PF flag behave like real hardware by always running the
periodic timer without regard to the setting of the PIE bit, so
that the PF will be set when the period expires even if an interrupt
will not be raised.  This behavior is documented on page 16 of the
MC146818A advance information datasheet.

Signed-off-by: Jason Thorpe <thorpej@me.com>
---
 hw/rtc/mc146818rtc.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index 4fbafddb22..85abdfd9d1 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -155,9 +155,24 @@ static uint32_t rtc_periodic_clock_ticks(RTCState *s)
 {
     int period_code;
 
-    if (!(s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
-        return 0;
-     }
+    /*
+     * Quoting the data sheet "MC146818A Advance Information", 1984,
+     * page 16:
+     *
+     * <quote>
+     * PF - The periodic interrupt flag (PF) is a read-only bit which is
+     * set to a "1" when a particular edge is detected on the selected tap
+     * of the divider chain.  The RS3 to RS0 bits establish the periodic
+     * rate.  PF is set to "1" independent of the state of the PIE bit.
+     * PF initiates an ~IRQ signal and sets the IRQF bit when PIE is also
+     * a "1".  The PF bit is cleared by a ~RESET or a software read of
+     * Register C.
+     * </quote>
+     *
+     * As such, we always run the timer irrespective if the state of
+     * either bit so as to always set PF at regular intervals regardless
+     * of when software reads it.
+     */
 
     period_code = s->cmos_data[RTC_REG_A] & 0x0f;
 
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]