Adds a new external reference clock scale variable to complement the existing system_clock_scale variable. Previously, the value was hardcoded to 1000 when calculating the SysTick scale. The new variable defaults to 1000 to maintain backward compatibility.
Signed-off-by: Andre Beckus <mikemail98-q...@yahoo.com> --- hw/arm-misc.h | 4 ++++ hw/armv7m_nvic.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/arm-misc.h b/hw/arm-misc.h index bdd8fec..32b19df 100644 --- a/hw/arm-misc.h +++ b/hw/arm-misc.h @@ -65,4 +65,8 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); ticks. */ extern int system_clock_scale; +/* Multiplication factor to convert from external reference clock ticks to + * qemu timer ticks. */ +extern int external_ref_clock_scale; + #endif /* !ARM_MISC_H */ diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c index 10b5954..4eaa113 100644 --- a/hw/armv7m_nvic.c +++ b/hw/armv7m_nvic.c @@ -65,6 +65,7 @@ static const uint8_t nvic_id[] = { #define SYSTICK_COUNTFLAG (1 << 16) int system_clock_scale; +int external_ref_clock_scale = 1000; /* Conversion factor from qemu timer to SysTick frequencies. */ static inline int64_t systick_scale(nvic_state *s) @@ -72,7 +73,7 @@ static inline int64_t systick_scale(nvic_state *s) if (s->systick.control & SYSTICK_CLKSOURCE) return system_clock_scale; else - return 1000; + return external_ref_clock_scale; } static void systick_reload(nvic_state *s, int reset) -- 1.7.9.5