summaryrefslogtreecommitdiff
path: root/arch/x86/machine/cpu.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-05-16 01:57:40 +0200
committerRichard Braun <rbraun@sceen.net>2017-05-16 01:57:40 +0200
commitfca151d3e8b551483cc3f5d43394a1d90b79ee34 (patch)
tree5d589f612de3d85f88bf9b1b61ea6b11141682ed /arch/x86/machine/cpu.h
parent27781cb2cbed5752861483623ac00e740a71678b (diff)
x86/{cpu,pit}: implement cpu_delay using the timestamp counter
Diffstat (limited to 'arch/x86/machine/cpu.h')
-rw-r--r--arch/x86/machine/cpu.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/arch/x86/machine/cpu.h b/arch/x86/machine/cpu.h
index 3bf1ade3..2360ea7d 100644
--- a/arch/x86/machine/cpu.h
+++ b/arch/x86/machine/cpu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2014 Richard Braun.
+ * Copyright (c) 2010-2017 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -479,6 +479,15 @@ cpu_set_msr(uint32_t msr, uint32_t high, uint32_t low)
asm volatile("wrmsr" : : "c" (msr), "a" (low), "d" (high));
}
+static __always_inline uint64_t
+cpu_get_tsc(void)
+{
+ uint32_t high, low;
+
+ asm volatile("rdtsc" : "=a" (low), "=d" (high));
+ return ((uint64_t)high << 32) | low;
+}
+
/*
* Flush non-global TLB entries.
*
@@ -528,13 +537,9 @@ cpu_tlb_flush_va(unsigned long va)
}
/*
- * XXX For now, directly use the PIT.
+ * Busy-wait for a given amount of time, in microseconds.
*/
-static inline void
-cpu_delay(unsigned long usecs)
-{
- pit_delay(usecs);
-}
+void cpu_delay(unsigned long usecs);
/*
* Return the address of the boot stack allocated for the current processor.