2020-04-18 22:26:39 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2018-01-23 18:53:05 +01:00
|
|
|
|
|
|
|
#include <cpu/x86/msr.h>
|
|
|
|
#include <timer.h>
|
2018-01-25 01:42:51 +01:00
|
|
|
#include <timestamp.h>
|
2018-01-23 18:53:05 +01:00
|
|
|
|
|
|
|
#define CU_PTSC_MSR 0xc0010280
|
|
|
|
#define PTSC_FREQ_MHZ 100
|
|
|
|
|
|
|
|
void timer_monotonic_get(struct mono_time *mt)
|
2018-01-25 01:42:51 +01:00
|
|
|
{
|
|
|
|
mono_time_set_usecs(mt, timestamp_get());
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t timestamp_get(void)
|
2018-01-23 18:53:05 +01:00
|
|
|
{
|
|
|
|
unsigned long long val;
|
|
|
|
msr_t msr;
|
|
|
|
|
|
|
|
msr = rdmsr(CU_PTSC_MSR);
|
|
|
|
|
|
|
|
val = ((unsigned long long)msr.hi << 32) | msr.lo;
|
|
|
|
|
2018-01-25 01:42:51 +01:00
|
|
|
return val / PTSC_FREQ_MHZ;
|
2018-01-23 18:53:05 +01:00
|
|
|
}
|