blob: e6d0369eff5cc918a16baa7294f48f9f7bf84a1f [file] [log] [blame]
Lee Leahy87df8d02016-02-07 14:37:13 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 * Copyright (C) 2015-2016 Intel Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <stdint.h>
18#include <cpu/x86/msr.h>
19#include <cpu/x86/tsc.h>
Lee Leahy68fdb782016-12-31 08:21:56 -080020#include <timer.h>
Lee Leahy87df8d02016-02-07 14:37:13 -080021
22unsigned long tsc_freq_mhz(void)
23{
Lee Leahy68fdb782016-12-31 08:21:56 -080024 /* CPU freq = 400 MHz */
25 return 400;
26}
Lee Leahy87df8d02016-02-07 14:37:13 -080027
Lee Leahy68fdb782016-12-31 08:21:56 -080028void timer_monotonic_get(struct mono_time *mt)
29{
30 uint64_t tsc_value;
Lee Leahy87df8d02016-02-07 14:37:13 -080031
Lee Leahy68fdb782016-12-31 08:21:56 -080032 tsc_value = rdtscll();
33 mt->microseconds = tsc_value / tsc_freq_mhz();
Lee Leahy87df8d02016-02-07 14:37:13 -080034}