T Michael Turney | 3775f1c | 2018-04-24 10:15:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
T Michael Turney | 3775f1c | 2018-04-24 10:15:46 -0700 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <timer.h> |
| 15 | #include <arch/lib_helpers.h> |
| 16 | |
| 17 | void timer_monotonic_get(struct mono_time *mt) |
| 18 | { |
| 19 | uint64_t tvalue = raw_read_cntpct_el0(); |
| 20 | uint32_t tfreq = raw_read_cntfrq_el0(); |
| 21 | long usecs = (tvalue * 1000000) / tfreq; |
| 22 | mono_time_set_usecs(mt, usecs); |
| 23 | } |