1*f2841d37SMarkus Klotzbuecher //========================================================================== 2*f2841d37SMarkus Klotzbuecher // 3*f2841d37SMarkus Klotzbuecher // crc.h 4*f2841d37SMarkus Klotzbuecher // 5*f2841d37SMarkus Klotzbuecher // Interface for the CRC algorithms. 6*f2841d37SMarkus Klotzbuecher // 7*f2841d37SMarkus Klotzbuecher //========================================================================== 8*f2841d37SMarkus Klotzbuecher //####ECOSGPLCOPYRIGHTBEGIN#### 9*f2841d37SMarkus Klotzbuecher // ------------------------------------------- 10*f2841d37SMarkus Klotzbuecher // This file is part of eCos, the Embedded Configurable Operating System. 11*f2841d37SMarkus Klotzbuecher // Copyright (C) 2002 Andrew Lunn 12*f2841d37SMarkus Klotzbuecher // 13*f2841d37SMarkus Klotzbuecher // eCos is free software; you can redistribute it and/or modify it under 14*f2841d37SMarkus Klotzbuecher // the terms of the GNU General Public License as published by the Free 15*f2841d37SMarkus Klotzbuecher // Software Foundation; either version 2 or (at your option) any later version. 16*f2841d37SMarkus Klotzbuecher // 17*f2841d37SMarkus Klotzbuecher // eCos is distributed in the hope that it will be useful, but WITHOUT ANY 18*f2841d37SMarkus Klotzbuecher // WARRANTY; without even the implied warranty of MERCHANTABILITY or 19*f2841d37SMarkus Klotzbuecher // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20*f2841d37SMarkus Klotzbuecher // for more details. 21*f2841d37SMarkus Klotzbuecher // 22*f2841d37SMarkus Klotzbuecher // You should have received a copy of the GNU General Public License along 23*f2841d37SMarkus Klotzbuecher // with eCos; if not, write to the Free Software Foundation, Inc., 24*f2841d37SMarkus Klotzbuecher // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 25*f2841d37SMarkus Klotzbuecher // 26*f2841d37SMarkus Klotzbuecher // As a special exception, if other files instantiate templates or use macros 27*f2841d37SMarkus Klotzbuecher // or inline functions from this file, or you compile this file and link it 28*f2841d37SMarkus Klotzbuecher // with other works to produce a work based on this file, this file does not 29*f2841d37SMarkus Klotzbuecher // by itself cause the resulting work to be covered by the GNU General Public 30*f2841d37SMarkus Klotzbuecher // License. However the source code for this file must still be made available 31*f2841d37SMarkus Klotzbuecher // in accordance with section (3) of the GNU General Public License. 32*f2841d37SMarkus Klotzbuecher // 33*f2841d37SMarkus Klotzbuecher // This exception does not invalidate any other reasons why a work based on 34*f2841d37SMarkus Klotzbuecher // this file might be covered by the GNU General Public License. 35*f2841d37SMarkus Klotzbuecher // 36*f2841d37SMarkus Klotzbuecher // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. 37*f2841d37SMarkus Klotzbuecher // at http://sources.redhat.com/ecos/ecos-license/ 38*f2841d37SMarkus Klotzbuecher // ------------------------------------------- 39*f2841d37SMarkus Klotzbuecher //####ECOSGPLCOPYRIGHTEND#### 40*f2841d37SMarkus Klotzbuecher //========================================================================== 41*f2841d37SMarkus Klotzbuecher //#####DESCRIPTIONBEGIN#### 42*f2841d37SMarkus Klotzbuecher // 43*f2841d37SMarkus Klotzbuecher // Author(s): Andrew Lunn 44*f2841d37SMarkus Klotzbuecher // Contributors: Andrew Lunn 45*f2841d37SMarkus Klotzbuecher // Date: 2002-08-06 46*f2841d37SMarkus Klotzbuecher // Purpose: 47*f2841d37SMarkus Klotzbuecher // Description: 48*f2841d37SMarkus Klotzbuecher // 49*f2841d37SMarkus Klotzbuecher // This code is part of eCos (tm). 50*f2841d37SMarkus Klotzbuecher // 51*f2841d37SMarkus Klotzbuecher //####DESCRIPTIONEND#### 52*f2841d37SMarkus Klotzbuecher // 53*f2841d37SMarkus Klotzbuecher //========================================================================== 54*f2841d37SMarkus Klotzbuecher 55*f2841d37SMarkus Klotzbuecher #ifndef _SERVICES_CRC_CRC_H_ 56*f2841d37SMarkus Klotzbuecher #define _SERVICES_CRC_CRC_H_ 57*f2841d37SMarkus Klotzbuecher 58*f2841d37SMarkus Klotzbuecher #include <linux/types.h> 59*f2841d37SMarkus Klotzbuecher 60*f2841d37SMarkus Klotzbuecher #ifndef __externC 61*f2841d37SMarkus Klotzbuecher # ifdef __cplusplus 62*f2841d37SMarkus Klotzbuecher # define __externC extern "C" 63*f2841d37SMarkus Klotzbuecher # else 64*f2841d37SMarkus Klotzbuecher # define __externC extern 65*f2841d37SMarkus Klotzbuecher # endif 66*f2841d37SMarkus Klotzbuecher #endif 67*f2841d37SMarkus Klotzbuecher 68*f2841d37SMarkus Klotzbuecher // Compute a CRC, using the POSIX 1003 definition 69*f2841d37SMarkus Klotzbuecher extern uint32_t 70*f2841d37SMarkus Klotzbuecher cyg_posix_crc32(unsigned char *s, int len); 71*f2841d37SMarkus Klotzbuecher 72*f2841d37SMarkus Klotzbuecher // Gary S. Brown's 32 bit CRC 73*f2841d37SMarkus Klotzbuecher 74*f2841d37SMarkus Klotzbuecher extern uint32_t 75*f2841d37SMarkus Klotzbuecher cyg_crc32(unsigned char *s, int len); 76*f2841d37SMarkus Klotzbuecher 77*f2841d37SMarkus Klotzbuecher // Gary S. Brown's 32 bit CRC, but accumulate the result from a 78*f2841d37SMarkus Klotzbuecher // previous CRC calculation 79*f2841d37SMarkus Klotzbuecher 80*f2841d37SMarkus Klotzbuecher extern uint32_t 81*f2841d37SMarkus Klotzbuecher cyg_crc32_accumulate(uint32_t crc, unsigned char *s, int len); 82*f2841d37SMarkus Klotzbuecher 83*f2841d37SMarkus Klotzbuecher // Ethernet FCS Algorithm 84*f2841d37SMarkus Klotzbuecher 85*f2841d37SMarkus Klotzbuecher extern uint32_t 86*f2841d37SMarkus Klotzbuecher cyg_ether_crc32(unsigned char *s, int len); 87*f2841d37SMarkus Klotzbuecher 88*f2841d37SMarkus Klotzbuecher // Ethernet FCS algorithm, but accumulate the result from a previous 89*f2841d37SMarkus Klotzbuecher // CRC calculation. 90*f2841d37SMarkus Klotzbuecher 91*f2841d37SMarkus Klotzbuecher extern uint32_t 92*f2841d37SMarkus Klotzbuecher cyg_ether_crc32_accumulate(uint32_t crc, unsigned char *s, int len); 93*f2841d37SMarkus Klotzbuecher 94*f2841d37SMarkus Klotzbuecher // 16 bit CRC with polynomial x^16+x^12+x^5+1 95*f2841d37SMarkus Klotzbuecher 96*f2841d37SMarkus Klotzbuecher extern uint16_t cyg_crc16(unsigned char *s, int len); 97*f2841d37SMarkus Klotzbuecher 98*f2841d37SMarkus Klotzbuecher #endif // _SERVICES_CRC_CRC_H_ 99*f2841d37SMarkus Klotzbuecher 100*f2841d37SMarkus Klotzbuecher 101*f2841d37SMarkus Klotzbuecher 102