forked from dankamongmen/x86info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdmsr.c
40 lines (35 loc) · 776 Bytes
/
rdmsr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Licensed under the terms of the GNU GPL License version 2.
*
* Generic routines for reading MSRs.
*/
#include <stdio.h>
#include <x86info.h>
void dumpmsr(int cpu, unsigned int msr, int size)
{
unsigned long long val=0;
if (read_msr(cpu, msr, &val) == 1) {
if (size == 32){
printf("MSR: 0x%08x=0x%08lx : ", msr, (unsigned long) val);
binary32(val);
}
if (size == 64) {
printf("MSR: 0x%08x=0x%016llx : ", msr, val);
binary64(val);
}
return;
}
printf("Couldn't read MSR 0x%x\n", msr);
}
void dumpmsr_bin(int cpu, unsigned int msr, int size)
{
unsigned long long val=0;
if (read_msr(cpu, msr, &val) == 1) {
if (size == 32)
binary32(val);
if (size == 64)
binary64(val);
return;
}
printf("Couldn't read MSR 0x%x\n", msr);
}