added a lot of printk output to ease writing of emulator
[linux-2.4.21-pre4.git] / include / linux / ftape.h
1 #ifndef _FTAPE_H
2 #define _FTAPE_H
3
4 /*
5  * Copyright (C) 1994-1996 Bas Laarhoven,
6  *           (C) 1996-1997 Claus-Justus Heine.
7
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2, or (at your option)
11  any later version.
12
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; see the file COPYING.  If not, write to
20  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22  *
23  * $Source: /cvshome/samwise/ppclinux/include/linux/ftape.h,v $
24  * $Revision: 1.1.1.1 $
25  * $Date: 2005/04/11 02:51:02 $
26  *
27  *      This file contains global definitions, typedefs and macro's
28  *      for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
29  */
30
31 #define FTAPE_VERSION "ftape v3.04d 25/11/97"
32
33 /* this makes the Kernel version numbers readable */
34 #define KERNEL_VER(major,minor,sublvl) (((major)<<16)+((minor)<<8)+(sublvl))
35
36 #ifdef __KERNEL__
37 #include <linux/sched.h>
38 #include <linux/mm.h>
39 #endif
40 #include <linux/types.h>
41 #include <linux/version.h>
42 #include <linux/config.h>
43 #include <linux/mtio.h>
44
45 #define FT_SECTOR(x)            (x+1)   /* sector offset into real sector */
46 #define FT_SECTOR_SIZE          1024
47 #define FT_SECTORS_PER_SEGMENT    32
48 #define FT_ECC_SECTORS             3
49 #define FT_SEGMENT_SIZE         ((FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS) * FT_SECTOR_SIZE)
50 #define FT_BUFF_SIZE    (FT_SECTORS_PER_SEGMENT * FT_SECTOR_SIZE)
51
52 /*
53  *   bits of the minor device number that define drive selection
54  *   methods. Could be used one day to access multiple tape
55  *   drives on the same controller.
56  */
57 #define FTAPE_SEL_A     0
58 #define FTAPE_SEL_B     1
59 #define FTAPE_SEL_C     2
60 #define FTAPE_SEL_D     3
61 #define FTAPE_SEL_MASK     3
62 #define FTAPE_SEL(unit) ((unit) & FTAPE_SEL_MASK)
63 #define FTAPE_NO_REWIND 4       /* mask for minor nr */
64
65 /* the following two may be reported when MTIOCGET is requested ... */
66 typedef union {
67         struct {
68                 __u8 error;
69                 __u8 command;
70         } error;
71         long space;
72 } ft_drive_error;
73 typedef union {
74         struct {
75                 __u8 drive_status;
76                 __u8 drive_config;
77                 __u8 tape_status;
78         } status;
79         long space;
80 } ft_drive_status;
81
82 #ifdef __KERNEL__
83
84 #define FT_RQM_DELAY    12
85 #define FT_MILLISECOND  1
86 #define FT_SECOND       1000
87 #define FT_FOREVER      -1
88 #ifndef HZ
89 #error "HZ undefined."
90 #endif
91 #define FT_USPT         (1000000/HZ) /* microseconds per tick */
92
93 /* This defines the number of retries that the driver will allow
94  * before giving up (and letting a higher level handle the error).
95  */
96 #ifdef TESTING
97 #define FT_SOFT_RETRIES 1          /* number of low level retries */
98 #define FT_RETRIES_ON_ECC_ERROR 3  /* ecc error when correcting segment */
99 #else
100 #define FT_SOFT_RETRIES 6          /* number of low level retries (triple) */
101 #define FT_RETRIES_ON_ECC_ERROR 3  /* ecc error when correcting segment */
102 #endif
103
104 #ifndef THE_FTAPE_MAINTAINER
105 #define THE_FTAPE_MAINTAINER "the ftape maintainer"
106 #endif
107
108 /* Initialize missing configuration parameters.
109  */
110 #ifndef CONFIG_FT_NR_BUFFERS
111 # define CONFIG_FT_NR_BUFFERS 3
112 #endif
113 #ifndef CONFIG_FT_FDC_THR
114 # define CONFIG_FT_FDC_THR 8
115 #endif
116 #ifndef CONFIG_FT_FDC_MAX_RATE
117 # define CONFIG_FT_FDC_MAX_RATE 2000
118 #endif
119 #ifndef CONFIG_FT_FDC_BASE
120 # define CONFIG_FT_FDC_BASE 0
121 #endif
122 #ifndef CONFIG_FT_FDC_IRQ
123 # define CONFIG_FT_FDC_IRQ  0
124 #endif
125 #ifndef CONFIG_FT_FDC_DMA
126 # define CONFIG_FT_FDC_DMA  0
127 #endif
128
129 /* Turn some booleans into numbers.
130  */
131 #ifdef CONFIG_FT_PROBE_FC10
132 # undef CONFIG_FT_PROBE_FC10
133 # define CONFIG_FT_PROBE_FC10 1
134 #else
135 # define CONFIG_FT_PROBE_FC10 0
136 #endif
137 #ifdef CONFIG_FT_MACH2
138 # undef CONFIG_FT_MACH2
139 # define CONFIG_FT_MACH2 1
140 #else
141 # define CONFIG_FT_MACH2 0
142 #endif
143
144 /* Insert default settings
145  */
146 #if CONFIG_FT_PROBE_FC10 == 1
147 # if CONFIG_FT_FDC_BASE == 0
148 #  undef  CONFIG_FT_FDC_BASE
149 #  define CONFIG_FT_FDC_BASE 0x180
150 # endif
151 # if CONFIG_FT_FDC_IRQ == 0
152 #  undef  CONFIG_FT_FDC_IRQ
153 #  define CONFIG_FT_FDC_IRQ 9
154 # endif
155 # if CONFIG_FT_FDC_DMA == 0
156 #  undef  CONFIG_FT_FDC_DMA
157 #  define CONFIG_FT_FDC_DMA 3
158 # endif
159 #elif CONFIG_FT_MACH2 == 1    /* CONFIG_FT_PROBE_FC10 == 1 */
160 # if CONFIG_FT_FDC_BASE == 0
161 #  undef  CONFIG_FT_FDC_BASE
162 #  define CONFIG_FT_FDC_BASE 0x1E0
163 # endif
164 # if CONFIG_FT_FDC_IRQ == 0
165 #  undef  CONFIG_FT_FDC_IRQ
166 #  define CONFIG_FT_FDC_IRQ 6
167 # endif
168 # if CONFIG_FT_FDC_DMA == 0
169 #  undef  CONFIG_FT_FDC_DMA
170 #  define CONFIG_FT_FDC_DMA 2
171 # endif
172 #elif CONFIG_FT_ALT_FDC == 1  /* CONFIG_FT_MACH2 */
173 # if CONFIG_FT_FDC_BASE == 0
174 #  undef  CONFIG_FT_FDC_BASE
175 #  define CONFIG_FT_FDC_BASE 0x370
176 # endif
177 # if CONFIG_FT_FDC_IRQ == 0
178 #  undef  CONFIG_FT_FDC_IRQ
179 #  define CONFIG_FT_FDC_IRQ 6
180 # endif
181 # if CONFIG_FT_FDC_DMA == 0
182 #  undef  CONFIG_FT_FDC_DMA
183 #  define CONFIG_FT_FDC_DMA 2
184 # endif
185 #else                          /* CONFIG_FT_ALT_FDC */
186 # if CONFIG_FT_FDC_BASE == 0
187 #  undef  CONFIG_FT_FDC_BASE
188 #  define CONFIG_FT_FDC_BASE 0x3f0
189 # endif
190 # if CONFIG_FT_FDC_IRQ == 0
191 #  undef  CONFIG_FT_FDC_IRQ
192 #  define CONFIG_FT_FDC_IRQ 6
193 # endif
194 # if CONFIG_FT_FDC_DMA == 0
195 #  undef  CONFIG_FT_FDC_DMA
196 #  define CONFIG_FT_FDC_DMA 2
197 # endif
198 #endif                         /* standard FDC */
199
200 /*      some useful macro's
201  */
202 #define ABS(a)          ((a) < 0 ? -(a) : (a))
203 #define NR_ITEMS(x)     (int)(sizeof(x)/ sizeof(*x))
204
205 extern int ftape_init(void);
206
207 #endif  /* __KERNEL__ */
208
209 #endif