diff options
author | Michael Brown <mcb30@ipxe.org> | 2014-07-20 11:10:24 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2014-07-23 10:20:15 +0100 |
commit | 5888c887a4adbbb6d98c7fba6e469ac5ad9f129c (patch) | |
tree | 74e54fda7677709adb25fd5bc5d110ddaabe3c31 /src | |
parent | 945b8de1fd4f4e93d3a221e790a2ed28aa20cad9 (diff) | |
download | ipxe-5888c887a4adbbb6d98c7fba6e469ac5ad9f129c.zip ipxe-5888c887a4adbbb6d98c7fba6e469ac5ad9f129c.tar.gz ipxe-5888c887a4adbbb6d98c7fba6e469ac5ad9f129c.tar.bz2 |
[x86_64] Add functions to read and write model-specific registers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/x86_64/include/ipxe/msr.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/arch/x86_64/include/ipxe/msr.h b/src/arch/x86_64/include/ipxe/msr.h new file mode 100644 index 0000000..a5816ac --- /dev/null +++ b/src/arch/x86_64/include/ipxe/msr.h @@ -0,0 +1,43 @@ +#ifndef _IPXE_MSR_H +#define _IPXE_MSR_H + +/** @file + * + * Model-specific registers + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +/** + * Read model-specific register + * + * @v msr Model-specific register + * @ret value Value + */ +static inline __attribute__ (( always_inline )) uint64_t +rdmsr ( unsigned int msr ) { + uint32_t high; + uint32_t low; + + __asm__ __volatile__ ( "rdmsr" : + "=d" ( high ), "=a" ( low ) : "c" ( msr ) ); + return ( ( ( ( uint64_t ) high ) << 32 ) | low ); +} + +/** + * Write model-specific register + * + * @v msr Model-specific register + * @v value Value + */ +static inline __attribute__ (( always_inline )) void +wrmsr ( unsigned int msr, uint64_t value ) { + uint32_t high = ( value >> 32 ); + uint32_t low = ( value >> 0 ); + + __asm__ __volatile__ ( "wrmsr" : : + "c" ( msr ), "d" ( high ), "a" ( low ) ); +} + +#endif /* _IPXE_MSR_H */ |