Line 0
Link Here
|
|
|
1 |
--- src/cpuinfo_aarch64.c.orig 2019-03-18 12:13:19.292580000 +0100 |
2 |
+++ src/cpuinfo_aarch64.c 2019-03-18 12:13:54.601426000 +0100 |
3 |
@@ -22,6 +22,11 @@ |
4 |
|
5 |
#include <ctype.h> |
6 |
|
7 |
+#if defined (__FreeBSD__) |
8 |
+#include <sys/types.h> |
9 |
+#include <machine/armreg.h> |
10 |
+#endif |
11 |
+ |
12 |
DECLARE_SETTER(Aarch64Features, fp) |
13 |
DECLARE_SETTER(Aarch64Features, asimd) |
14 |
DECLARE_SETTER(Aarch64Features, aes) |
15 |
@@ -79,6 +84,44 @@ static void FillProcCpuInfoData(Aarch64Info* const inf |
16 |
static const Aarch64Info kEmptyAarch64Info; |
17 |
|
18 |
Aarch64Info GetAarch64Info(void) { |
19 |
+#if defined (__FreeBSD__) |
20 |
+ |
21 |
+ Aarch64Info info = kEmptyAarch64Info; |
22 |
+ uint64_t id_aa64isar0, id_aa64pfr0; |
23 |
+ id_aa64isar0 = READ_SPECIALREG(ID_AA64ISAR0_EL1); |
24 |
+ id_aa64pfr0 = READ_SPECIALREG(ID_AA64PFR0_EL1); |
25 |
+ |
26 |
+ if (ID_AA64ISAR0_AES(id_aa64isar0) == ID_AA64ISAR0_AES_BASE) { |
27 |
+ info.features.aes = 1; |
28 |
+ } |
29 |
+ |
30 |
+ if (ID_AA64ISAR0_AES(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL) { |
31 |
+ info.features.pmull = 1; |
32 |
+ } |
33 |
+ |
34 |
+ if (ID_AA64ISAR0_SHA1(id_aa64isar0) == ID_AA64ISAR0_SHA1_BASE) { |
35 |
+ info.features.sha1 = 1; |
36 |
+ } |
37 |
+ |
38 |
+ if (ID_AA64ISAR0_SHA2(id_aa64isar0) == ID_AA64ISAR0_SHA2_BASE) { |
39 |
+ info.features.sha2 = 1; |
40 |
+ } |
41 |
+ |
42 |
+ if (ID_AA64ISAR0_CRC32(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE) { |
43 |
+ info.features.crc32 = 1; |
44 |
+ } |
45 |
+ |
46 |
+ if (ID_AA64PFR0_ADV_SIMD(id_aa64pfr0) == ID_AA64PFR0_ADV_SIMD_IMPL || \ |
47 |
+ ID_AA64PFR0_ADV_SIMD(id_aa64pfr0) == ID_AA64PFR0_ADV_SIMD_HP ) { |
48 |
+ info.features.asimd = 1; |
49 |
+ } |
50 |
+ |
51 |
+ if (ID_AA64PFR0_FP(id_aa64pfr0) == ID_AA64PFR0_FP_IMPL || \ |
52 |
+ ID_AA64PFR0_FP(id_aa64pfr0) == ID_AA64PFR0_FP_HP) { |
53 |
+ info.features.fp = 1; |
54 |
+ } |
55 |
+ |
56 |
+#else // linux |
57 |
// capabilities are fetched from both getauxval and /proc/cpuinfo so we can |
58 |
// have some information if the executable is sandboxed (aka no access to |
59 |
// /proc/cpuinfo). |
60 |
@@ -88,6 +131,7 @@ Aarch64Info GetAarch64Info(void) { |
61 |
CpuFeatures_OverrideFromHwCaps(kConfigsSize, kConfigs, |
62 |
CpuFeatures_GetHardwareCapabilities(), |
63 |
&info.features); |
64 |
+#endif |
65 |
|
66 |
return info; |
67 |
} |