summaryrefslogtreecommitdiffstats
path: root/src/asm.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-08-13 16:44:04 +0200
committerLouis Burda <quent.burda@gmail.com>2022-08-13 16:45:08 +0200
commit98babf91dcf166bc7644a3d70a90dac272f12a75 (patch)
tree529acab95367ae6ed35eddf0731ee82f73c94842 /src/asm.h
parent88d598bc2894c28d8dd9c2259c5c8cbe2ec7ce55 (diff)
downloadcachepc-98babf91dcf166bc7644a3d70a90dac272f12a75.tar.gz
cachepc-98babf91dcf166bc7644a3d70a90dac272f12a75.zip
Reorder repo into module and tests
Diffstat (limited to 'src/asm.h')
-rwxr-xr-xsrc/asm.h85
1 files changed, 0 insertions, 85 deletions
diff --git a/src/asm.h b/src/asm.h
deleted file mode 100755
index 35f803b..0000000
--- a/src/asm.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#pragma once
-
-#include <linux/kernel.h>
-
-#define CPUID_AFFECTED_REGS "rax", "rbx", "rcx", "rdx"
-
-__attribute__((always_inline))
-static inline uint64_t cachepc_readpmc(uint64_t event);
-
-__attribute__((always_inline))
-static inline void cachepc_cpuid(void);
-
-__attribute__((always_inline))
-static inline void cachepc_lfence(void);
-
-__attribute__((always_inline))
-static inline void cachepc_sfence(void);
-
-__attribute__((always_inline))
-static inline void cachepc_mfence(void);
-
-__attribute__((always_inline))
-static inline void cachepc_readq(void *p);
-
-uint64_t
-cachepc_readpmc(uint64_t event)
-{
- uint32_t lo, hi;
-
- event = 0xC0010201 + 2 * event;
-
- asm volatile (
- "rdmsr"
- : "=a" (lo), "=d" (hi)
- : "c"(event)
- );
-
- return ((uint64_t) hi << 32) | (uint64_t) lo;
-}
-
-void
-cachepc_cpuid(void)
-{
- asm volatile(
- "mov $0x80000005, %%eax\n\t"
- "cpuid\n\t"
- ::: CPUID_AFFECTED_REGS
- );
-}
-
-void
-cachepc_lfence(void)
-{
- asm volatile(
- "lfence\n\t"
- ::: "memory"
- );
-}
-
-void
-cachepc_sfence(void)
-{
- asm volatile(
- "sfence\n\t"
- ::: "memory"
- );
-}
-
-void
-cachepc_mfence(void)
-{
- asm volatile(
- "mfence\n\t"
- ::: "memory"
- );
-}
-
-void
-cachepc_readq(void *p)
-{
- asm volatile (
- "movq (%0), %%r10\n\t"
- : : "r" (p) : "r10"
- );
-}