clock: add k_cycle_get_64

This change adds `k_cycle_get_64()` on platforms that
support a 64-bit cycle counter.

The interface functions `arch_k_cycle_get_64()` and
`sys_clock_cycle_get_64()` are also introduced.

Fixes #39934

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This commit is contained in:
Christopher Friedt 2021-10-29 20:10:35 -04:00
commit 918a574c88
25 changed files with 205 additions and 4 deletions

View file

@ -52,6 +52,20 @@ uint32_t sys_clock_cycle_get_32(void)
return timer_total;
}
uint64_t sys_clock_cycle_get_64(void)
{
static struct k_spinlock lock;
uint64_t timer_total;
k_spinlock_key_t key = k_spin_lock(&lock);
litex_write8(UPDATE_TOTAL, TIMER_TOTAL_UPDATE);
timer_total = litex_read64(TIMER_TOTAL);
k_spin_unlock(&lock, key);
return timer_total;
}
/* tickless kernel is not supported */
uint32_t sys_clock_elapsed(void)
{