This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
forked from mpollice/AmdMsrTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAmdMsrTweaker.cpp
151 lines (123 loc) · 3.5 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
/*
* 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 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;
}
}
}
void WaitForKey()
{
cout << endl << "Press any key to exit... ";
_getch();
cout << endl;
}