Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <cpu/x86/tsc.h> |
| 17 | #include <timestamp.h> |
| 18 | |
| 19 | uint64_t timestamp_get(void) |
| 20 | { |
| 21 | return rdtscll(); |
| 22 | } |
Aaron Durbin | c49014e | 2015-08-30 21:19:55 -0500 | [diff] [blame] | 23 | |
| 24 | unsigned long __attribute__((weak)) tsc_freq_mhz(void) |
| 25 | { |
| 26 | /* Default to not knowing TSC frequency. cbmem will have to fallback |
| 27 | * on trying to determine it in userspace. */ |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | int timestamp_tick_freq_mhz(void) |
| 32 | { |
| 33 | /* Chipsets that have a constant TSC provide this value correctly. */ |
| 34 | return tsc_freq_mhz(); |
| 35 | } |