Patchwork [U-Boot,07/15] x86: Add functions to access MSRs

login
register
mail settings
Submitter Simon Glass
Date Oct. 24, 2012, 4:04 a.m.
Message ID <1351051486-6980-8-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/193660/
State Superseded, archived
Delegated to: Simon Glass
Headers show

Comments

Simon Glass - Oct. 24, 2012, 4:04 a.m.
From: Stefan Reinauer <reinauer@chromium.org>

Provide basic functions to access these registers.

Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/x86/include/asm/msr.h |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/msr.h

Patch

diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
new file mode 100644
index 0000000..0a681d1
--- /dev/null
+++ b/arch/x86/include/asm/msr.h
@@ -0,0 +1,25 @@ 
+#ifndef CPU_X86_ASM_MSR_H
+#define CPU_X86_ASM_MSR_H
+
+static inline uint64_t rdmsr(unsigned index)
+{
+	uint64_t result;
+
+	asm volatile (
+		"rdmsr"
+		: "=A" (result)
+		: "c" (index)
+		);
+	return result;
+}
+
+static inline void wrmsr(unsigned index, uint64_t msr)
+{
+	asm volatile (
+		"wrmsr"
+		: /* No outputs */
+		: "c" (index), "A" (msr)
+		);
+}
+
+#endif /* CPU_X86_ASM_MSR_H */