summaryrefslogtreecommitdiffstats
path: root/src/arch/i386
diff options
context:
space:
mode:
authorMichael Brown2014-07-20 12:10:00 +0200
committerMichael Brown2014-07-23 11:20:15 +0200
commit945b8de1fd4f4e93d3a221e790a2ed28aa20cad9 (patch)
tree24679f31266e4e9264d79741cc55398066935215 /src/arch/i386
parent[natsemi] Check for ioremap() failures (diff)
downloadipxe-945b8de1fd4f4e93d3a221e790a2ed28aa20cad9.tar.gz
ipxe-945b8de1fd4f4e93d3a221e790a2ed28aa20cad9.tar.xz
ipxe-945b8de1fd4f4e93d3a221e790a2ed28aa20cad9.zip
[i386] Add functions to read and write model-specific registers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386')
-rw-r--r--src/arch/i386/include/ipxe/msr.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/arch/i386/include/ipxe/msr.h b/src/arch/i386/include/ipxe/msr.h
new file mode 100644
index 000000000..c88e26a39
--- /dev/null
+++ b/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 */