blob: 0a4c9c4ec9b5150ea5fbededbc2604716d521f4a [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer3a6550d2013-08-01 13:31:44 -07002
3#include <cpu/x86/tsc.h>
Elyes Haouas6f0531c2022-10-02 12:10:20 +02004#include <stdint.h>
Stefan Reinauer3a6550d2013-08-01 13:31:44 -07005#include <timestamp.h>
6
7uint64_t timestamp_get(void)
8{
9 return rdtscll();
10}
Aaron Durbinc49014e2015-08-30 21:19:55 -050011
Aaron Durbinc49014e2015-08-30 21:19:55 -050012int timestamp_tick_freq_mhz(void)
13{
14 /* Chipsets that have a constant TSC provide this value correctly. */
Kyösti Mälkki0d6ddf82019-10-31 14:52:20 +020015 if (tsc_constant_rate())
Kyösti Mälkki6c19cb52019-01-08 19:14:41 +020016 return tsc_freq_mhz();
17
18 /* Filling tick_freq_mhz = 0 in timestamps-table will trigger
19 * userspace utility to try deduce it from the running system.
20 */
21 return 0;
Aaron Durbinc49014e2015-08-30 21:19:55 -050022}