2022-09-19 22:23:31 +02:00
|
|
|
#include "cpu.h"
|
2022-09-19 23:16:43 +02:00
|
|
|
#include "common/sysctl.h"
|
2022-09-19 22:23:31 +02:00
|
|
|
|
2023-06-12 09:56:03 +08:00
|
|
|
const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu)
|
2022-09-19 22:23:31 +02:00
|
|
|
{
|
2023-06-12 09:56:03 +08:00
|
|
|
if (ffSysctlGetString("hw.model", &cpu->name))
|
|
|
|
|
return "sysctlbyname(hw.model) failed";
|
2022-09-24 15:59:36 +02:00
|
|
|
|
2023-06-12 09:56:03 +08:00
|
|
|
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
|
|
|
|
|
cpu->coresLogical = cpu->coresPhysical;
|
|
|
|
|
cpu->coresOnline = cpu->coresPhysical;
|
|
|
|
|
|
|
|
|
|
cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0;
|
|
|
|
|
cpu->frequencyMax = cpu->frequencyMin;
|
|
|
|
|
|
|
|
|
|
if (options->temp)
|
2022-10-27 11:06:43 +08:00
|
|
|
{
|
2023-04-15 15:29:54 +08:00
|
|
|
FF_STRBUF_AUTO_DESTROY cpuTemp = ffStrbufCreate();
|
2023-06-15 09:35:47 +08:00
|
|
|
if(ffSysctlGetString("hw.acpi.thermal.tz0.temperature", &cpuTemp))
|
2022-10-27 11:06:43 +08:00
|
|
|
cpu->temperature = FF_CPU_TEMP_UNSET;
|
|
|
|
|
else
|
|
|
|
|
cpu->temperature = ffStrbufToDouble(&cpuTemp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cpu->temperature = FF_CPU_TEMP_UNSET;
|
2022-09-24 15:59:36 +02:00
|
|
|
|
2023-06-12 09:56:03 +08:00
|
|
|
return NULL;
|
2022-09-19 22:23:31 +02:00
|
|
|
}
|