Add support for using the Armv8-A CRC32 feature
The Armv8-A architecture specifies a CRC32 hardware feature, it can be
used through an intrinsic specified by ACLE. However, the HW feature is
mandatory only starting from v8.1, so for v8.0 CPUs we have to check its
availability. This commit implements a mechanism to do this check for
both Linux and SP environments, and override the default software CRC32
implementation when the HW feature is present.
Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Change-Id: Ia15fe1db9890b8aa076deec44c71639a4382cb35
diff --git a/components/common/crc32/component.cmake b/components/common/crc32/component.cmake
new file mode 100644
index 0000000..4628b7f
--- /dev/null
+++ b/components/common/crc32/component.cmake
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+if (NOT DEFINED TGT)
+ message(FATAL_ERROR "mandatory parameter TGT is not defined.")
+endif()
+
+target_sources(${TGT} PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/crc32.c"
+)
+
+if (TS_ENV STREQUAL "arm-linux")
+ target_sources(${TGT} PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/crc32_linux.c"
+ )
+endif()
+
+if ((TS_ENV STREQUAL "opteesp") OR (TS_ENV STREQUAL "sp"))
+ target_sources(${TGT} PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/crc32_sp.c"
+ )
+endif()