summaryrefslogtreecommitdiffhomepage
path: root/pkg/cpuid/cpuid_test.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-10-26 16:54:46 -0700
committerShentubot <shentubot@google.com>2018-10-26 16:55:39 -0700
commitb15a7267e1965148731e9d379ec33154f1bb54e6 (patch)
tree089267ac8e6d8fb61f8b2e49a1162a71125ebfef /pkg/cpuid/cpuid_test.go
parente60525e4ddd9a7fff8b27d0be8119ce3203a2f5c (diff)
Add AMD-specific features to cpuid package
Extend the cpuid package to parse and emulate cpuid features that exist only on AMD and not Intel. The least straightforward part of this is that AMD duplicates several block 1 features in block 6. Thus we ignore those features when parsing block 6 and add them when emulating. PiperOrigin-RevId: 218935032 Change-Id: Id41bf1c24720b0d9b968e2c19ab5bc00a6d62bd4
Diffstat (limited to 'pkg/cpuid/cpuid_test.go')
-rw-r--r--pkg/cpuid/cpuid_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/cpuid/cpuid_test.go b/pkg/cpuid/cpuid_test.go
index 0decd8f08..35e7b8e50 100644
--- a/pkg/cpuid/cpuid_test.go
+++ b/pkg/cpuid/cpuid_test.go
@@ -18,6 +18,34 @@ import (
"testing"
)
+// These are the default values of various FeatureSet fields.
+const (
+ defaultVendorID = "GenuineIntel"
+
+ // These processor signature defaults are derived from the values
+ // listed in Intel Application Note 485 for i7/Xeon processors.
+ defaultExtFamily uint8 = 0
+ defaultExtModel uint8 = 1
+ defaultType uint8 = 0
+ defaultFamily uint8 = 0x06
+ defaultModel uint8 = 0x0a
+ defaultSteppingID uint8 = 0
+)
+
+// newEmptyFeatureSet creates a new FeatureSet with a sensible default model and no features.
+func newEmptyFeatureSet() *FeatureSet {
+ return &FeatureSet{
+ Set: make(map[Feature]bool),
+ VendorID: defaultVendorID,
+ ExtendedFamily: defaultExtFamily,
+ ExtendedModel: defaultExtModel,
+ ProcessorType: defaultType,
+ Family: defaultFamily,
+ Model: defaultModel,
+ SteppingID: defaultSteppingID,
+ }
+}
+
var justFPU = &FeatureSet{
Set: map[Feature]bool{
X86FeatureFPU: true,