ftape-ecc.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef _FTAPE_ECC_H_
  2. #define _FTAPE_ECC_H_
  3. /*
  4.  *      Copyright (C) 1993 Ning and David Mosberger.
  5.  *      Original:
  6.  *      Copyright (C) 1993 Bas Laarhoven.
  7.  *      Copyright (C) 1992 David L. Brown, Jr.
  8.  
  9.  This program is free software; you can redistribute it and/or
  10.  modify it under the terms of the GNU General Public License as
  11.  published by the Free Software Foundation; either version 2, or (at
  12.  your option) any later version.
  13.  
  14.  This program is distributed in the hope that it will be useful, but
  15.  WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.  General Public License for more details.
  18.  
  19.  You should have received a copy of the GNU General Public License
  20.  along with this program; see the file COPYING.  If not, write to
  21.  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  22.  USA.
  23.  
  24.  *
  25.  * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ecc.h,v $
  26.  * $Revision: 1.2 $
  27.  * $Date: 1997/10/05 19:18:11 $
  28.  *
  29.  *      This file contains the definitions for the
  30.  *      Reed-Solomon error correction code 
  31.  *      for the QIC-40/80 tape streamer device driver.
  32.  */
  33. #include "../lowlevel/ftape-bsm.h"
  34. #define BAD_CLEAR(entry) ((entry)=0)
  35. #define BAD_SET(entry,sector) ((entry)|=(1<<(sector)))
  36. #define BAD_CHECK(entry,sector) ((entry)&(1<<(sector)))
  37. /*
  38.  * Return values for ecc_correct_data:
  39.  */
  40. enum {
  41. ECC_OK, /* Data was correct. */
  42. ECC_CORRECTED, /* Correctable error in data. */
  43. ECC_FAILED, /* Could not correct data. */
  44. };
  45. /*
  46.  * Representation of an in memory segment.  MARKED_BAD lists the
  47.  * sectors that were marked bad during formatting.  If the N-th sector
  48.  * in a segment is marked bad, bit 1<<N will be set in MARKED_BAD.
  49.  * The sectors should be read in from the disk and packed, as if the
  50.  * bad sectors were not there, and the segment just contained fewer
  51.  * sectors.  READ_SECTORS is a bitmap of errors encountered while
  52.  * reading the data.  These offsets are relative to the packed data.
  53.  * BLOCKS is a count of the sectors not marked bad.  This is just to
  54.  * prevent having to count the zero bits in MARKED_BAD each time this
  55.  * is needed.  DATA is the actual sector packed data from (or to) the
  56.  * tape.
  57.  */
  58.  struct memory_segment {
  59. SectorMap marked_bad;
  60. SectorMap read_bad;
  61.   int blocks;
  62.   __u8 *data;
  63. SectorMap corrected;
  64.  };
  65. /*
  66.  * ecc.c defined global variables:
  67.  */
  68. #ifdef TEST
  69. extern int ftape_ecc_tracing;
  70. #endif
  71. /*
  72.  * ecc.c defined global functions:
  73.  */
  74. extern int ftape_ecc_correct_data(struct memory_segment *data);
  75. extern int ftape_ecc_set_segment_parity(struct memory_segment *data);
  76. #endif /* _FTAPE_ECC_H_ */