MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / FillMIDRInformationViaLinux

Function FillMIDRInformationViaLinux

Source/Common/HostFeatures.cpp:16–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace FEX {
15
16void FillMIDRInformationViaLinux(FEXCore::HostFeatures* Features) {
17 auto Cores = FEX::CPUInfo::CalculateNumberOfCPUs();
18 Features->CPUMIDRs.resize(Cores);
19#ifdef _M_ARM_64
20 for (size_t i = 0; i < Cores; ++i) {
21 std::error_code ec {};
22 fextl::string MIDRPath = fextl::fmt::format("/sys/devices/system/cpu/cpu{}/regs/identification/midr_el1", i);
23 std::array<char, 18> Data;
24 // Needs to be a fixed size since depending on kernel it will try to read a full page of data and fail
25 // Only read 18 bytes for a 64bit value prefixed with 0x
26 if (FEXCore::FileLoading::LoadFileToBuffer(MIDRPath, Data) == sizeof(Data)) {
27 uint64_t MIDR {};
28 auto Results = std::from_chars(Data.data() + 2, Data.data() + sizeof(Data), MIDR, 16);
29 if (Results.ec == std::errc()) {
30 // Truncate to 32-bits, top 32-bits are all reserved in MIDR
31 Features->CPUMIDRs[i] = static_cast<uint32_t>(MIDR);
32 }
33 }
34 }
35#endif
36}
37
38#ifdef _M_ARM_64
39#define GetSysReg(name, reg) \

Callers 1

FetchHostFeaturesFunction · 0.85

Calls 3

CalculateNumberOfCPUsFunction · 0.85
formatFunction · 0.85
LoadFileToBufferFunction · 0.85

Tested by

no test coverage detected