Adding upstream version 3.53.
[syslinux-debian/hramrach.git] / com32 / include / sys / cpu.h
blob0a7b46520e6c7544d02801be410de01f82d5618d
1 #ifndef _CPU_H
2 #define _CPU_H
4 #include <inttypes.h>
6 static inline uint64_t rdtsc(void)
8 uint64_t v;
9 asm volatile("rdtsc" : "=A" (v));
10 return v;
13 static inline uint32_t rdtscl(void)
15 uint32_t v;
16 asm volatile("rdtsc" : "=a" (v) : : "edx");
17 return v;
20 static inline uint32_t cpuid_eax(uint32_t level)
22 uint32_t v;
24 asm("cpuid" : "=a" (v) : "a" (level) : "ebx", "ecx", "edx");
25 return v;
27 static inline uint32_t cpuid_ebx(uint32_t level)
29 uint32_t v;
31 asm("cpuid" : "=b" (v), "+a" (level) : : "ecx", "edx");
32 return v;
34 static inline uint32_t cpuid_ecx(uint32_t level)
36 uint32_t v;
38 asm("cpuid" : "=c" (v), "+a" (level) : : "ebx", "edx");
39 return v;
41 static inline uint32_t cpuid_edx(uint32_t level)
43 uint32_t v;
45 asm("cpuid" : "=d" (v), "+a" (level) : : "ebx", "ecx");
46 return v;
49 static inline uint64_t rdmsr(uint32_t msr)
51 uint64_t v;
53 asm volatile("rdmsr" : "=A" (v) : "c" (msr));
54 return v;
56 static inline void wrmsr(uint64_t v, uint32_t msr)
58 asm volatile("wrmsr" : : "A" (v), "c" (msr));
61 static inline void cpu_relax(void)
63 asm volatile("rep ; nop");
66 /* These are local cli/sti; not SMP-safe!!! */
68 static inline void cli(void)
70 asm volatile("cli");
73 static inline void sti(void)
75 asm volatile("sti");
78 #endif