Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[i386] Add functions to read and write model-specific registers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 23, 2014
1 parent 3a02409 commit 945b8de
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/arch/i386/include/ipxe/msr.h
@@ -0,0 +1,38 @@
#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 ) {
uint64_t value;

__asm__ __volatile__ ( "rdmsr" : "=A" ( value ) : "c" ( msr ) );
return value;
}

/**
* 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 ) {

__asm__ __volatile__ ( "wrmsr" : : "c" ( msr ), "A" ( value ) );
}

#endif /* _IPXE_MSR_H */

0 comments on commit 945b8de

Please sign in to comment.