Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle RISC-V CPU Manufacturer and Brand using uarch in /proc/cpuinfo #904

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/cpu.js
Expand Up @@ -605,6 +605,9 @@ function cpuManufacturer(str) {
if (str.indexOf('Xen') >= 0) { result = 'Xen Hypervisor'; }
if (str.indexOf('tcg') >= 0) { result = 'QEMU'; }
if (str.indexOf('apple') >= 0) { result = 'Apple'; }
if (str.indexOf('sifive') >= 0) { result = 'SiFive'; }
if (str.indexOf('thead') >= 0) { result = 'T-Head'; }
if (str.indexOf('andestech') >= 0) { result = 'Andes Technology'; }

return result;
}
Expand Down Expand Up @@ -788,6 +791,17 @@ function getCpu() {
}
}

// Test RISC-V
if (util.getValue(lines, 'architecture') === 'riscv64') {
const linesRiscV = fs.readFileSync('/proc/cpuinfo').toString().split('\n');
const uarch = util.getValue(linesRiscV, 'uarch') || '';
if (uarch.indexOf(',') > -1) {
const split = uarch.split(',');
result.manufacturer = cpuManufacturer(split[0]);
result.brand = split[1];
}
}

// socket type
let lines2 = [];
exec('export LC_ALL=C; dmidecode –t 4 2>/dev/null | grep "Upgrade: Socket"; unset LC_ALL', function (error2, stdout2) {
Expand Down