[Top][All Lists]

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

[Qemu-trivial] [PATCH] hw/timer/armv7m_systick: Fix default system_clock

From: Domen Puncer Kugler
Subject: [Qemu-trivial] [PATCH] hw/timer/armv7m_systick: Fix default system_clock_scale. Resolves SIGFPE divide by zero.
Date: Wed, 1 Nov 2017 20:59:49 +0000

Fix default system_clock_scale. Resolves SIGFPE divide by zero.

Netduino platform code does not provide a way to set
system_clock_scale, so it remains 0.
This causes a divide by zero, when emulated code asks systick for
current timer value:
    (s->tick - (t + 1)) / systick_scale(s)) + 1;
Patch fixes this by providing a default value.

Also replaces a magic number an with already defined constant:
    #define SYSTICK_SCALE 1000ULL

Signed-off-by: Domen Puncer Kugler <address@hidden>

diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c
index df8d2804b3..651f8030a8 100644
--- a/hw/timer/armv7m_systick.c
+++ b/hw/timer/armv7m_systick.c
@@ -25,15 +25,15 @@
 #define SYSTICK_CLKSOURCE (1 << 2)
 #define SYSTICK_COUNTFLAG (1 << 16)

-int system_clock_scale;
+uint64_t system_clock_scale = SYSTICK_SCALE;

 /* Conversion factor from qemu timer to SysTick frequencies.  */
-static inline int64_t systick_scale(SysTickState *s)
+static inline uint64_t systick_scale(SysTickState *s)
     if (s->control & SYSTICK_CLKSOURCE) {
         return system_clock_scale;
     } else {
-        return 1000;
+        return SYSTICK_SCALE;

reply via email to

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