Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 1 | /* |
| 2 | *========================================================================== |
| 3 | * |
| 4 | * crc.h |
| 5 | * |
| 6 | * Interface for the CRC algorithms. |
| 7 | * |
| 8 | *========================================================================== |
Wolfgang Denk | fb7f006 | 2013-07-08 12:11:35 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: eCos-2.0 |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 10 | *========================================================================== |
| 11 | *#####DESCRIPTIONBEGIN#### |
| 12 | * |
| 13 | * Author(s): Andrew Lunn |
| 14 | * Contributors: Andrew Lunn |
| 15 | * Date: 2002-08-06 |
| 16 | * Purpose: |
| 17 | * Description: |
| 18 | * |
| 19 | * This code is part of eCos (tm). |
| 20 | * |
| 21 | *####DESCRIPTIONEND#### |
| 22 | * |
| 23 | *========================================================================== |
| 24 | */ |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 25 | |
| 26 | #ifndef _SERVICES_CRC_CRC_H_ |
| 27 | #define _SERVICES_CRC_CRC_H_ |
| 28 | |
| 29 | #include <linux/types.h> |
| 30 | |
| 31 | #ifndef __externC |
| 32 | # ifdef __cplusplus |
| 33 | # define __externC extern "C" |
| 34 | # else |
| 35 | # define __externC extern |
| 36 | # endif |
| 37 | #endif |
| 38 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 39 | /* Compute a CRC, using the POSIX 1003 definition */ |
| 40 | extern uint32_t |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 41 | cyg_posix_crc32(unsigned char *s, int len); |
| 42 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 43 | /* Gary S. Brown's 32 bit CRC */ |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 44 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 45 | extern uint32_t |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 46 | cyg_crc32(unsigned char *s, int len); |
| 47 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 48 | /* Gary S. Brown's 32 bit CRC, but accumulate the result from a */ |
| 49 | /* previous CRC calculation */ |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 50 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 51 | extern uint32_t |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 52 | cyg_crc32_accumulate(uint32_t crc, unsigned char *s, int len); |
| 53 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 54 | /* Ethernet FCS Algorithm */ |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 55 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 56 | extern uint32_t |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 57 | cyg_ether_crc32(unsigned char *s, int len); |
| 58 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 59 | /* Ethernet FCS algorithm, but accumulate the result from a previous */ |
| 60 | /* CRC calculation. */ |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 61 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 62 | extern uint32_t |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 63 | cyg_ether_crc32_accumulate(uint32_t crc, unsigned char *s, int len); |
| 64 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 65 | /* 16 bit CRC with polynomial x^16+x^12+x^5+1 */ |
Markus Klotzbuecher | 387f541 | 2006-03-30 13:40:55 +0200 | [diff] [blame] | 66 | |
| 67 | extern uint16_t cyg_crc16(unsigned char *s, int len); |
| 68 | |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 69 | #endif /* _SERVICES_CRC_CRC_H_ */ |