Extract MIDR using CPUID information that are exposed to user-space * * @param[in] max_num_cpus Maximum number of possible CPUs * * @return std::vector A list of the MIDR of each core */
| 89 | * @return std::vector<uint32_t> A list of the MIDR of each core |
| 90 | */ |
| 91 | std::vector<uint32_t> midr_from_cpuid(uint32_t max_num_cpus) |
| 92 | { |
| 93 | std::vector<uint32_t> cpus; |
| 94 | for (unsigned int i = 0; i < max_num_cpus; ++i) |
| 95 | { |
| 96 | std::stringstream str; |
| 97 | str << "/sys/devices/system/cpu/cpu" << i << "/regs/identification/midr_el1"; |
| 98 | std::ifstream file(str.str(), std::ios::in); |
| 99 | if (file.is_open()) |
| 100 | { |
| 101 | std::string line; |
| 102 | if (bool(getline(file, line))) |
| 103 | { |
| 104 | cpus.emplace_back(support::cpp11::stoul(line, nullptr, support::cpp11::NumericBase::BASE_16)); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | return cpus; |
| 109 | } |
| 110 | |
| 111 | /** Extract MIDR by parsing the /proc/cpuinfo meta-data |
| 112 | * |