Avoids nehalem keyboard issues, better monitors
[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(uint32_t index)
18 {                                                                                                    
19     uint64_t pmc;
20
21     __asm __volatile("rdpmc" : "=A" (pmc) : "c" (index)); 
22     return pmc;                                                                                      
23 }
24
25 void perfmon_init();
26
27 #endif /* ROS_INC_PERFMON_H */