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> |
Elyes Haouas | 6f0531c | 2022-10-02 12:10:20 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 5 | #include <timestamp.h> |
| 6 | |
| 7 | uint64_t timestamp_get(void) |
| 8 | { |
| 9 | return rdtscll(); |
| 10 | } |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 11 | |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 12 | int timestamp_tick_freq_mhz(void) |
| 13 | { |
| 14 | /* Chipsets that have a constant TSC provide this value correctly. */ |
Kyösti Mälkki | 0d6ddf8 | 2019-10-31 14:52:20 +0200 | [diff] [blame] | 15 | if (tsc_constant_rate()) |
Kyösti Mälkki | 6c19cb5 | 2019-01-08 19:14:41 +0200 | [diff] [blame] | 16 | 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 Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 22 | } |