[*] move kGetByPartID / kSetByImpl for different arm oses

[+] some more arm vendors
This commit is contained in:
Reece Wilson 2024-12-19 01:43:00 +00:00
parent e7871473e7
commit 3c18dfb4ef

View File

@ -471,6 +471,141 @@ namespace Aurora::HWInfo
bool bHasSpecialRegisters {}; bool bHasSpecialRegisters {};
static const auto kGetByPartID = [](AuUInt32 uPartID) -> AuROString
{
static const AuBST<AuUInt16, AuROString> kCPUMap = {
{ 0x810, "ARM810" },
{ 0x920, "ARM920" },
{ 0x922, "ARM922" },
{ 0x926, "ARM926" },
{ 0x940, "ARM940" },
{ 0x946, "ARM946" },
{ 0x966, "ARM966" },
{ 0xa20, "ARM1020" },
{ 0xa22, "ARM1022" },
{ 0xa26, "ARM1026" },
{ 0xb02, "ARM11 MPCore" },
{ 0xb36, "ARM1136" },
{ 0xb56, "ARM1156" },
{ 0xb76, "ARM1176" },
{ 0xc05, "Cortex-A5" },
{ 0xc07, "Cortex-A7" },
{ 0xc08, "Cortex-A8" },
{ 0xc09, "Cortex-A9" },
{ 0xc0d, "Cortex-A17" },
{ 0xc0f, "Cortex-A15" },
{ 0xc0e, "Cortex-A17" },
{ 0xc14, "Cortex-R4" },
{ 0xc15, "Cortex-R5" },
{ 0xc17, "Cortex-R7" },
{ 0xc18, "Cortex-R8" },
{ 0xc20, "Cortex-M0" },
{ 0xc21, "Cortex-M1" },
{ 0xc23, "Cortex-M3" },
{ 0xc24, "Cortex-M4" },
{ 0xc27, "Cortex-M7" },
{ 0xc60, "Cortex-M0+" },
{ 0xd01, "Cortex-A32" },
{ 0xd02, "Cortex-A34" },
{ 0xd03, "Cortex-A53" },
{ 0xd04, "Cortex-A35" },
{ 0xd05, "Cortex-A55" },
{ 0xd06, "Cortex-A65" },
{ 0xd07, "Cortex-A57" },
{ 0xd08, "Cortex-A72" },
{ 0xd09, "Cortex-A73" },
{ 0xd0a, "Cortex-A75" },
{ 0xd0b, "Cortex-A76" },
{ 0xd0c, "Neoverse-N1" },
{ 0xd0d, "Cortex-A77" },
{ 0xd0e, "Cortex-A76AE" },
{ 0xd13, "Cortex-R52" },
{ 0xd20, "Cortex-M23" },
{ 0xd21, "Cortex-M33" },
{ 0xd40, "Neoverse-V1" },
{ 0xd41, "Cortex-A78" },
{ 0xd42, "Cortex-A78AE" },
{ 0xd43, "Cortex-A65AE" },
{ 0xd44, "Cortex-X1" },
{ 0xd46, "Cortex-A510" },
{ 0xd47, "Cortex-A710" },
{ 0xd48, "Cortex-X2" },
{ 0xd49, "Neoverse-N2" },
{ 0xd4a, "Neoverse-E1" },
{ 0xd4b, "Cortex-A78C" },
{ 0xd4c, "Cortex-X1C" },
{ 0xd4d, "Cortex-A715" },
{ 0xd4e, "Cortex-X3"}
};
auto itr = kCPUMap.find(uPartID);
if (itr != kCPUMap.end())
{
return itr->second;
}
else
{
return {};
}
};
static const auto kSetByImpl = [](AuUInt32 uVendorID)
{
if (uVendorID == 0x41)
{
gCpuInfo.cpuId.vendor = "Arm Holdings Plc";
}
if (uVendorID == 0x61)
{
// yea, i'm not calling you "Apple Inc"
// <turn your brand into a religion.webp>
// i'm thinking, no, you're still a terrible computer company and will be addressed as such.
gCpuInfo.cpuId.vendor = "Apple Computer, Inc";
}
if (uVendorID == 0x51)
{
// finally, a respectable company.
gCpuInfo.cpuId.vendor = "Qualcomm Technologies Inc";
}
if (uVendorID == 0x42)
{
// welp, that lasted long.
gCpuInfo.cpuId.vendor = "Broadcom Inc";
}
if (uVendorID == 0xc0)
{
// 2 more weeks. we believe in you.
gCpuInfo.cpuId.vendor = "Ampere Computing LLC";
}
if (uVendorID == 0x46)
{
// guess we're playing blockgame on toasters now.
gCpuInfo.cpuId.vendor = "Fujitsu Ltd";
}
if (uVendorID == 0x4e)
{
// worthy of note, most nvidia products idnt as 0x41.
gCpuInfo.cpuId.vendor = "Nvidia Corporation";
}
if (uVendorID == 0x48)
{
// calm down, mcmutts.
gCpuInfo.cpuId.vendor = "Huawei Technologies Co., Ltd";
}
if (uVendorID == 0x56)
{
gCpuInfo.cpuId.vendor = "Marvell International Ltd";
}
if (uVendorID == 0x43)
{
gCpuInfo.cpuId.vendor = "Cavium Inc";
}
if (uVendorID == 0x49)
{
gCpuInfo.cpuId.vendor = "Infineon Technologies AG";
}
};
// https://boringssl.googlesource.com/boringssl/+/master/crypto/cpu_aarch64_sysreg.cc#21 // https://boringssl.googlesource.com/boringssl/+/master/crypto/cpu_aarch64_sysreg.cc#21
// https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registers.txt // https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registers.txt
#if defined(__FreeBSD__) || defined(AURORA_PLATFORM_KERNEL_LINUX) || (defined(AURORA_IS_LINUX_DERIVED) && defined(HWCAP_CPUID)) #if defined(__FreeBSD__) || defined(AURORA_PLATFORM_KERNEL_LINUX) || (defined(AURORA_IS_LINUX_DERIVED) && defined(HWCAP_CPUID))
@ -519,6 +654,7 @@ namespace Aurora::HWInfo
#endif #endif
// TODO: read mainid register via MRC p15, 0, <Rt>, c0, c0, 0
// unused? linux proposal // unused? linux proposal
#if defined(AURORA_IS_LINUX_DERIVED) #if defined(AURORA_IS_LINUX_DERIVED)
@ -1078,131 +1214,45 @@ namespace Aurora::HWInfo
if (optImplementer) if (optImplementer)
{ {
auto uVendorID = optImplementer.value(); auto uVendorID = optImplementer.value();
kSetByImpl(uVendorID);
if (uVendorID == 0x41)
{
// nice company stamp you got there.
// you don't get to idnt as a british company after a chinese man stole your ip & wont let you do anything besides lolsuit qualcomm.
gCpuInfo.cpuId.vendor = "Arm Holdings 有限公司";
}
if (uVendorID == 0x61)
{
// yea, i'm not calling you "Apple Inc"
// <turn your brand into a religion.webp>
// i'm thinking, no, you're still a terrible computer company and will be addressed as such.
gCpuInfo.cpuId.vendor = "Apple Computer, Inc";
}
if (uVendorID == 0x51)
{
// finally, a respectable company.
gCpuInfo.cpuId.vendor = "Qualcomm Technologies Inc";
}
if (uVendorID == 0x42 || uVendorID == 0x43)
{
// welp, that lasted long.
gCpuInfo.cpuId.vendor = "Broadcom Inc";
}
if (uVendorID == 0xc0)
{
// 2 more weeks. we believe in you.
gCpuInfo.cpuId.vendor = "Ampere Computing LLC";
}
if (uVendorID == 0x46)
{
// guess we're playing blockgame on toasters now.
gCpuInfo.cpuId.vendor = "Fujitsu Ltd";
}
if (uVendorID == 0x4e)
{
// worthy of note, most nvidia products idnt as 0x41.
gCpuInfo.cpuId.vendor = "Nvidia Corporation";
}
if (uVendorID == 0x48)
{
// calm down, mcmutts.
gCpuInfo.cpuId.vendor = "Huawei Technologies Co., Ltd";
}
} }
} }
if (AuStartsWith(line, "CPU part:")) if (AuStartsWith(line, "CPU part:"))
{ {
static const AuBST<AuUInt16, AuROString> kDriveMap = {
{ 0x810, "ARM810" },
{ 0x920, "ARM920" },
{ 0x922, "ARM922" },
{ 0x926, "ARM926" },
{ 0x940, "ARM940" },
{ 0x946, "ARM946" },
{ 0x966, "ARM966" },
{ 0xa20, "ARM1020" },
{ 0xa22, "ARM1022" },
{ 0xa26, "ARM1026" },
{ 0xb02, "ARM11 MPCore" },
{ 0xb36, "ARM1136" },
{ 0xb56, "ARM1156" },
{ 0xb76, "ARM1176" },
{ 0xc05, "Cortex-A5" },
{ 0xc07, "Cortex-A7" },
{ 0xc08, "Cortex-A8" },
{ 0xc09, "Cortex-A9" },
{ 0xc0d, "Cortex-A17" },
{ 0xc0f, "Cortex-A15" },
{ 0xc0e, "Cortex-A17" },
{ 0xc14, "Cortex-R4" },
{ 0xc15, "Cortex-R5" },
{ 0xc17, "Cortex-R7" },
{ 0xc18, "Cortex-R8" },
{ 0xc20, "Cortex-M0" },
{ 0xc21, "Cortex-M1" },
{ 0xc23, "Cortex-M3" },
{ 0xc24, "Cortex-M4" },
{ 0xc27, "Cortex-M7" },
{ 0xc60, "Cortex-M0+" },
{ 0xd01, "Cortex-A32" },
{ 0xd02, "Cortex-A34" },
{ 0xd03, "Cortex-A53" },
{ 0xd04, "Cortex-A35" },
{ 0xd05, "Cortex-A55" },
{ 0xd06, "Cortex-A65" },
{ 0xd07, "Cortex-A57" },
{ 0xd08, "Cortex-A72" },
{ 0xd09, "Cortex-A73" },
{ 0xd0a, "Cortex-A75" },
{ 0xd0b, "Cortex-A76" },
{ 0xd0c, "Neoverse-N1" },
{ 0xd0d, "Cortex-A77" },
{ 0xd0e, "Cortex-A76AE" },
{ 0xd13, "Cortex-R52" },
{ 0xd20, "Cortex-M23" },
{ 0xd21, "Cortex-M33" },
{ 0xd40, "Neoverse-V1" },
{ 0xd41, "Cortex-A78" },
{ 0xd42, "Cortex-A78AE" },
{ 0xd43, "Cortex-A65AE" },
{ 0xd44, "Cortex-X1" },
{ 0xd46, "Cortex-A510" },
{ 0xd47, "Cortex-A710" },
{ 0xd48, "Cortex-X2" },
{ 0xd49, "Neoverse-N2" },
{ 0xd4a, "Neoverse-E1" },
{ 0xd4b, "Cortex-A78C" },
{ 0xd4c, "Cortex-X1C" },
{ 0xd4d, "Cortex-A715" },
{ 0xd4e, "Cortex-X3"} };
auto optImplementer = AuParse::ParseUInt16(line.SubStr(9)); auto optImplementer = AuParse::ParseUInt16(line.SubStr(9));
if (optImplementer) if (optImplementer)
{ {
auto itr = kDriveMap.find(optImplementer.value()); lookUp = kGetByPartID(optImplementer.value());
if (itr != kDriveMap.end())
{
lookUp = itr->second;
}
} }
} }
}); });
if (gCpuInfo.cpuId.brand.empty())
{
AuString hm;
if (AuFS::ReadString("/proc/device-tree/model", hm))
{
gCpuInfo.cpuId.brand = hm;
}
}
if (AuCodepointsStartsWithIgnoreCase(gCpuInfo.cpuId.brand, "NVIDIA"))
{
gCpuInfo.cpuId.vendor = "Nvidia Corporation";
}
else
{
AuString nvCont;
if (AuFS::ReadString("/proc/device-tree/compatible", nvCont))
{
if (AuCodepointsStartsWithIgnoreCase(nvCont, "NVIDIA"))
{
gCpuInfo.cpuId.vendor = "Nvidia Corporation";
}
}
}
if (!lookUp.Empty()) if (!lookUp.Empty())
{ {
if (gCpuInfo.cpuId.brand.empty()) if (gCpuInfo.cpuId.brand.empty())