Add support for displaying the ISA string on RISC-V CPUs

This commit is contained in:
Aaron Franke 2023-01-08 00:14:21 -06:00
parent 117bc7738c
commit 70690c50df
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF

View file

@ -2587,6 +2587,18 @@ get_cpu() {
[[ -z "$cpu" ]] && cpu="$(awk -F':' '/family/ {printf $2; exit}' "$cpu_file")"
;;
"riscv"* | "rv"*)
cpu_uarch="$(awk -F':' '/uarch/ {print $2; exit}' "$cpu_file")"
# RISC-V ISA string example: "rv64imafdch_zicsr_zifencei".
cpu_isa="$(awk -F':' '/isa/ {print $2; exit}' "$cpu_file")"
# The _z parts are not important for CPU showcasing, so we remove them.
cpu_isa="${cpu_isa%%_*}"
# Then we replace "imafd" with "g" since "g" is a shorthand.
cpu_isa="${cpu_isa/imafd/g}"
# The final ISA output of the above example is "rv64gch".
cpu="$cpu_uarch $cpu_isa"
;;
"arm"* | "aarch64")
if [[ $(trim "$distro") == Android* ]]; then
# Android roms have modified cpuinfo that shows CPU model as a string