2017-02-15 05:17:53 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Synopsys, Inc.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Time Stamp API for ARCv2
|
|
|
|
*
|
|
|
|
* Provide 64-bit time stamp API
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:49:15 +08:00
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#include <zephyr/toolchain.h>
|
|
|
|
#include <zephyr/kernel_structs.h>
|
2017-02-15 05:17:53 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @brief Read 64-bit timestamp value
|
|
|
|
*
|
|
|
|
* This function returns a 64-bit bit time stamp value that is clocked
|
|
|
|
* at the same frequency as the CPU.
|
|
|
|
*
|
|
|
|
* @return 64-bit time stamp value
|
|
|
|
*/
|
2020-05-28 00:26:57 +08:00
|
|
|
uint64_t z_tsc_read(void)
|
2017-02-15 05:17:53 +08:00
|
|
|
{
|
|
|
|
unsigned int key;
|
2020-05-28 00:26:57 +08:00
|
|
|
uint64_t t;
|
|
|
|
uint32_t count;
|
2017-02-15 05:17:53 +08:00
|
|
|
|
2020-04-06 18:30:36 +08:00
|
|
|
key = arch_irq_lock();
|
2021-03-13 21:21:21 +08:00
|
|
|
t = (uint64_t)sys_clock_tick_get();
|
2019-03-09 05:19:05 +08:00
|
|
|
count = z_arc_v2_aux_reg_read(_ARC_V2_TMR0_COUNT);
|
2020-04-06 18:30:36 +08:00
|
|
|
arch_irq_unlock(key);
|
2019-10-04 02:43:10 +08:00
|
|
|
t *= k_ticks_to_cyc_floor64(1);
|
2020-05-28 00:26:57 +08:00
|
|
|
t += (uint64_t)count;
|
2017-02-15 05:17:53 +08:00
|
|
|
return t;
|
|
|
|
}
|