summaryrefslogtreecommitdiffstats
path: root/src/arch/x86_64
diff options
context:
space:
mode:
authorMichael Brown2014-04-23 18:43:18 +0200
committerMichael Brown2014-04-28 00:14:43 +0200
commite5f6a9be384f6adc2b50ffdb8781e81327b790aa (patch)
tree42efc59b490b68891abd81a5cc11ac938c3848c2 /src/arch/x86_64
parent[libc] Add flsll() (diff)
downloadipxe-e5f6a9be384f6adc2b50ffdb8781e81327b790aa.tar.gz
ipxe-e5f6a9be384f6adc2b50ffdb8781e81327b790aa.tar.xz
ipxe-e5f6a9be384f6adc2b50ffdb8781e81327b790aa.zip
[profile] Add generic profiling infrastructure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86_64')
-rw-r--r--src/arch/x86_64/include/bits/profile.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/arch/x86_64/include/bits/profile.h b/src/arch/x86_64/include/bits/profile.h
new file mode 100644
index 000000000..6fc16d84b
--- /dev/null
+++ b/src/arch/x86_64/include/bits/profile.h
@@ -0,0 +1,29 @@
+#ifndef _BITS_PROFILE_H
+#define _BITS_PROFILE_H
+
+/** @file
+ *
+ * Profiling
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdint.h>
+
+/**
+ * Get profiling timestamp
+ *
+ * @ret timestamp Timestamp
+ */
+static inline __attribute__ (( always_inline )) uint64_t
+profile_timestamp ( void ) {
+ uint32_t eax;
+ uint32_t edx;
+
+ /* Read timestamp counter */
+ __asm__ __volatile__ ( "rdtsc" : "=a" ( eax ), "=d" ( edx ) );
+ return ( ( ( ( uint64_t ) edx ) << 32 ) | eax );
+}
+
+#endif /* _BITS_PROFILE_H */