Browse Source

[i386] Add functions to read and write model-specific registers

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
945b8de1fd
1 changed files with 38 additions and 0 deletions
  1. 38
    0
      src/arch/i386/include/ipxe/msr.h

+ 38
- 0
src/arch/i386/include/ipxe/msr.h View File

@@ -0,0 +1,38 @@
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 );
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
19
+rdmsr ( unsigned int msr ) {
20
+	uint64_t value;
21
+
22
+	__asm__ __volatile__ ( "rdmsr" : "=A" ( value ) : "c" ( msr ) );
23
+	return value;
24
+}
25
+
26
+/**
27
+ * Write model-specific register
28
+ *
29
+ * @v msr		Model-specific register
30
+ * @v value		Value
31
+ */
32
+static inline __attribute__ (( always_inline )) void
33
+wrmsr ( unsigned int msr, uint64_t value ) {
34
+
35
+	__asm__ __volatile__ ( "wrmsr" : : "c" ( msr ), "A" ( value ) );
36
+}
37
+
38
+#endif /* _IPXE_MSR_H */

Loading…
Cancel
Save