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