cpuid 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/cpuid/cpuid.rb +43 -7
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/cpuid/cpuid.rb
CHANGED
@@ -14,12 +14,15 @@ module CPUID
|
|
14
14
|
BRAND_STR_FN_1 = 0x80000002
|
15
15
|
BRAND_STR_FN_2 = 0x80000003
|
16
16
|
BRAND_STR_FN_3 = 0x80000004
|
17
|
+
EXT_L2_FN = 0x80000006
|
18
|
+
POWER_MANAGEMENT_FN = 0x80000007
|
17
19
|
ADDRESS_SIZE_FN = 0x80000008
|
18
20
|
|
19
|
-
INTEL_SYSCALL_CHECK_BIT = 1 <<
|
20
|
-
INTEL_XD_CHECK_BIT = 1 <<
|
21
|
-
INTEL_64_CHECK_BIT = 1 <<
|
21
|
+
INTEL_SYSCALL_CHECK_BIT = 1 << 11
|
22
|
+
INTEL_XD_CHECK_BIT = 1 << 20
|
23
|
+
INTEL_64_CHECK_BIT = 1 << 29
|
22
24
|
INTEL_LAHF_CHECK_BIT = 1
|
25
|
+
INTEL_TSC_INVARIANCE_CHECK_BIT = 1 << 7
|
23
26
|
##
|
24
27
|
# Returns the model information of the processor, which can be used
|
25
28
|
# for telling individual processors apart. Note: you will need to use
|
@@ -130,7 +133,7 @@ module CPUID
|
|
130
133
|
#
|
131
134
|
# @return [Boolean]
|
132
135
|
def has_syscall?
|
133
|
-
|
136
|
+
(run_function(EXT_FEATURE_FN)[3] & INTEL_SYSCALL_CHECK_BIT) > 0
|
134
137
|
end
|
135
138
|
|
136
139
|
##
|
@@ -138,7 +141,7 @@ module CPUID
|
|
138
141
|
#
|
139
142
|
# @return [Boolean]
|
140
143
|
def has_xd_bit?
|
141
|
-
|
144
|
+
(run_function(EXT_FEATURE_FN)[3] & INTEL_XD_CHECK_BIT) > 0
|
142
145
|
end
|
143
146
|
|
144
147
|
##
|
@@ -146,7 +149,7 @@ module CPUID
|
|
146
149
|
#
|
147
150
|
# @return [Boolean]
|
148
151
|
def has_lahf?
|
149
|
-
|
152
|
+
(run_function(EXT_FEATURE_FN)[2] & INTEL_LAHF_CHECK_BIT) > 0
|
150
153
|
end
|
151
154
|
|
152
155
|
##
|
@@ -154,11 +157,44 @@ module CPUID
|
|
154
157
|
#
|
155
158
|
# @return [Boolean] does the processor support x86_64?
|
156
159
|
def has_x64?
|
157
|
-
|
160
|
+
(run_function(EXT_FEATURE_FN)[3] & INTEL_64_CHECK_BIT) > 0
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# Returns whether the processor supports TSC invariance.
|
165
|
+
#
|
166
|
+
# I honestly don't know what this is, but it's in the intel spec.
|
167
|
+
def has_tsc_invariance?
|
168
|
+
(run_function(POWER_MANAGEMENT_FN).last & INTEL_TSC_INVARIANCE_CHECK_BIT) > 0
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Access L2 information via the extended function, 0x80000006.
|
173
|
+
def easy_L2_info
|
174
|
+
ecx = run_function(SIGNATURE_FEATURES_FN)[2]
|
175
|
+
assoc_bits = ((ecx >> 12) & 0xF)
|
176
|
+
assoc = {}
|
177
|
+
case assoc_bits
|
178
|
+
when 0x0
|
179
|
+
assoc[:disabled] = true
|
180
|
+
when 0xF
|
181
|
+
assoc[:fully_associative] = true
|
182
|
+
else
|
183
|
+
assoc[:direct_mapped] = true if assoc_bits & 0x1 > 0
|
184
|
+
assoc[:sixteen_way] = true if assoc_bits & 0x8 > 0
|
185
|
+
assoc[:eight_way] = true if assoc_bits & 0x6 > 0
|
186
|
+
assoc[:four_way] = true if assoc_bits & 0x4 > 0
|
187
|
+
assoc[:two_way] = true if assoc_bits & 0x2 > 0
|
188
|
+
end
|
189
|
+
{:line_size => ecx & 0xFF, :cache_size => (ecx >> 16) * 1024, :associativity => assoc}
|
158
190
|
end
|
159
191
|
|
160
192
|
#private
|
161
193
|
|
194
|
+
def supports_easy_L2?
|
195
|
+
EXT_L2_FN <= max_extended_param
|
196
|
+
end
|
197
|
+
|
162
198
|
def signature
|
163
199
|
@signature ||= run_function(SIGNATURE_FEATURES_FN).first
|
164
200
|
end
|