Skip to content

Commit

Permalink
imp - Used ARM implementer list (Linux)
Browse files Browse the repository at this point in the history
---

We've supported for more ARM CPU names.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 17, 2024
1 parent a25b4b5 commit e5fd6b5
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions SpecProbe/Probers/ProcessorProber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,16 @@ public static ProcessorPart ProbeLinux(out Exception[] errors)
uint cacheL1 = 0;
uint cacheL2 = 0;
uint cacheL3 = 0;
string name = "";
string name = "ARM Processor";
string cpuidVendor = "";
string hypervisorVendor = "";
double clockSpeed = 0.0;
string[] features = [];

// ARM-specific variables
string armVendorId = "";
string armPartId = "";

// Some constants
const string physicalId = "physical id\t: ";
const string logicalId = "processor\t: ";
Expand All @@ -176,6 +180,7 @@ public static ProcessorPart ProbeLinux(out Exception[] errors)
const string processorNum = "processor\t: ";
const string armProcessorName = "Processor\t: ";
const string armVendorName = "CPU implementer\t: ";
const string armPartName = "CPU part\t: ";

try
{
Expand Down Expand Up @@ -208,18 +213,11 @@ public static ProcessorPart ProbeLinux(out Exception[] errors)

// Get the processor vendor
if (cpuInfoLine.StartsWith(armVendorName))
{
string armVendorId = cpuInfoLine.Replace(armVendorName, "");
armVendorId = armVendorId.Substring(2);
int armVendorIdInt = int.Parse(armVendorId, NumberStyles.AllowHexSpecifier);
cpuidVendor = armVendorIdInt switch
{
0x41 => "ARM",
_ => "",
};
if (string.IsNullOrEmpty(name))
name = "ARM Processor";
}
armVendorId = cpuInfoLine.Replace(armVendorName, "").Substring(2);

// Get the processor part
if (cpuInfoLine.StartsWith(armPartName))
armPartId = cpuInfoLine.Replace(armPartName, "").Substring(2);
}
else
{
Expand Down Expand Up @@ -311,6 +309,31 @@ public static ProcessorPart ProbeLinux(out Exception[] errors)
cacheL3 = uint.Parse(cacheKilobytes) * 1024;
}
}

// If running on ARM, get the CPU implementer and part names
if (PlatformHelper.IsOnArmOrArm64() && !string.IsNullOrEmpty(armVendorId) && !string.IsNullOrEmpty(armPartId))
{
int armVendorIdInt = int.Parse(armVendorId, NumberStyles.AllowHexSpecifier);
int armPartIdInt = int.Parse(armPartId, NumberStyles.AllowHexSpecifier);
cpuidVendor = "";
name = $"ARM Processor [V: {armVendorIdInt:X2}, P: {armPartIdInt:X3}]";

// Get the implementer and the part
foreach (var implementer in ArmImplementers.implementers)
{
if (implementer == null)
continue;
if (implementer.id == armVendorIdInt)
{
cpuidVendor = implementer.name;
foreach (var part in implementer.parts)
{
if (part.id == armPartIdInt)
name = part.name;
}
}
}
}
}
catch (Exception ex)
{
Expand Down

0 comments on commit e5fd6b5

Please sign in to comment.