Dr-Noob / cpufetch

Simple yet fancy CPU architecture fetching tool
GNU General Public License v2.0
1.82k stars 99 forks source link

Refactor Apple SoC detection #213

Open Dr-Noob opened 6 months ago

Dr-Noob commented 6 months ago

guess_soc_apple and get_cpu_info_mach need refactoring since they'll probably keep releasing more and more chips. Also asahilinux has a very good tracking of the MIDR values which we should replicate since currently we are setting the same MIDR for all CPU types within a family (M1/M2/M3) which is incorrect. Instead we should follow this.

Also fix this: // Must be M1 in src/arm/midr.c

Also fill_cpu_info_XXX_XXX is not maintainable.

Dr-Noob commented 5 months ago

Even more neccesary after d221f578b79b40ffbb3284f61a62bc1de36bbb84

ThomasKaiser commented 5 months ago

BTW: since I had an aarch64 Linux VM running on my MacBook below the output. Wouldn't it be an idea to print Virtualized Apple Silicon in such situations?

Apple's Hypervisor.Framework limits CPU features/flags to the one of M1's cores and sets the stepping info to r0p0 on all cores regardless of their real stepping. So it should be easy to detect such an environment?

[root@fedora # /usr/local/src/cpufetch/cpufetch 
[ERROR]: Unknown microarchitecture detected: IM=0x0 P=0x0 V=0x0 R=0x0
[VERSION]: cpufetch v1.04-42-g0967 (Linux ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            Microarchitecture:   Unknown
                                                            Max Frequency:       Unknown
                                                            Cores:               8 cores
                                                            Features:            NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    Unknown

[root@fedora # /usr/local/src/cpufetch/cpufetch -d
[ERROR]: Unknown microarchitecture detected: IM=0x0 P=0x0 V=0x0 R=0x0
[VERSION]: cpufetch v1.04-42-g0967 (Linux ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
cpufetch v1.04-42-g0967 (Linux ARM build)
[Core 0] 0x000F0000 -1 MHz
[Core 1] 0x000F0000 -1 MHz
[Core 2] 0x000F0000 -1 MHz
[Core 3] 0x000F0000 -1 MHz
[Core 4] 0x000F0000 -1 MHz
[Core 5] 0x000F0000 -1 MHz
[Core 6] 0x000F0000 -1 MHz
[Core 7] 0x000F0000 -1 MHz

[root@fedora # /usr/local/src/cpufetch/cpufetch -v
[WARNING]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 0. This is probably because the core is offline
[WARNING]: Could not open '/sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 1. This is probably because the core is offline
[WARNING]: Could not open '/sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 2. This is probably because the core is offline
[WARNING]: Could not open '/sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 3. This is probably because the core is offline
[WARNING]: Could not open '/sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 4. This is probably because the core is offline
[WARNING]: Could not open '/sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 5. This is probably because the core is offline
[WARNING]: Could not open '/sys/devices/system/cpu/cpu6/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 6. This is probably because the core is offline
[WARNING]: Could not open '/sys/devices/system/cpu/cpu7/cpufreq/cpuinfo_max_freq'
[WARNING]: Unable to fetch max frequency for core 7. This is probably because the core is offline
[ERROR]: Unknown microarchitecture detected: IM=0x0 P=0x0 V=0x0 R=0x0
[VERSION]: cpufetch v1.04-42-g0967 (Linux ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
[WARNING]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'
[WARNING]: SoC detection failed using /proc/cpuinfo: No string found
[WARNING]: read_file: /sys/bus/nvmem/devices/rockchip-efuse0/nvmem: No such file or directory
[WARNING]: read_file: /sys/bus/nvmem/devices/rockchip-otp0/nvmem: No such file or directory

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            Microarchitecture:   Unknown
                                                            Max Frequency:       Unknown
                                                            Cores:               8 cores
                                                            Features:            NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    Unknown