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