]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[i386] Add functions to read and write model-specific registers
authorMichael Brown <mcb30@ipxe.org>
Sun, 20 Jul 2014 10:10:00 +0000 (11:10 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 23 Jul 2014 09:20:15 +0000 (10:20 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/include/ipxe/msr.h [new file with mode: 0644]

diff --git a/src/arch/i386/include/ipxe/msr.h b/src/arch/i386/include/ipxe/msr.h
new file mode 100644 (file)
index 0000000..c88e26a
--- /dev/null
@@ -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 */