Pyrogenesis
13997
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
source
lib
sysdep
arch
x86_x64
msr.cpp
Go to the documentation of this file.
1
/* Copyright (c) 2010 Wildfire Games
2
*
3
* Permission is hereby granted, free of charge, to any person obtaining
4
* a copy of this software and associated documentation files (the
5
* "Software"), to deal in the Software without restriction, including
6
* without limitation the rights to use, copy, modify, merge, publish,
7
* distribute, sublicense, and/or sell copies of the Software, and to
8
* permit persons to whom the Software is furnished to do so, subject to
9
* the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included
12
* in all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
*/
22
23
#include "precompiled.h"
24
#include "
lib/sysdep/arch/x86_x64/msr.h
"
25
26
#include "
lib/sysdep/os/win/mahaf.h
"
27
#include "
lib/sysdep/arch/x86_x64/x86_x64.h
"
28
29
30
namespace
MSR {
31
32
bool
IsAccessible
()
33
{
34
if
(!
x86_x64::Cap
(
x86_x64::CAP_MSR
))
35
return
false
;
36
37
// only read/writable from ring 0, so we need the driver.
38
if
(
mahaf_Init
() < 0)
39
return
false
;
40
41
return
true
;
42
}
43
44
45
bool
HasEnergyPerfBias
()
46
{
47
#if 1
48
// the documentation is unclear. until it improves, disable
49
// this, lest we provoke a GPF.
50
return
false
;
51
#else
52
if
(
x86_x64::Vendor
() !=
x86_x64::VENDOR_INTEL
)
53
return
false
;
54
55
if
(
x86_x64::Family
() < 6)
56
return
false
;
57
58
if
(
x86_x64::Model
() < 0xE)
59
return
false
;
60
61
return
true
;
62
#endif
63
}
64
65
66
bool
HasPlatformInfo
()
67
{
68
if
(
x86_x64::Vendor
() !=
x86_x64::VENDOR_INTEL
)
69
return
false
;
70
71
if
(
x86_x64::Family
() != 6)
72
return
false
;
73
74
switch
(
x86_x64::Model
())
75
{
76
// section 34.4 in 253665-041US
77
case
x86_x64::MODEL_NEHALEM_EP
:
78
case
x86_x64::MODEL_NEHALEM_EP_2
:
79
case
x86_x64::MODEL_NEHALEM_EX
:
80
case
x86_x64::MODEL_I7_I5
:
81
return
true
;
82
83
// section 34.5
84
case
x86_x64::MODEL_CLARKDALE
:
85
case
x86_x64::MODEL_WESTMERE_EP
:
86
return
true
;
87
88
// section 34.6
89
case
x86_x64::MODEL_WESTMERE_EX
:
90
return
true
;
91
92
// section 34.7
93
case
x86_x64::MODEL_SANDY_BRIDGE
:
94
case
x86_x64::MODEL_SANDY_BRIDGE_2
:
95
return
true
;
96
97
default
:
98
return
false
;
99
}
100
}
101
102
103
bool
HasUncore
()
104
{
105
if
(
x86_x64::Vendor
() !=
x86_x64::VENDOR_INTEL
)
106
return
false
;
107
108
if
(
x86_x64::Family
() != 6)
109
return
false
;
110
111
switch
(
x86_x64::Model
())
112
{
113
// Xeon 5500 / i7 (section B.4.1 in 253669-037US)
114
case
0x1A:
// Bloomfield, Gainstown
115
case
0x1E:
// Clarksfield, Lynnfield, Jasper Forest
116
case
0x1F:
117
return
true
;
118
119
// Xeon 5600 / Westmere (section B.5)
120
case
0x25:
// Clarkdale, Arrandale
121
case
0x2C:
// Gulftown
122
return
true
;
123
124
default
:
125
return
false
;
126
}
127
}
128
129
130
u64
Read
(
u64
reg)
131
{
132
return
mahaf_ReadModelSpecificRegister
(reg);
133
}
134
135
136
void
Write
(
u64
reg,
u64
value)
137
{
138
mahaf_WriteModelSpecificRegister
(reg, value);
139
}
140
141
}
// namespace MSR
x86_x64::CAP_MSR
Definition:
x86_x64.h:123
mahaf_Init
Status mahaf_Init()
Definition:
mahaf.cpp:390
MSR::HasUncore
bool HasUncore()
Definition:
msr.cpp:103
MSR::IsAccessible
bool IsAccessible()
Definition:
msr.cpp:32
x86_x64::MODEL_WESTMERE_EX
Definition:
x86_x64.h:90
x86_x64::MODEL_SANDY_BRIDGE
Definition:
x86_x64.h:91
mahaf.h
x86_x64::Vendor
Vendors Vendor()
Definition:
x86_x64.cpp:200
x86_x64::VENDOR_INTEL
Definition:
x86_x64.h:75
x86_x64::MODEL_CLARKDALE
Definition:
x86_x64.h:87
mahaf_WriteModelSpecificRegister
void mahaf_WriteModelSpecificRegister(u64 reg, u64 value)
Definition:
mahaf.cpp:181
x86_x64::MODEL_NEHALEM_EP_2
Definition:
x86_x64.h:85
mahaf_ReadModelSpecificRegister
u64 mahaf_ReadModelSpecificRegister(u64 reg)
Definition:
mahaf.cpp:171
x86_x64::MODEL_WESTMERE_EP
Definition:
x86_x64.h:88
MSR::HasPlatformInfo
bool HasPlatformInfo()
Definition:
msr.cpp:66
x86_x64::MODEL_NEHALEM_EX
Definition:
x86_x64.h:89
u64
#define u64
Definition:
types.h:42
x86_x64::Cap
bool Cap(Caps cap)
Definition:
x86_x64.cpp:142
MSR::HasEnergyPerfBias
bool HasEnergyPerfBias()
Definition:
msr.cpp:45
MSR::Read
u64 Read(u64 reg)
Definition:
msr.cpp:130
x86_x64::Family
size_t Family()
Definition:
x86_x64.cpp:238
x86_x64::MODEL_SANDY_BRIDGE_2
Definition:
x86_x64.h:92
x86_x64::MODEL_NEHALEM_EP
Definition:
x86_x64.h:84
MSR::Write
void Write(u64 reg, u64 value)
Definition:
msr.cpp:136
x86_x64::MODEL_I7_I5
Definition:
x86_x64.h:86
msr.h
x86_x64::Model
size_t Model()
Definition:
x86_x64.cpp:232
x86_x64.h
Generated on Mon Oct 14 2013 00:58:07 for Pyrogenesis by
1.8.5