blob: 04a82313d89a8310017dbff679d4821fa0af21d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/* Copyright 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __CROS_EC_CRC_H
#define __CROS_EC_CRC_H
/* CRC-32 implementation with USB constants */
/* Note: it's a stateful CRC-32 to match the hardware block interface */
#if defined(CONFIG_HW_CRC) && !defined(HOST_TOOLS_BUILD)
#include "crc_hw.h"
#else
/* Use software implementation */
/* Static context variant */
void crc32_init(void);
/**
* Calculate CRC32 of data in arbitrary length.
*
* @param buf Data for CRC32 to be calculated for.
* @param size Size of <buf> in bytes.
*/
void crc32_hash(const void *buf, int size);
void crc32_hash32(uint32_t val);
void crc32_hash16(uint16_t val);
uint32_t crc32_result(void);
/* Provided context variant */
void crc32_ctx_init(uint32_t *ctx);
/**
* Calculate CRC32 of data in arbitrary length using given context.
*
* @param crc CRC32 context.
* @param buf Data for CRC32 to be calculated for.
* @param size Size of <buf> in bytes.
*/
void crc32_ctx_hash(uint32_t *crc, const void *buf, int size);
void crc32_ctx_hash32(uint32_t *ctx, uint32_t val);
void crc32_ctx_hash16(uint32_t *ctx, uint16_t val);
void crc32_ctx_hash8(uint32_t *ctx, uint8_t val);
uint32_t crc32_ctx_result(uint32_t *ctx);
#endif /* CONFIG_HW_CRC && !HOST_TOOLS_BUILD */
#endif /* __CROS_EC_CRC_H */
|