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

@ -77,6 +77,17 @@ static uint32_t count32(void)
return shim_regs->walclk32_lo;
}
static uint64_t count64(void)
{
k_spinlock_key_t key = k_spin_lock(&lock);
uint64_t ret = shim_regs->walclk32_lo;
ret |= (uint64_t)shim_regs->walclk32_hi << 32;
k_spin_unlock(&lock, key);
return ret;
}
static void compare_isr(const void *arg)
{
ARG_UNUSED(arg);
@ -182,6 +193,11 @@ uint32_t sys_clock_cycle_get_32(void)
return count32();
}
uint64_t sys_clock_cycle_get_64(void)
{
return count64();
}
/* Runs on secondary cores */
void smp_timer_init(void)
{