6 typedef __builtin_msr_t msr_t;
8 static msr_t rdmsr(unsigned long index)
10 return __builtin_rdmsr(index);
13 static void wrmsr(unsigned long index, msr_t msr)
15 __builtin_wrmsr(index, msr.lo, msr.hi);
20 typedef struct msr_struct
26 typedef struct msrinit_struct
32 /* The following functions require the always_inline due to AMD
33 * function STOP_CAR_AND_CPU that disables cache as
34 * ram, the cache as ram stack can no longer be used. Called
35 * functions must be inlined to avoid stack usage. Also, the
36 * compiler must keep local variables register based and not
37 * allocated them from the stack. With gcc 4.5.0, some functions
38 * declared as inline are not being inlined. This patch forces
39 * these functions to always be inlined by adding the qualifier
40 * __attribute__((always_inline)) to their declaration.
42 static inline __attribute__((always_inline)) msr_t rdmsr(unsigned index)
45 __asm__ __volatile__ (
47 : "=a" (result.lo), "=d" (result.hi)
53 static inline __attribute__((always_inline)) void wrmsr(unsigned index, msr_t msr)
55 __asm__ __volatile__ (
58 : "c" (index), "a" (msr.lo), "d" (msr.hi)
62 #endif /* __ROMCC__ */
64 #endif /* CPU_X86_MSR_H */