Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
09e153a9
Commit
09e153a9
authored
May 24, 2021
by
Mark Dykes
Committed by
TrustedFirmware Code Review
May 24, 2021
Browse files
Merge "feat(hw_crc): add support for HW computed CRC" into integration
parents
0fd12b9e
a1cedadf
Changes
4
Hide whitespace changes
Inline
Side-by-side
common/hw_crc32.c
0 → 100644
View file @
09e153a9
/*
* Copyright (c) 2021, 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>
/* hw_crc32 - compute CRC using Arm intrinsic function
*
* This function is useful for the platforms with the CPU ARMv8.0
* (with CRC instructions supported), and onwards.
* Platforms with CPU ARMv8.0 should make sure to add a compile switch
* '-march=armv8-a+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
hw_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
;
}
include/common/hw_crc32.h
0 → 100644
View file @
09e153a9
/*
* Copyright (c) 2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef HW_CRC32_H
#define HW_CRC32_H
#include <stddef.h>
#include <stdint.h>
/* compute CRC using Arm intrinsic function */
uint32_t
hw_crc32
(
uint32_t
crc
,
const
unsigned
char
*
buf
,
size_t
size
);
#endif
/* HW_CRC32_H */
include/lib/libc/arm_acle.h
View file @
09e153a9
...
@@ -14,8 +14,10 @@
...
@@ -14,8 +14,10 @@
#define ARM_ACLE_H
#define ARM_ACLE_H
#if !defined(__aarch64__) || defined(__clang__)
#if !defined(__aarch64__) || defined(__clang__)
# define __crc32b __builtin_arm_crc32b
# define __crc32w __builtin_arm_crc32w
# define __crc32w __builtin_arm_crc32w
#else
#else
# define __crc32b __builtin_aarch64_crc32b
# define __crc32w __builtin_aarch64_crc32w
# define __crc32w __builtin_aarch64_crc32w
#endif
#endif
...
...
plat/arm/common/arm_common.mk
View file @
09e153a9
...
@@ -178,6 +178,13 @@ ifeq (${ARM_GPT_SUPPORT}, 1)
...
@@ -178,6 +178,13 @@ ifeq (${ARM_GPT_SUPPORT}, 1)
drivers/partition/partition.c
drivers/partition/partition.c
endif
endif
# Enable CRC instructions via extension for ARMv8-A CPUs.
# For ARMv8.1-A, and onwards CRC instructions are default enabled.
# Enable HW computed CRC support unconditionally in BL2 component.
ifeq
(${ARM_ARCH_MINOR},0)
BL2_CPPFLAGS
+=
-march
=
armv8-a+crc
endif
ifeq
(${ARCH}, aarch64)
ifeq
(${ARCH}, aarch64)
PLAT_INCLUDES
+=
-Iinclude
/plat/arm/common/aarch64
PLAT_INCLUDES
+=
-Iinclude
/plat/arm/common/aarch64
endif
endif
...
@@ -223,6 +230,7 @@ BL2_SOURCES += drivers/delay_timer/delay_timer.c \
...
@@ -223,6 +230,7 @@ BL2_SOURCES += drivers/delay_timer/delay_timer.c \
drivers/io/io_storage.c
\
drivers/io/io_storage.c
\
plat/arm/common/arm_bl2_setup.c
\
plat/arm/common/arm_bl2_setup.c
\
plat/arm/common/arm_err.c
\
plat/arm/common/arm_err.c
\
common/hw_crc32.c
\
${ARM_IO_SOURCES}
${ARM_IO_SOURCES}
# Firmware Configuration Framework sources
# Firmware Configuration Framework sources
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment