1 #ifndef _IPXE_MSR_H 2 #define _IPXE_MSR_H 3 4 /** @file 5 * 6 * Model-specific registers 7 * 8 */ 9 10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 11 12 /** 13 * Read model-specific register 14 * 15 * @v msr Model-specific register 16 * @ret value Value 17 */ 18 static inline __attribute__ (( always_inline )) uint64_t rdmsr(unsigned int msr)19rdmsr ( unsigned int msr ) { 20 uint32_t high; 21 uint32_t low; 22 23 __asm__ __volatile__ ( "rdmsr" : 24 "=d" ( high ), "=a" ( low ) : "c" ( msr ) ); 25 return ( ( ( ( uint64_t ) high ) << 32 ) | low ); 26 } 27 28 /** 29 * Write model-specific register 30 * 31 * @v msr Model-specific register 32 * @v value Value 33 */ 34 static inline __attribute__ (( always_inline )) void wrmsr(unsigned int msr,uint64_t value)35wrmsr ( unsigned int msr, uint64_t value ) { 36 uint32_t high = ( value >> 32 ); 37 uint32_t low = ( value >> 0 ); 38 39 __asm__ __volatile__ ( "wrmsr" : : 40 "c" ( msr ), "d" ( high ), "a" ( low ) ); 41 } 42 43 #endif /* _IPXE_MSR_H */ 44