2020-08-28 11:07:01 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Intel Corporation.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:49:15 +08:00
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#include <zephyr/sys_clock.h>
|
|
|
|
#include <zephyr/timing/timing.h>
|
2020-08-28 11:07:01 +08:00
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
void arch_timing_init(void)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
void arch_timing_start(void)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
void arch_timing_stop(void)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
timing_t arch_timing_counter_get(void)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
|
|
|
return k_cycle_get_32();
|
|
|
|
}
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
uint64_t arch_timing_cycles_get(volatile timing_t *const start,
|
|
|
|
volatile timing_t *const end)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
|
|
|
return (*end - *start);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
uint64_t arch_timing_freq_get(void)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
|
|
|
return sys_clock_hw_cycles_per_sec();
|
|
|
|
}
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
uint64_t arch_timing_cycles_to_ns(uint64_t cycles)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
|
|
|
return k_cyc_to_ns_floor64(cycles);
|
|
|
|
}
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
uint64_t arch_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
2020-10-15 02:15:40 +08:00
|
|
|
return arch_timing_cycles_to_ns(cycles) / count;
|
2020-08-28 11:07:01 +08:00
|
|
|
}
|
|
|
|
|
2020-10-15 02:15:40 +08:00
|
|
|
uint32_t arch_timing_freq_get_mhz(void)
|
2020-08-28 11:07:01 +08:00
|
|
|
{
|
2021-04-03 13:55:18 +08:00
|
|
|
return (uint32_t)(arch_timing_freq_get() / 1000000U);
|
2020-08-28 11:07:01 +08:00
|
|
|
}
|