diff mbox

system_clock_scale unset in hw/intc/armv7m_nvic.c

Message ID CAF++6AOnuOzwiiPRJEGatzX7LuoJKU5ij2xWRLkKbxhytJscqA@mail.gmail.com
State New
Headers show

Commit Message

James Hanley Jan. 13, 2017, 12:35 p.m. UTC
How should system_clock_scale be set in hw/intc/armv7m_nvic.c - there is no
API for the global, and I've defaulted the global to SYSTICK_SCALE which
seems to work, but is not obvious.  This was needed as this value was set
to zero and the arm firmware was selecting the external clock source
causing zero to be returned from systick_scale() and the interrupt to run
continuously.

Comments

Peter Maydell Jan. 13, 2017, 12:43 p.m. UTC | #1
On 13 January 2017 at 12:35, James Hanley <jhanley@dgtlrift.com> wrote:
> How should system_clock_scale be set in hw/intc/armv7m_nvic.c - there is no
> API for the global, and I've defaulted the global to SYSTICK_SCALE which
> seems to work, but is not obvious.  This was needed as this value was set to
> zero and the arm firmware was selecting the external clock source causing
> zero to be returned from systick_scale() and the interrupt to run
> continuously.

If I recall correctly, this is an external-to-the-CPU thing
(wired up by the SoC or the board), which suggests that it
ought to be a property on the CPU object (or perhaps on a
currently-nonexistent container object which has the CPU
and the NVIC and the other M profile devices).

As the code stands today, I think the answer is that the
board has to set the global -- this is what stellaris.c does.

thanks
-- PMM
diff mbox

Patch

diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 06d8db6..c15841e 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -70,7 +70,7 @@  static const uint8_t nvic_id[] = {
 #define SYSTICK_CLKSOURCE (1 << 2)
 #define SYSTICK_COUNTFLAG (1 << 16)

-int system_clock_scale;
+int system_clock_scale = SYSTICK_SCALE;

 /* Conversion factor from qemu timer to SysTick frequencies.  */
 static inline int64_t systick_scale(nvic_state *s)