From b15a7267e1965148731e9d379ec33154f1bb54e6 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 26 Oct 2018 16:54:46 -0700 Subject: 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 --- pkg/cpuid/cpuid_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'pkg/cpuid/cpuid_test.go') 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, -- cgit v1.2.3