1#ifndef _FTAPE_CTL_H
2#define _FTAPE_CTL_H
3
4/*
5 * Copyright (C) 1993-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: /home/user/PROJECT/WL-520gu-NewUI/src/linux/linux/drivers/char/ftape/lowlevel/ftape-ctl.h,v $
24 * $Revision: 1.1.1.1 $
25 * $Date: 2008/10/15 03:26:29 $
26 *
27 *      This file contains the non-standard IOCTL related definitions
28 *      for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
29 *      Linux.
30 */
31
32#include <linux/ioctl.h>
33#include <linux/mtio.h>
34#include <linux/ftape-vendors.h>
35
36#include "../lowlevel/ftape-rw.h"
37#include <linux/ftape-header-segment.h>
38
39typedef struct {
40	int used;		/* any reading or writing done */
41	/* isr statistics */
42	unsigned int id_am_errors;	/* id address mark not found */
43	unsigned int id_crc_errors;	/* crc error in id address mark */
44	unsigned int data_am_errors;	/* data address mark not found */
45	unsigned int data_crc_errors;	/* crc error in data field */
46	unsigned int overrun_errors;	/* fdc access timing problem */
47	unsigned int no_data_errors;	/* sector not found */
48	unsigned int retries;	/* number of tape retries */
49	/* ecc statistics */
50	unsigned int crc_errors;	/* crc error in data */
51	unsigned int crc_failures;	/* bad data without crc error */
52	unsigned int ecc_failures;	/* failed to correct */
53	unsigned int corrected;	/* total sectors corrected */
54	/* general statistics */
55	unsigned int rewinds;	/* number of tape rewinds */
56	unsigned int defects;	/* bad sectors due to media defects */
57} history_record;
58
59/* this structure contains * ALL * information that we want
60 * our child modules to know about, but don't want them to
61 * modify.
62 */
63typedef struct {
64	/*  vendor information */
65	vendor_struct fti_drive_type;
66	/*  data rates */
67	unsigned int fti_used_data_rate;
68	unsigned int fti_drive_max_rate;
69	unsigned int fti_fdc_max_rate;
70	/*  drive selection, either FTAPE_SEL_A/B/C/D */
71	int fti_drive_sel;
72	/*  flags set after decode the drive and tape status   */
73	unsigned int fti_formatted      :1;
74	unsigned int fti_no_tape        :1;
75	unsigned int fti_write_protected:1;
76	unsigned int fti_new_tape       :1;
77	/*  values of last queried drive/tape status and error */
78	ft_drive_error  fti_last_error;
79	ft_drive_status fti_last_status;
80	/*  cartridge geometry */
81	unsigned int fti_tracks_per_tape;
82	unsigned int fti_segments_per_track;
83	/*  location of header segments, etc. */
84	int fti_used_header_segment;
85	int fti_header_segment_1;
86	int fti_header_segment_2;
87	int fti_first_data_segment;
88	int fti_last_data_segment;
89	/*  the format code as stored in the header segment  */
90	ft_format_type  fti_format_code;
91	/*  the following is the sole reason for the ftape_set_status() call */
92	unsigned int fti_qic_std;
93	/*  is tape running? */
94	volatile enum runner_status_enum fti_runner_status;
95	/*  is tape reading/writing/verifying/formatting/deleting */
96	buffer_state_enum fti_state;
97	/*  flags fatal hardware error */
98	unsigned int fti_failure:1;
99	/*  history record */
100	history_record fti_history;
101} ftape_info;
102
103/* vendor information */
104#define ft_drive_type          ftape_status.fti_drive_type
105/*  data rates */
106#define ft_data_rate           ftape_status.fti_used_data_rate
107#define ft_drive_max_rate      ftape_status.fti_drive_max_rate
108#define ft_fdc_max_rate        ftape_status.fti_fdc_max_rate
109/*  drive selection, either FTAPE_SEL_A/B/C/D */
110#define ft_drive_sel           ftape_status.fti_drive_sel
111/*  flags set after decode the drive and tape status   */
112#define ft_formatted           ftape_status.fti_formatted
113#define ft_no_tape             ftape_status.fti_no_tape
114#define ft_write_protected     ftape_status.fti_write_protected
115#define ft_new_tape            ftape_status.fti_new_tape
116/*  values of last queried drive/tape status and error */
117#define ft_last_error          ftape_status.fti_last_error
118#define ft_last_status         ftape_status.fti_last_status
119/*  cartridge geometry */
120#define ft_tracks_per_tape     ftape_status.fti_tracks_per_tape
121#define ft_segments_per_track  ftape_status.fti_segments_per_track
122/*  the format code as stored in the header segment  */
123#define ft_format_code         ftape_status.fti_format_code
124/*  the qic status as returned by report drive configuration */
125#define ft_qic_std             ftape_status.fti_qic_std
126#define ft_used_header_segment ftape_status.fti_used_header_segment
127#define ft_header_segment_1    ftape_status.fti_header_segment_1
128#define ft_header_segment_2    ftape_status.fti_header_segment_2
129#define ft_first_data_segment  ftape_status.fti_first_data_segment
130#define ft_last_data_segment   ftape_status.fti_last_data_segment
131/*  is tape running? */
132#define ft_runner_status       ftape_status.fti_runner_status
133/*  is tape reading/writing/verifying/formatting/deleting */
134#define ft_driver_state        ftape_status.fti_state
135/*  flags fatal hardware error */
136#define ft_failure             ftape_status.fti_failure
137/*  history record */
138#define ft_history             ftape_status.fti_history
139
140/*
141 *      ftape-ctl.c defined global vars.
142 */
143extern ftape_info ftape_status;
144extern int ftape_segments_per_head;
145extern int ftape_segments_per_cylinder;
146extern int ftape_init_drive_needed;
147
148/*
149 *      ftape-ctl.c defined global functions.
150 */
151extern int  ftape_mmap(struct vm_area_struct *vma);
152extern int  ftape_enable(int drive_selection);
153extern void ftape_disable(void);
154extern int  ftape_seek_to_bot(void);
155extern int  ftape_seek_to_eot(void);
156extern int  ftape_abort_operation(void);
157extern void ftape_calc_timeouts(unsigned int qic_std,
158				 unsigned int data_rate,
159				 unsigned int tape_len);
160extern int  ftape_calibrate_data_rate(unsigned int qic_std);
161extern int  ftape_init_drive(void);
162extern const ftape_info *ftape_get_status(void);
163#endif
164