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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kernel.h>
|
|
|
|
#include <toolchain.h>
|
|
|
|
#include <kernel_structs.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @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
|
|
|
|
*/
|
2017-04-21 02:30:33 +08:00
|
|
|
u64_t _tsc_read(void)
|
2017-02-15 05:17:53 +08:00
|
|
|
{
|
|
|
|
unsigned int key;
|
2017-04-21 02:30:33 +08:00
|
|
|
u64_t t;
|
|
|
|
u32_t count;
|
2017-02-15 05:17:53 +08:00
|
|
|
|
|
|
|
key = irq_lock();
|
2018-09-20 05:17:00 +08:00
|
|
|
t = (u64_t)z_tick_get();
|
2017-02-15 05:17:53 +08:00
|
|
|
count = _arc_v2_aux_reg_read(_ARC_V2_TMR0_COUNT);
|
|
|
|
irq_unlock(key);
|
2018-09-20 02:33:07 +08:00
|
|
|
t *= (u64_t)sys_clock_hw_cycles_per_tick();
|
2017-04-21 02:30:33 +08:00
|
|
|
t += (u64_t)count;
|
2017-02-15 05:17:53 +08:00
|
|
|
return t;
|
|
|
|
}
|