Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 2 | |
| 3 | #include <cpu/x86/tsc.h> |
| 4 | #include <timestamp.h> |
| 5 | |
| 6 | uint64_t timestamp_get(void) |
| 7 | { |
| 8 | return rdtscll(); |
| 9 | } |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 10 | |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 11 | int timestamp_tick_freq_mhz(void) |
| 12 | { |
| 13 | /* Chipsets that have a constant TSC provide this value correctly. */ |
Kyösti Mälkki | 0d6ddf8 | 2019-10-31 14:52:20 +0200 | [diff] [blame] | 14 | if (tsc_constant_rate()) |
Kyösti Mälkki | 6c19cb5 | 2019-01-08 19:14:41 +0200 | [diff] [blame] | 15 | return tsc_freq_mhz(); |
| 16 | |
| 17 | /* Filling tick_freq_mhz = 0 in timestamps-table will trigger |
| 18 | * userspace utility to try deduce it from the running system. |
| 19 | */ |
| 20 | return 0; |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 21 | } |