Dr-Noob / cpufetch

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

[FreeBSD][Apple] Implement fallback frequency calculation #251

Open er2off opened 3 weeks ago

er2off commented 3 weeks ago

This PR is a recreation of #232 because seems like @Dr-Noob is now ready to merge it.

github-actions[bot] commented 3 weeks ago

cpufetch does not accept pull requests, see the contributing guidelines for details

Dr-Noob commented 3 weeks ago

General question, why is this needed? Have you found a x86 CPU which does not get the frequency reported when using FreeBSD and macOS? Which CPU is that?

er2off commented 3 weeks ago

Which CPU is that?

For me it's AMD Ryzen 5 3500, it reports Can't read frequency information from cpuid (needed level is 0x00000016, max is 0x00000010).

Dr-Noob commented 3 weeks ago

Which CPU is that?

For me it's AMD Ryzen 5 3500, it reports Can't read frequency information from cpuid (needed level is 0x00000016, max is 0x00000010).

I see, makes sense. Then please have a look at my review comment.

er2off commented 2 weeks ago

I see, makes sense. Then please have a look at my review comment.

Maybe I don't understood something but referenced commit nor next commits doesn't change anything for x86/amd64.

(kinda offtopic for this issue) BTW cpufetch doesn't work on ARM64 FreeBSD (because nobody ported) and u-boot doesn't expose many information about CPU, some related sysctls for rpi3b are

hw.fdt.compatible: raspberrypi,3-model-b brcm,bcm2837
hw.fdt.model: Raspberry Pi 3 Model B Rev 1.2
hw.machine: arm64
hw.model: ARM Cortex-A53 r0p4
hw.ncpu: 4
hw.byteorder: 1234
hw.machine_arch: aarch64

(neofetch on this platform simply says hw.model value which doesn't represent real cpu name)

Dr-Noob commented 2 weeks ago

I see, makes sense. Then please have a look at my review comment.

Maybe I don't understood something but referenced commit nor next commits doesn't change anything for x86/amd64.

There is no visible change in x86. What changed is the fact that you can now include src/common/sysctl.h in src/x86/cpuid.c and use get_sys_info_by_name instead of sysctlbyname directly.

(kinda offtopic for this issue) BTW cpufetch doesn't work on ARM64 FreeBSD (because nobody ported) and u-boot doesn't expose many information about CPU, some related sysctls for rpi3b are

hw.fdt.compatible: raspberrypi,3-model-b brcm,bcm2837
hw.fdt.model: Raspberry Pi 3 Model B Rev 1.2
hw.machine: arm64
hw.model: ARM Cortex-A53 r0p4
hw.ncpu: 4
hw.byteorder: 1234
hw.machine_arch: aarch64

(neofetch on this platform simply says hw.model value which doesn't represent real cpu name)

Regarding what you mention about ARM64 in FreeBSD, if you have a proper error message from cpufetch please open an issue and we'll see what can be done to support it :+1: .