mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
CPU (Haiku): add support
This commit is contained in:
+1
-1
@@ -1103,7 +1103,7 @@ elseif(Haiku)
|
||||
src/detection/brightness/brightness_nosupport.c
|
||||
src/detection/btrfs/btrfs_nosupport.c
|
||||
src/detection/chassis/chassis_nosupport.c
|
||||
src/detection/cpu/cpu_nosupport.c
|
||||
src/detection/cpu/cpu_haiku.c
|
||||
src/detection/cpucache/cpucache_nosupport.c
|
||||
src/detection/cpuusage/cpuusage_nosupport.c
|
||||
src/detection/cursor/cursor_nosupport.c
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "cpu.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <OS.h>
|
||||
#include <private/shared/cpu_type.h>
|
||||
|
||||
const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
{
|
||||
system_info sysInfo;
|
||||
if (get_system_info(&sysInfo) != B_OK)
|
||||
return "get_system_info() failed";
|
||||
|
||||
uint32_t topoNodeCount = 0;
|
||||
get_cpu_topology_info(NULL, &topoNodeCount);
|
||||
if (topoNodeCount == 0)
|
||||
return "get_cpu_topology_info(NULL) failed";
|
||||
|
||||
FF_AUTO_FREE cpu_topology_node_info* topology = malloc(sizeof(*topology) * topoNodeCount);
|
||||
if (get_cpu_topology_info(topology, &topoNodeCount) != B_OK)
|
||||
return "get_cpu_topology_info(topology) failed";
|
||||
|
||||
enum cpu_platform platform = B_CPU_UNKNOWN;
|
||||
enum cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN;
|
||||
uint32 cpuModel = 0, frequency = 0;
|
||||
uint16_t packages = 0, cores = 0;
|
||||
|
||||
for (uint32 i = 0; i < topoNodeCount; i++)
|
||||
{
|
||||
switch (topology[i].type) {
|
||||
case B_TOPOLOGY_ROOT:
|
||||
platform = topology[i].data.root.platform;
|
||||
break;
|
||||
|
||||
case B_TOPOLOGY_PACKAGE:
|
||||
cpuVendor = topology[i].data.package.vendor;
|
||||
++packages;
|
||||
break;
|
||||
|
||||
case B_TOPOLOGY_CORE:
|
||||
cpuModel = topology[i].data.core.model;
|
||||
uint32_t freq = (uint32_t) (topology[i].data.core.default_frequency / 1000000);
|
||||
frequency = freq > frequency ? freq : frequency;
|
||||
++cores;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *model = get_cpu_model_string(platform, cpuVendor, cpuModel);
|
||||
if (model)
|
||||
ffStrbufSetS(&cpu->name, model);
|
||||
else
|
||||
ffStrbufSetF(&cpu->name, "(Unknown %" B_PRIx32 ")", cpuModel);
|
||||
ffStrbufSetS(&cpu->vendor, get_cpu_vendor_string(cpuVendor));
|
||||
|
||||
ffCPUDetectSpeedByCpuid(cpu);
|
||||
if (cpu->frequencyBase < frequency) cpu->frequencyBase = frequency;
|
||||
cpu->packages = packages;
|
||||
cpu->coresPhysical = cores;
|
||||
cpu->coresOnline = cpu->coresLogical = (uint16_t) sysInfo.cpu_count;
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user