-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathAmdMsrTweaker.cpp
107 lines (85 loc) · 3.36 KB
/
AmdMsrTweaker.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Copyright (c) Martin Kinkelin
*
* See the "License.txt" file in the root directory for infos
* about permitted and prohibited uses of this code.
*/
#include <cstdio>
#include <iostream>
#include "Info.h"
#include "Worker.h"
#include "WinRing0.h"
using std::cout;
using std::cerr;
using std::endl;
void PrintInfo(const Info& info);
/// <summary>Entry point for the program.</summary>
int main(int argc, const char* argv[]) {
try {
Info info;
if (!info.Initialize()) {
cout << "ERROR: unsupported CPU" << endl;
return 2;
}
if (argc > 1) {
Worker worker(info);
if (!worker.ParseParams(argc, argv)) {
return 3;
}
worker.ApplyChanges();
} else {
PrintInfo(info);
}
} catch (const std::exception& e) {
cerr << "ERROR: " << e.what() << endl;
return 10;
}
return 0;
}
void PrintInfo(const Info& info) {
cout << endl;
cout << "AmdMsrTweaker v1.1" << endl;
cout << endl;
cout << ".:. General" << endl << "---" << endl;
cout << " AMD family 0x" << std::hex << info.Family << ", model 0x" << info.Model << std::dec << " CPU, " << info.NumCores << " cores" << endl;
cout << " Default reference clock: " << info.multiScaleFactor * 100 << " MHz" << endl;
cout << " Available multipliers: " << (info.MinMulti / info.multiScaleFactor) << " .. " << (info.MaxSoftwareMulti / info.multiScaleFactor) << endl;
cout << " Available voltage IDs: " << info.MinVID << " .. " << info.MaxVID << " (" << info.VIDStep << " steps)" << endl;
cout << endl;
cout << ".:. Turbo" << endl << "---" << endl;
if (!info.IsBoostSupported)
cout << " not supported" << endl;
else {
cout << " " << (info.IsBoostEnabled ? "enabled" : "disabled") << endl;
cout << " " << (info.IsBoostLocked ? "locked" : "unlocked") << endl;
if (info.MaxMulti != info.MaxSoftwareMulti)
cout << " Max multiplier: " << (info.MaxMulti / info.multiScaleFactor) << endl;
}
cout << endl;
cout << ".:. P-states" << endl << "---" << endl;
cout << " " << info.NumPStates << " of " << (info.Family == 0x10 ? 5 : 8) << " enabled (P0 .. P" << (info.NumPStates - 1) << ")" << endl;
if (info.IsBoostSupported && info.NumBoostStates > 0) {
cout << " Turbo P-states:";
for (int i = 0; i < info.NumBoostStates; i++)
cout << " P" << i;
cout << endl;
}
cout << " ---" << endl;
for (int i = 0; i < info.NumPStates; i++) {
const PStateInfo pi = info.ReadPState(i);
cout << " P" << i << ": " << (pi.Multi / info.multiScaleFactor) << "x at " << info.DecodeVID(pi.VID) << "V" << endl;
if (pi.NBPState >= 0) {
cout << " NorthBridge in NB_P" << pi.NBPState;
if (pi.NBVID >= 0)
cout << " at " << info.DecodeVID(pi.NBVID) << "V";
cout << endl;
}
}
if (info.Family == 0x15) {
cout << " ---" << endl;
for (int i = 0; i < info.NumNBPStates; i++) {
const NBPStateInfo pi = info.ReadNBPState(i);
cout << " NB_P" << i << ": " << pi.Multi << "x at " << info.DecodeVID(pi.VID) << "V" << endl;
}
}
}