summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-11-12 22:42:18 -0700
committerSimon Glass <sjg@chromium.org>2014-11-21 07:34:13 +0100
commiteddbad224b9e0e6834f946f587923f27e54abb69 (patch)
tree06c2b369d774ed0d05ec851f8d697624a65e5e04
parent3f70a6f5773432c83429e33dbc062812113b1c50 (diff)
downloadu-boot-imx-eddbad224b9e0e6834f946f587923f27e54abb69.zip
u-boot-imx-eddbad224b9e0e6834f946f587923f27e54abb69.tar.gz
u-boot-imx-eddbad224b9e0e6834f946f587923f27e54abb69.tar.bz2
x86: Add msr read/write functions that use a structure
It is convenient to be able to adjust MSRs with a structure that splits the two 32-bit halves into separate fields, as they are often dealt with separately. Add a few functions to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--arch/x86/include/asm/msr.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 3b5915d..df43983 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -175,6 +175,25 @@ static inline int wrmsr_safe_regs(u32 regs[8])
return native_wrmsr_safe_regs(regs);
}
+typedef struct msr_t {
+ uint32_t lo;
+ uint32_t hi;
+} msr_t;
+
+static inline struct msr_t msr_read(unsigned msr_num)
+{
+ struct msr_t msr;
+
+ rdmsr(msr_num, msr.lo, msr.hi);
+
+ return msr;
+}
+
+static inline void msr_write(unsigned msr_num, msr_t msr)
+{
+ wrmsr(msr_num, msr.lo, msr.hi);
+}
+
#define rdtscl(low) \
((low) = (u32)__native_read_tsc())