1 /* 2 * Copyright (c) 2017 Synopsys, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief Time Stamp API for ARCv2 10 * 11 * Provide 64-bit time stamp API 12 */ 13 14 #include <zephyr/kernel.h> 15 #include <zephyr/toolchain.h> 16 #include <zephyr/kernel_structs.h> 17 18 /* 19 * @brief Read 64-bit timestamp value 20 * 21 * This function returns a 64-bit bit time stamp value that is clocked 22 * at the same frequency as the CPU. 23 * 24 * @return 64-bit time stamp value 25 */ z_tsc_read(void)26uint64_t z_tsc_read(void) 27 { 28 unsigned int key; 29 uint64_t t; 30 uint32_t count; 31 32 key = arch_irq_lock(); 33 t = (uint64_t)sys_clock_tick_get(); 34 count = z_arc_v2_aux_reg_read(_ARC_V2_TMR0_COUNT); 35 arch_irq_unlock(key); 36 t *= k_ticks_to_cyc_floor64(1); 37 t += (uint64_t)count; 38 return t; 39 } 40