summaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
Diffstat (limited to 'asm')
-rw-r--r--asm/asm_x86.h2
-rw-r--r--asm/asm_x86.s17
2 files changed, 19 insertions, 0 deletions
diff --git a/asm/asm_x86.h b/asm/asm_x86.h
index ec9ebd0..0781fc7 100644
--- a/asm/asm_x86.h
+++ b/asm/asm_x86.h
@@ -100,4 +100,6 @@ static inline void x86_paging_enable() {x86_set_cr(0,x86_get_cr(0)| 0x8000000
/** Disable paging */
static inline void x86_paging_disable() {x86_set_cr(0,x86_get_cr(0)&~0x80000000);}
+/** Read Time Stamp Counter */
+uint64_t x86_rdtscp();
#endif
diff --git a/asm/asm_x86.s b/asm/asm_x86.s
index 3481ec2..7f0f56b 100644
--- a/asm/asm_x86.s
+++ b/asm/asm_x86.s
@@ -24,6 +24,9 @@
.global x86_get_cr
.global x86_set_cr
+// timer
+.global x86_rdtscp
+
x86_outb:
mov 4(%esp), %edx
mov 8(%esp), %eax
@@ -132,3 +135,17 @@ x86_invlpg:
mov 4(%esp), %eax // addr
invlpg (%eax)
ret
+
+#x86_rdtscp:
+# rdtscp
+# ret
+# https://stackoverflow.com/questions/12631856/difference-between-rdtscp-rdtsc-memory-and-cpuid-rdtsc
+x86_rdtscp:
+ lfence #intel
+ rdtsc
+ ret
+
+#x86_rdtscp:
+# mfence #amd
+# rdtsc
+# ret