summaryrefslogtreecommitdiff
path: root/kernel/arch/i386/tsc.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/arch/i386/tsc.c')
-rw-r--r--kernel/arch/i386/tsc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/arch/i386/tsc.c b/kernel/arch/i386/tsc.c
new file mode 100644
index 0000000..a4f3c3f
--- /dev/null
+++ b/kernel/arch/i386/tsc.c
@@ -0,0 +1,16 @@
+#include <arch/i386/tsc.h>
+
+u64 cpu_mhz = 0;
+u64 tsc_get_hz(void);
+
+void tsc_init(void) {
+ cpu_mhz = tsc_get_hz() / 10000;
+}
+
+u64 tsc_get_mhz() {
+ return cpu_mhz;
+}
+
+u64 tsc_calculate_ms(u64 tsc) {
+ return tsc / (cpu_mhz * 1000);
+}