From d9073a18488acc3206e39ea075762820aa21c51b Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 24 Aug 2017 13:36:24 +0200 Subject: [PATCH] timer/util: generic TIMER_MIN_TICKS_PER_MS Ref #2400 --- repos/base-hw/src/core/spec/cortex_a9/timer.cc | 3 ++- repos/base-hw/src/core/spec/x86_64/timer.cc | 2 +- repos/base/include/drivers/timer/util.h | 7 +++++-- repos/os/src/drivers/timer/pit/time_source.cc | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/repos/base-hw/src/core/spec/cortex_a9/timer.cc b/repos/base-hw/src/core/spec/cortex_a9/timer.cc index 8cae627e7..f211748a5 100644 --- a/repos/base-hw/src/core/spec/cortex_a9/timer.cc +++ b/repos/base-hw/src/core/spec/cortex_a9/timer.cc @@ -26,7 +26,8 @@ using namespace Kernel; Timer_driver::Timer_driver(unsigned) : Mmio(Platform::mmio_to_virt(Board::Cpu_mmio::PRIVATE_TIMER_MMIO_BASE)) { - static_assert(TICS_PER_MS >= 1000, "Bad TICS_PER_MS value"); + static_assert(TICS_PER_MS >= (unsigned)TIMER_MIN_TICKS_PER_MS, + "Bad TICS_PER_MS value"); write(0); } diff --git a/repos/base-hw/src/core/spec/x86_64/timer.cc b/repos/base-hw/src/core/spec/x86_64/timer.cc index 95b9e98b4..b75b25b5c 100644 --- a/repos/base-hw/src/core/spec/x86_64/timer.cc +++ b/repos/base-hw/src/core/spec/x86_64/timer.cc @@ -67,7 +67,7 @@ Timer_driver::Timer_driver(unsigned) /* Calculate timer frequency */ ticks_per_ms = pit_calc_timer_freq(); - assert(ticks_per_ms >= 1000); + assert(ticks_per_ms >= TIMER_MIN_TICKS_PER_MS); } diff --git a/repos/base/include/drivers/timer/util.h b/repos/base/include/drivers/timer/util.h index b20b620ca..25ee3f8e8 100644 --- a/repos/base/include/drivers/timer/util.h +++ b/repos/base/include/drivers/timer/util.h @@ -16,6 +16,8 @@ namespace Genode { + enum { TIMER_MIN_TICKS_PER_MS = 1000ULL }; + /* * Translate timer ticks to microseconds without losing precicision * @@ -28,8 +30,9 @@ namespace Genode { * shifting the values to their optimal bit position. Afterwards, the * results are shifted back and merged together again. * - * Please ensure that the assertion "ticks_per_ms >= 1000" is true - * when calling this method! + * Please ensure that the assertion + * "ticks_per_ms >= TIMER_MIN_TICKS_PER_MS" is true when calling this + * method! */ template RESULT_T timer_ticks_to_us(RESULT_T const ticks, diff --git a/repos/os/src/drivers/timer/pit/time_source.cc b/repos/os/src/drivers/timer/pit/time_source.cc index 8986b5049..443f80cc1 100644 --- a/repos/os/src/drivers/timer/pit/time_source.cc +++ b/repos/os/src/drivers/timer/pit/time_source.cc @@ -92,7 +92,8 @@ Duration Timer::Time_source::curr_time() ticks = PIT_MAX_COUNT + 1 - curr_counter; } - static_assert(PIT_TICKS_PER_MSEC >= 1000, "Bad TICS_PER_MS value"); + static_assert(PIT_TICKS_PER_MSEC >= (unsigned)TIMER_MIN_TICKS_PER_MS, + "Bad TICS_PER_MS value"); _curr_time_us += timer_ticks_to_us(ticks, PIT_TICKS_PER_MSEC); /* use current counter as the reference for the next update */