forked from sweoggy/AmdMsrTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmdMsrTweaker.cpp
237 lines (196 loc) · 6.89 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
* Copyright (c) Martin Kinkelin
*
* See the "License.txt" file in the root directory for infos
* about permitted and prohibited uses of this code.
*/
#include <iostream>
#include <conio.h>
#include "Info.h"
#include "Worker.h"
#include "WinRing0.h"
using std::cout;
using std::cerr;
using std::endl;
void PrintInfo(const Info& info);
void WaitForKey();
/// <summary>Entry point for the program.</summary>
int main(int argc, const char* argv[])
{
// initialize WinRing0
if (!InitializeOls() || GetDllStatus() != 0)
{
cerr << "ERROR: WinRing0 initialization failed" << endl;
DeinitializeOls();
return 1;
}
try
{
Info info;
if (!info.Initialize())
{
cout << "ERROR: unsupported CPU" << endl;
DeinitializeOls();
WaitForKey();
return 2;
}
if (argc > 1)
{
Worker worker(info);
if (!worker.ParseParams(argc, argv))
{
DeinitializeOls();
WaitForKey();
return 3;
}
worker.ApplyChanges();
}
else
{
PrintInfo(info);
WaitForKey();
}
}
catch (const std::exception& e)
{
cerr << "ERROR: " << e.what() << endl;
DeinitializeOls();
WaitForKey();
return 10;
}
DeinitializeOls();
return 0;
}
void PrintInfo(const Info& info)
{
cout << endl;
cout << "AmdMsrTweaker v2.0" << 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.Family == 0x12 )
{
cout << " BoostEnAllCores: " << info.BoostEnAllCores << endl;
cout << " IgnoreBoostThresh: " << info.IgnoreBoostThresh << 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;
}
}
cout << " * PsiVidEn = " << info.PsiVidEn << ", PsiVid = " << info.DecodeVID(info.PsiVid) << " V" << endl;
if (info.Family == 0x15)
{
cout << " ---" << endl;
int memPStateCnt[2] = { 0, 0 };
for (int i = 0; i < info.NumNBPStates; i++)
{
const NBPStateInfo pi = info.ReadNBPState(i);
if (pi.Enabled)
{
cout << " NB_P" << i << ": " << pi.Multi << "x at " << info.DecodeVID(pi.VID) << "V";
if (i == info.NBPStateHi)
cout << " [NBPStateHi]";
if (i == info.NBPStateLo)
cout << " [NBPStateLo]";
//if (i == info.NBPStateHiGPU)
// cout << " [GPU Hi]";
//if (i == info.NBPStateLoGPU)
// cout << " [GPU Lo]";
cout << endl;
if (pi.MemPState >= 0)
{
cout << " Memory in M" << pi.MemPState << endl;
memPStateCnt[pi.MemPState]++;
}
}
}
cout << " * NbPstateDis = " << info.NbPstateDis << ", NbPstateGnbSlowDis = " << info.NbPstateGnbSlowDis << ", StartupNbPstate = " << info.StartupNbPstate << endl;
cout << " * NbPsi0VidEn = " << info.NbPsi0VidEn << ", NbPsi0Vid = " << info.DecodeVID(info.NbPsi0Vid) << " V" << endl;
cout << " * NBPStateHiCPU = " << info.NBPStateHiCPU << ", NBPStateLoCPU = " << info.NBPStateLoCPU << endl;
cout << " * NBPStateHiGPU = " << info.NBPStateHiGPU << ", NBPStateLoGPU = " << info.NBPStateLoGPU << endl;
cout << " ---" << endl;
for (int i = 0; i < info.NumMemPStates; i++)
{
if (memPStateCnt[i] > 0)
{
const MemPStateInfo pi = info.ReadMemPState(i);
cout << " M" << i << ": " << pi.MemClkFreq << " MHz" << endl;
}
if (!info.IsDynMemPStateChgEnabled)
break;
}
cout << " * MemClkFreqVal(M0) = " << info.MemClkFreqVal << ", FastMstateDis(M1) = " << info.FastMstateDis << endl;
cout << " ---" << endl;
for (int i = 0; i < 8; i++)
{
const iGPUPStateInfo pi = info.ReadiGPUPState(i);
cout << " GPU_P" << i << ": StateValid = " << pi.StateValid << ", LclkDivider = " << pi.LclkDivider << ", VID = " << info.DecodeVID(pi.VID) << " V";
if (pi.StateValid == 1)
cout << " [VALID]";
cout << endl;
}
cout << " * GpuEnabled = " << info.GpuEnabled << ", SwGfxDis = " << info.SwGfxDis << ", ForceIntGfxDisable = " << info.ForceIntGfxDisable << endl;
cout << " * LclkDpmEn = " << info.LclkDpmEn << ", VoltageChgEn = " << info.VoltageChgEn << ", LclkDpmBootState = " << info.LclkDpmBootState << endl;
}
else if( info.Family == 0x12 )
{
cout << endl;
cout << ".:. RAM" << endl << "---" << endl;
DRAMInfo sticks[2];
for( int i = 0; i <= 1; ++i )
{
sticks[i] = info.ReadDRAMInfo( i );
}
cout << " Freq: " << sticks[0].Freq << "," << sticks[1].Freq << endl;
cout << " tCL: " << sticks[0].tCL << "," << sticks[1].tCL << endl;
cout << " tRCD: " << sticks[0].tRCD << "," << sticks[1].tRCD << endl;
cout << " tRP: " << sticks[0].tRP << "," << sticks[1].tRP << endl;
cout << " tRAS: " << sticks[0].tRAS << "," << sticks[1].tRAS << endl;
cout << " tRC: " << sticks[0].tRC << "," << sticks[1].tRC << endl;
cout << " tRTP: " << sticks[0].tRTP << "," << sticks[1].tRTP << endl;
cout << " tRRD: " << sticks[0].tRRD << "," << sticks[1].tRRD << endl;
cout << " tWTR: " << sticks[0].tWTR << "," << sticks[1].tWTR << endl;
cout << " tWR: " << sticks[0].tWR << "," << sticks[1].tWR << endl;
cout << " tCWL: " << sticks[0].tCWL << "," << sticks[1].tCWL << endl;
cout << " CR: " << sticks[0].CR << "," << sticks[1].CR << endl;
}
}
void WaitForKey()
{
cout << endl << "Press any key to exit... ";
_getch();
cout << endl;
}