aboutsummaryrefslogtreecommitdiff
path: root/gprofng/common/cpuid.c
diff options
context:
space:
mode:
Diffstat (limited to 'gprofng/common/cpuid.c')
-rw-r--r--gprofng/common/cpuid.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gprofng/common/cpuid.c b/gprofng/common/cpuid.c
index af15439..891d547 100644
--- a/gprofng/common/cpuid.c
+++ b/gprofng/common/cpuid.c
@@ -42,6 +42,11 @@ __get_cpuid (unsigned int op ATTRIBUTE_UNUSED, unsigned int *eax,
Tprintf (DBG_LT0, "cpuid.c:%d read_cpuid_id() MIDR_EL1=0x%016x\n", __LINE__, *eax);
return res;
}
+#elif defined(__riscv)
+#include <sched.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <asm/hwprobe.h>
#endif
/*
@@ -180,6 +185,28 @@ get_cpuid_info ()
cpi->cpi_model += CPI_MODEL_XTD (regs.eax) << 4;
break;
}
+#elif defined(__riscv)
+ #ifndef __riscv_hwprobe
+ cpi->cpi_vendor = 0;
+ cpi->cpi_family = 0;
+ cpi->cpi_model = 0;
+ #else
+ struct riscv_hwprobe res;
+ res.key = RISCV_HWPROBE_KEY_MVENDORID;
+ cpu_set_t cpu_set;
+ int __riscv_hwprobe (struct riscv_hwprobe *pairs, \
+ long pair_count, long cpu_count, \
+ unsigned long *cpus, unsigned long flags) \
+ {
+ return syscall(__NR_riscv_hwprobe, pairs, pair_count, cpu_count, cpus, flags);
+ }
+ CPU_ZERO(&cpu_set);
+ CPU_SET(0, &cpu_set);
+ long ret = __riscv_hwprobe(&res, 1, 1, &cpu_set, 0);
+ cpi->cpi_vendor = res.value;
+ cpi->cpi_family = 0;
+ cpi->cpi_model = 0;
+ #endif
#endif
return cpi;
}