diff options
| -rw-r--r-- | mos/sys/inc/arch/x86_64/msr.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mos/sys/inc/arch/x86_64/msr.h b/mos/sys/inc/arch/x86_64/msr.h index 4ccf3c8..5c3e1d1 100644 --- a/mos/sys/inc/arch/x86_64/msr.h +++ b/mos/sys/inc/arch/x86_64/msr.h @@ -6,6 +6,8 @@ #ifndef _MACHINE_MSR_H_ #define _MACHINE_MSR_H_ 1 +#include <sdk/defs.h> + #define IA32_APIC_BASE 0x0000001B #define IA32_GS_BASE 0xC0000101 #define IA32_MTRR_CAP 0x000000FE @@ -15,4 +17,37 @@ #define IA32_KERNEL_GS_BASE 0xC0000102 #define IA32_EFER 0xC0000080 +#ifndef __ASSEMBLER__ +ALWAYS_INLINE static inline void +md_wrmsr(ULONG msr, UQUAD v) +{ + ULONG lo, hi; + + lo = v & 0xFFFFFFFF; + hi = (v >> 32) & 0xFFFFFFFF; + + ASM( + "wrmsr" + : + : "c" (msr), "a" (lo), "d" (hi) + : "memory" + ); +} + +ALWAYS_INLINE static inline UQUAD +md_rdmsr(ULONG msr) +{ + ULONG lo, hi; + + ASM( + "rdmsr" + : "=a" (lo), "=d" (hi) + : "c" (msr) + : "memory" + ); + + return ((UQUAD)hi << 32) | lo; +} + +#endif /* !__ASSEMBLER__ */ #endif /* !_MACHINE_MSR_H_ */ |
