Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 1 | #ifndef CPU_X86_MSR_H |
| 2 | #define CPU_X86_MSR_H |
| 3 | |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 4 | #if defined( __ROMCC__) && !defined (__GNUC__) |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 5 | |
| 6 | typedef __builtin_msr_t msr_t; |
| 7 | |
| 8 | static msr_t rdmsr(unsigned long index) |
| 9 | { |
| 10 | return __builtin_rdmsr(index); |
| 11 | } |
| 12 | |
| 13 | static void wrmsr(unsigned long index, msr_t msr) |
| 14 | { |
| 15 | __builtin_wrmsr(index, msr.lo, msr.hi); |
| 16 | } |
| 17 | |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 18 | #else |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 19 | |
| 20 | typedef struct msr_struct |
| 21 | { |
| 22 | unsigned lo; |
| 23 | unsigned hi; |
| 24 | } msr_t; |
| 25 | |
| 26 | static inline msr_t rdmsr(unsigned index) |
| 27 | { |
| 28 | msr_t result; |
| 29 | __asm__ __volatile__ ( |
| 30 | "rdmsr" |
| 31 | : "=a" (result.lo), "=d" (result.hi) |
| 32 | : "c" (index) |
| 33 | ); |
| 34 | return result; |
| 35 | } |
| 36 | |
| 37 | static inline void wrmsr(unsigned index, msr_t msr) |
| 38 | { |
| 39 | __asm__ __volatile__ ( |
| 40 | "wrmsr" |
| 41 | : /* No outputs */ |
| 42 | : "c" (index), "a" (msr.lo), "d" (msr.hi) |
| 43 | ); |
| 44 | } |
| 45 | |
arch import user (historical) | 6ca7636 | 2005-07-06 17:17:25 +0000 | [diff] [blame] | 46 | #endif /* ROMCC__ && !__GNUC__ */ |
Eric Biederman | c84c190 | 2004-10-14 20:13:01 +0000 | [diff] [blame] | 47 | |
| 48 | |
| 49 | #endif /* CPU_X86_MSR_H */ |