5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
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)
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.
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.
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-io.h,v $
25 * $Date: 1997/10/05 19:18:06 $
27 * This file contains the declarations for the low level
28 * functions that communicate with the floppy disk controller,
29 * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
33 #include <linux/fdreg.h>
35 #include "../lowlevel/ftape-bsm.h"
37 #define FDC_SK_BIT (0x20)
38 #define FDC_MT_BIT (0x80)
40 #define FDC_READ (FD_READ & ~(FDC_SK_BIT | FDC_MT_BIT))
41 #define FDC_WRITE (FD_WRITE & ~FDC_MT_BIT)
42 #define FDC_READ_DELETED (0x4c)
43 #define FDC_WRITE_DELETED (0x49)
44 #define FDC_VERIFY (0x56)
45 #define FDC_READID (0x4a)
46 #define FDC_SENSED (0x04)
47 #define FDC_SENSEI (FD_SENSEI)
48 #define FDC_FORMAT (FD_FORMAT)
49 #define FDC_RECAL (FD_RECALIBRATE)
50 #define FDC_SEEK (FD_SEEK)
51 #define FDC_SPECIFY (FD_SPECIFY)
52 #define FDC_RECALIBR (FD_RECALIBRATE)
53 #define FDC_VERSION (FD_VERSION)
54 #define FDC_PERPEND (FD_PERPENDICULAR)
55 #define FDC_DUMPREGS (FD_DUMPREGS)
56 #define FDC_LOCK (FD_LOCK)
57 #define FDC_UNLOCK (FD_UNLOCK)
58 #define FDC_CONFIGURE (FD_CONFIGURE)
59 #define FDC_DRIVE_SPEC (0x8e) /* i82078 has this (any others?) */
60 #define FDC_PARTID (0x18) /* i82078 has this */
61 #define FDC_SAVE (0x2e) /* i82078 has this (any others?) */
62 #define FDC_RESTORE (0x4e) /* i82078 has this (any others?) */
64 #define FDC_STATUS_MASK (STATUS_BUSY | STATUS_DMA | STATUS_DIR | STATUS_READY)
65 #define FDC_DATA_READY (STATUS_READY)
66 #define FDC_DATA_OUTPUT (STATUS_DIR)
67 #define FDC_DATA_READY_MASK (STATUS_READY | STATUS_DIR)
68 #define FDC_DATA_OUT_READY (STATUS_READY | STATUS_DIR)
69 #define FDC_DATA_IN_READY (STATUS_READY)
70 #define FDC_BUSY (STATUS_BUSY)
71 #define FDC_CLK48_BIT (0x80)
72 #define FDC_SEL3V_BIT (0x40)
74 #define ST0_INT_MASK (ST0_INTR)
75 #define FDC_INT_NORMAL (ST0_INTR & 0x00)
76 #define FDC_INT_ABNORMAL (ST0_INTR & 0x40)
77 #define FDC_INT_INVALID (ST0_INTR & 0x80)
78 #define FDC_INT_READYCH (ST0_INTR & 0xC0)
79 #define ST0_SEEK_END (ST0_SE)
80 #define ST3_TRACK_0 (ST3_TZ)
82 #define FDC_RESET_NOT (0x04)
83 #define FDC_DMA_MODE (0x08)
84 #define FDC_MOTOR_0 (0x10)
85 #define FDC_MOTOR_1 (0x20)
88 void (**hook) (void); /* our wedge into the isr */
90 no_fdc, i8272, i82077, i82077AA, fc10,
92 } type; /* FDC type */
93 unsigned int irq; /* FDC irq nr */
94 unsigned int dma; /* FDC dma channel nr */
95 __u16 sra; /* Status register A (PS/2 only) */
96 __u16 srb; /* Status register B (PS/2 only) */
97 __u16 dor; /* Digital output register */
98 __u16 tdr; /* Tape Drive Register (82077SL-1 &
100 __u16 msr; /* Main Status Register */
101 __u16 dsr; /* Datarate Select Register (8207x only) */
102 __u16 fifo; /* Data register / Fifo on 8207x */
103 __u16 dir; /* Digital Input Register */
104 __u16 ccr; /* Configuration Control Register */
105 __u16 dor2; /* Alternate dor on MACH-2 controller,
106 also used with FC-10, meaning unknown */
110 fdc_data_rate_250 = 2,
111 fdc_data_rate_300 = 1, /* any fdc in default configuration */
112 fdc_data_rate_500 = 0,
113 fdc_data_rate_1000 = 3,
114 fdc_data_rate_2000 = 1, /* i82078-1: when using Data Rate Table #2 */
115 } fdc_data_rate_type;
119 fdc_reading_data = FDC_READ,
120 fdc_seeking = FDC_SEEK,
121 fdc_writing_data = FDC_WRITE,
122 fdc_deleting = FDC_WRITE_DELETED,
123 fdc_reading_id = FDC_READID,
124 fdc_recalibrating = FDC_RECAL,
125 fdc_formatting = FDC_FORMAT,
126 fdc_verifying = FDC_VERIFY
143 volatile buffer_state_enum status;
145 volatile unsigned int bytes;
146 volatile unsigned int segment_id;
148 /* bitmap for remainder of segment not yet handled.
149 * one bit set for each bad sector that must be skipped.
151 volatile SectorMap bad_sector_map;
153 /* bitmap with bad data blocks in data buffer.
154 * the errors in this map may be retried.
156 volatile SectorMap soft_error_map;
158 /* bitmap with bad data blocks in data buffer
159 * the errors in this map may not be retried.
161 volatile SectorMap hard_error_map;
163 /* retry counter for soft errors.
167 /* sectors to skip on retry ???
169 volatile unsigned int skip;
171 /* nr of data blocks in data buffer
173 volatile unsigned int data_offset;
175 /* offset in segment for first sector to be handled.
177 volatile unsigned int sector_offset;
179 /* size of cluster of good sectors to be handled.
181 volatile unsigned int sector_count;
183 /* size of remaining part of segment to be handled.
185 volatile unsigned int remaining;
187 /* points to next segment (contiguous) to be handled,
188 * or is zero if no read-ahead is allowed.
190 volatile unsigned int next_segment;
192 /* flag being set if deleted data was read.
194 volatile int deleted;
196 /* floppy coordinates of first sector in segment */
201 /* gap to use when formatting */
203 /* flag set when buffer is mmaped */
208 * fdc-io.c defined public variables
210 extern volatile fdc_mode_enum fdc_mode;
211 extern int fdc_setup_error; /* outdated ??? */
212 extern wait_queue_head_t ftape_wait_intr;
213 extern volatile int ftape_current_cylinder; /* track nr FDC thinks we're on */
214 extern volatile __u8 fdc_head; /* FDC head */
215 extern volatile __u8 fdc_cyl; /* FDC track */
216 extern volatile __u8 fdc_sect; /* FDC sector */
217 extern fdc_config_info fdc; /* FDC hardware configuration */
219 extern unsigned int ft_fdc_base;
220 extern unsigned int ft_fdc_irq;
221 extern unsigned int ft_fdc_dma;
222 extern unsigned int ft_fdc_threshold;
223 extern unsigned int ft_fdc_rate_limit;
224 extern int ft_probe_fc10;
227 * fdc-io.c defined public functions
229 extern void fdc_catch_stray_interrupts(int count);
230 extern int fdc_ready_wait(unsigned int timeout);
231 extern int fdc_command(const __u8 * cmd_data, int cmd_len);
232 extern int fdc_result(__u8 * res_data, int res_len);
233 extern int fdc_interrupt_wait(unsigned int time);
234 extern int fdc_seek(int track);
235 extern int fdc_sense_drive_status(int *st3);
236 extern void fdc_motor(int motor);
237 extern void fdc_reset(void);
238 extern void fdc_disable(void);
239 extern int fdc_fifo_threshold(__u8 threshold,
240 int *fifo_state, int *lock_state, int *fifo_thr);
241 extern void fdc_wait_calibrate(void);
242 extern int fdc_sense_interrupt_status(int *st0, int *current_cylinder);
243 extern void fdc_save_drive_specs(void);
244 extern void fdc_restore_drive_specs(void);
245 extern int fdc_set_data_rate(int rate);
246 extern void fdc_set_write_precomp(int precomp);
247 extern int fdc_release_irq_and_dma(void);
248 extern void fdc_release_regions(void);
249 extern int fdc_init(void);
250 extern int fdc_setup_read_write(buffer_struct * buff, __u8 operation);
251 extern int fdc_setup_formatting(buffer_struct * buff);