Julian Hall | d635ad7 | 2022-09-20 15:50:35 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef COMMON_CRC32_H |
| 8 | #define COMMON_CRC32_H |
| 9 | |
| 10 | #include <stddef.h> |
| 11 | #include <stdint.h> |
| 12 | |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | /** |
Balint Dobszay | 550ce87 | 2022-12-15 15:28:40 +0100 | [diff] [blame] | 18 | * \brief Initialize CRC32 to use HW acceleration if available |
| 19 | */ |
| 20 | void crc32_init(void); |
| 21 | |
| 22 | /** |
Julian Hall | d635ad7 | 2022-09-20 15:50:35 +0100 | [diff] [blame] | 23 | * \brief Calculate a CRC32 over the provided data |
| 24 | * |
Balint Dobszay | 550ce87 | 2022-12-15 15:28:40 +0100 | [diff] [blame] | 25 | * \param[in] crc_prev The starting CRC for previous data |
| 26 | * \param[in] buf The buffer to calculate the CRC over |
| 27 | * \param[in] size Number of bytes in the buffer |
Julian Hall | d635ad7 | 2022-09-20 15:50:35 +0100 | [diff] [blame] | 28 | * |
| 29 | * \return The calculated CRC32 |
| 30 | */ |
Balint Dobszay | 550ce87 | 2022-12-15 15:28:40 +0100 | [diff] [blame] | 31 | extern uint32_t (*crc32)(uint32_t crc_prev, const uint8_t *buf, size_t size); |
Julian Hall | d635ad7 | 2022-09-20 15:50:35 +0100 | [diff] [blame] | 32 | |
| 33 | #ifdef __cplusplus |
| 34 | } |
| 35 | #endif |
| 36 | |
| 37 | #endif /* COMMON_CRC32_H */ |