2 * Copyright (C) 1997 Claus-Justus Heine
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-proc.c,v $
21 * $Date: 1997/10/24 14:47:37 $
23 * This file contains the procfs interface for the
24 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
26 * Old code removed, switched to dynamic proc entry.
30 #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
32 #include <linux/proc_fs.h>
34 #include <linux/ftape.h>
35 #include <linux/init.h>
36 #include <linux/qic117.h>
38 #include "../lowlevel/ftape-io.h"
39 #include "../lowlevel/ftape-ctl.h"
40 #include "../lowlevel/ftape-proc.h"
41 #include "../lowlevel/ftape-tracing.h"
43 static size_t get_driver_info(char *buf)
45 const char *debug_level[] = { "bugs" ,
57 "used data rate: %d kbit/sec\n"
58 "dma memory : %d kb\n"
59 "debug messages: %s\n",
62 FT_BUFF_SIZE * ft_nr_buffers >> 10,
63 debug_level[TRACE_LEVEL]);
66 static size_t get_tapedrive_info(char *buf)
69 "vendor id : 0x%04x\n"
71 "wind speed: %d ips\n"
73 "max. rate : %d kbit/sec\n",
74 ft_drive_type.vendor_id,
77 ((ft_drive_type.wake_up == no_wake_up)
78 ? "No wakeup needed" :
79 ((ft_drive_type.wake_up == wake_up_colorado)
81 ((ft_drive_type.wake_up == wake_up_mountain)
83 ((ft_drive_type.wake_up == wake_up_insight)
89 static size_t get_cartridge_info(char *buf)
91 if (ftape_init_drive_needed) {
92 return sprintf(buf, "uninitialized\n");
95 return sprintf(buf, "no cartridge inserted\n");
103 "QIC spec. : QIC-%s\n"
105 ft_segments_per_track,
108 (ft_formatted == 1) ? "yes" : "no",
109 (ft_write_protected == 1) ? "no" : "yes",
110 ((ft_qic_std == QIC_TAPE_QIC40) ? "40" :
111 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
112 ((ft_qic_std == QIC_TAPE_QIC3010) ? "3010" :
113 ((ft_qic_std == QIC_TAPE_QIC3020) ? "3020" :
118 static size_t get_controller_info(char *buf)
120 const char *fdc_name[] = { "no fdc",
124 "Colorado FC-10 or FC-20",
130 "FDC base : 0x%03x\n"
134 "max. rate : %d kbit/sec\n",
135 ft_mach2 ? "Mountain MACH-2" : fdc_name[fdc.type],
136 fdc.sra, fdc.irq, fdc.dma,
137 ft_fdc_threshold, ft_fdc_max_rate);
140 static size_t get_history_info(char *buf)
145 "\nFDC isr statistics\n"
146 " id_am_errors : %3d\n"
147 " id_crc_errors : %3d\n"
148 " data_am_errors : %3d\n"
149 " data_crc_errors : %3d\n"
150 " overrun_errors : %3d\n"
151 " no_data_errors : %3d\n"
153 ft_history.id_am_errors, ft_history.id_crc_errors,
154 ft_history.data_am_errors, ft_history.data_crc_errors,
155 ft_history.overrun_errors, ft_history.no_data_errors,
157 len += sprintf(buf + len,
159 " crc_errors : %3d\n"
160 " crc_failures : %3d\n"
161 " ecc_failures : %3d\n"
162 " sectors corrected: %3d\n",
163 ft_history.crc_errors, ft_history.crc_failures,
164 ft_history.ecc_failures, ft_history.corrected);
165 len += sprintf(buf + len,
166 "\ntape quality statistics\n"
167 " media defects : %3d\n",
169 len += sprintf(buf + len,
170 "\ntape motion statistics\n"
171 " repositions : %3d\n",
176 static int ftape_read_proc(char *page, char **start, off_t off,
177 int count, int *eof, void *data)
182 ptr += sprintf(ptr, "Kernel Driver\n\n");
183 ptr += get_driver_info(ptr);
184 ptr += sprintf(ptr, "\nTape Drive\n\n");
185 ptr += get_tapedrive_info(ptr);
186 ptr += sprintf(ptr, "\nFDC Controller\n\n");
187 ptr += get_controller_info(ptr);
188 ptr += sprintf(ptr, "\nTape Cartridge\n\n");
189 ptr += get_cartridge_info(ptr);
190 ptr += sprintf(ptr, "\nHistory Record\n\n");
191 ptr += get_history_info(ptr);
195 if (off+count >= len) {
203 int __init ftape_proc_init(void)
205 return create_proc_read_entry("ftape", 0, &proc_root,
206 ftape_read_proc, NULL) != NULL;
209 void ftape_proc_destroy(void)
211 remove_proc_entry("ftape", &proc_root);
214 #endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) */