blob: d61b218b78cc9d1753c4c7d9eb0ca034f7b50c2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <msr.h>
uint64_t read_msr(uint32_t addr)
{
uint64_t eax;
uint64_t edx;
uint64_t ecx = addr;
__asm__ __volatile__("rdmsr;" : "=a"(eax), "=d"(edx) : "c"(ecx) :);
return (edx << 32) | eax;
}
void write_msr(uint32_t addr, uint64_t value)
{
uint64_t eax = value & 0xFFFFFFFF;
uint64_t edx = value >> 32;
uint64_t ecx = addr;
__asm__ __volatile__("wrmsr;" : : "a"(eax), "d"(edx), "c"(ecx) :);
}
|