Files
arm-trusted-firmware/common/tf_crc32.c
T
Boyan Karatotev fb0c409889 fix(build): use ARM_ARCH_FEATURE instead of -march directly
The -march compiler flag is owned by make_helpers/march.mk and its
output is controlled by ARM_ARCH_MAJOR, ARM_ARCH_MINOR, and
ARM_ARCH_FEATURE. Setting -march directly can lead to unexpected results
when using the above flags and is generally not recommended within tfa.

This patch migrates all instances of -march=armv8-a+crc to
ARM_ARCH_FEATURE=crc. Arm platforms (via arm_common.mk) are checked and
those that support cores greater than arm8.1 do not get the flag as it
is automatically pulled in.

Change-Id: I846f97367eab9529524a2805d5b87d34cce2360f
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
2026-01-05 09:22:09 +00:00

45 lines
996 B
C

/*
* Copyright (c) 2021-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdarg.h>
#include <assert.h>
#include <arm_acle.h>
#include <common/debug.h>
#include <common/tf_crc32.h>
/* compute CRC using Arm intrinsic function
*
* This function is useful for platforms with FEAT_CRC32 (mandatory from v8.1)
* Platforms with CPU ARMv8.0 should make sure to add a make switch
* `ARM_ARCH_FEATURE := crc` for successful compilation of this file.
*
* @crc: previous accumulated CRC
* @buf: buffer base address
* @size: the size of the buffer
*
* Return calculated CRC value
*/
uint32_t tf_crc32(uint32_t crc, const unsigned char *buf, size_t size)
{
assert(buf != NULL);
uint32_t calc_crc = ~crc;
const unsigned char *local_buf = buf;
size_t local_size = size;
/*
* calculate CRC over byte data
*/
while (local_size != 0UL) {
calc_crc = __crc32b(calc_crc, *local_buf);
local_buf++;
local_size--;
}
return ~calc_crc;
}