77#include <sddf/timer/timer_driver.h>
88#include <sddf/timer/protocol.h>
99#include <sddf/util/util.h>
10- #include <sddf/util/div64.h>
1110
1211// This file implements cached time conversion which is suitable for almost
1312// all timer drivers. Omit this file and use your own time conversion in your driver
14- // if you do not want the caching behaviour. All non-caching common code is
15- // contained in timer_driver_virt.c and time_conv.c.
16- // NOTE: this file depends on time_conv.c!
13+ // if you do not want the caching behaviour.
1714
18-
19- // Mult-shift cache. It's relatively expensive to calculate this every time, so we just
20- // don't. Usually we will just be reusing the last result, so we just remember the last
21- // one. We keep a separate entry for tick->ns and ns->tick.
2215ms_cache_entry_t tick_to_ns_cache = {0 };
2316ms_cache_entry_t ns_to_tick_cache = {0 };
2417
@@ -54,11 +47,8 @@ static inline uint64_t do_cached_period_freq_shift(uint64_t t_a, sddf_timer_freq
5447 * This function internally caches magic values for the calculation, these are recalculated
5548 * each time the frequency pair changes. Use do_freq_shift() to avoid caching.
5649 *
57- * Prescaler should be given as an exponent, i.e. prescaler counter counts to 2^N,
58- * provide N.
59- *
6050 * @param uint64_t ticks to convert
61- * @param uint64_t prescaler exponent
51+ * @param uint64_t prescaler exponent - i.e. if scaling to 2^N give N.
6252 * @returns non-zero on failure.
6353 */
6454uint64_t tick_to_ns_cached (uint64_t ticks , uint64_t prescaler , sddf_timer_freq_hz_t base_freq )
@@ -78,11 +68,8 @@ uint64_t tick_to_ns_cached(uint64_t ticks, uint64_t prescaler, sddf_timer_freq_h
7868 * This function internally caches magic values for the calculation, these are recalculated
7969 * each time the frequency pair changes. Use do_freq_shift() to avoid caching.
8070 *
81- * Prescaler should be given as an exponent, i.e. prescaler counter counts to 2^N,
82- * provide N.
83- *
8471 * @param uint64_t ticks to convert
85- * @param uint64_t prescaler exponent
72+ * @param uint64_t prescaler exponent - i.e. if scaling to 2^N give N.
8673 * @returns non-zero on failure.
8774 */
8875uint64_t ns_to_tick_cached (uint64_t ns , uint64_t prescaler , sddf_timer_freq_hz_t base_freq ) {
0 commit comments