14 lines
336 B
C++
14 lines
336 B
C++
|
#include "common/msr.h"
|
||
|
|
||
|
uint64_t GetMSR(uint32_t msr) {
|
||
|
uint32_t lo, hi;
|
||
|
asm("rdmsr" : "=a"(lo), "=d"(hi) : "c"(msr));
|
||
|
return (static_cast<uint64_t>(hi) << 32) | lo;
|
||
|
}
|
||
|
|
||
|
void SetMSR(uint32_t msr, uint64_t val) {
|
||
|
uint32_t lo = static_cast<uint32_t>(val);
|
||
|
uint32_t hi = val >> 32;
|
||
|
asm("wrmsr" ::"a"(lo), "d"(hi), "c"(msr));
|
||
|
}
|