ftape-ecc.h 2.6 KB

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