View | Details | Raw Unified | Return to bug 235994
Collapse All | Expand All

(-)devel/cpu_features/Makefile (-2 / +2 lines)
Lines 3-9 Link Here
3
PORTNAME=	cpu_features
3
PORTNAME=	cpu_features
4
PORTVERSION=	0.2.0
4
PORTVERSION=	0.2.0
5
DISTVERSIONPREFIX=	v
5
DISTVERSIONPREFIX=	v
6
PORTREVISION=	1
6
PORTREVISION=	2
7
CATEGORIES=	devel
7
CATEGORIES=	devel
8
8
9
MAINTAINER=	skreuzer@FreeBSD.org
9
MAINTAINER=	skreuzer@FreeBSD.org
Lines 11-17 Link Here
11
11
12
LICENSE=	APACHE20
12
LICENSE=	APACHE20
13
13
14
NOT_FOR_ARCHS=		aarch64 armv6 armv7 mips mips64
14
NOT_FOR_ARCHS=		armv6 armv7 mips mips64
15
NOT_FOR_ARCHS_REASON=	assumes android if on ARM or MIPS
15
NOT_FOR_ARCHS_REASON=	assumes android if on ARM or MIPS
16
16
17
USES=	cmake:insource
17
USES=	cmake:insource
(-)devel/cpu_features/files/patch-src-cpuinfo__aarch64.c (+67 lines)
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
 }

Return to bug 235994