Adding initial support for performance counters.
[akaros.git] / kern / arch / i686 / perfmon.h
1 #ifndef ROS_INC_PERFMON_H
2 #define ROS_INC_PERFMON_H
3 #include <ros/common.h>
4 #include <arch/x86.h>
5
6 #define IA32_PMC_BASE 0xC1
7 #define IA32_PERFEVTSEL_BASE 0x186
8
9 #define LLCACHE_EVENT 0x2E
10 #define LLCACHE_MISS_MASK 0x41
11 #define LLCACHE_REF_MASK 0x4F
12 #define ENABLE_PERFCTR 0x00400000
13 #define DISABLE_PERFCTR 0xFFAFFFFF
14
15
16 static __inline uint64_t
17 read_pmc(void)
18 {
19     uint64_t pmc;
20     __asm __volatile("rdpmc" : "=A" (pmc));
21     return pmc;
22 }
23
24 void perfmon_init();
25
26 #endif /* ROS_INC_PERFMON_H */