Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / char / ftape / lowlevel / ftape-proc.c
blobc66251e997ed528037c4154008e03335bf2dd62a
1 /*
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)
7 any later version.
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 $
20 * $Revision: 1.11 $
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.
29 #include <linux/config.h>
31 #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
33 #include <linux/proc_fs.h>
35 #include <linux/ftape.h>
36 #include <linux/init.h>
37 #include <linux/qic117.h>
39 #include "../lowlevel/ftape-io.h"
40 #include "../lowlevel/ftape-ctl.h"
41 #include "../lowlevel/ftape-proc.h"
42 #include "../lowlevel/ftape-tracing.h"
44 static size_t get_driver_info(char *buf)
46 const char *debug_level[] = { "bugs" ,
47 "errors",
48 "warnings",
49 "informational",
50 "noisy",
51 "program flow",
52 "fdc and dma",
53 "data flow",
54 "anything" };
56 return sprintf(buf,
57 "version : %s\n"
58 "used data rate: %d kbit/sec\n"
59 "dma memory : %d kb\n"
60 "debug messages: %s\n",
61 FTAPE_VERSION,
62 ft_data_rate,
63 FT_BUFF_SIZE * ft_nr_buffers >> 10,
64 debug_level[TRACE_LEVEL]);
67 static size_t get_tapedrive_info(char *buf)
69 return sprintf(buf,
70 "vendor id : 0x%04x\n"
71 "drive name: %s\n"
72 "wind speed: %d ips\n"
73 "wakeup : %s\n"
74 "max. rate : %d kbit/sec\n",
75 ft_drive_type.vendor_id,
76 ft_drive_type.name,
77 ft_drive_type.speed,
78 ((ft_drive_type.wake_up == no_wake_up)
79 ? "No wakeup needed" :
80 ((ft_drive_type.wake_up == wake_up_colorado)
81 ? "Colorado" :
82 ((ft_drive_type.wake_up == wake_up_mountain)
83 ? "Mountain" :
84 ((ft_drive_type.wake_up == wake_up_insight)
85 ? "Motor on" :
86 "Unknown")))),
87 ft_drive_max_rate);
90 static size_t get_cartridge_info(char *buf)
92 if (ftape_init_drive_needed) {
93 return sprintf(buf, "uninitialized\n");
95 if (ft_no_tape) {
96 return sprintf(buf, "no cartridge inserted\n");
98 return sprintf(buf,
99 "segments : %5d\n"
100 "tracks : %5d\n"
101 "length : %5dft\n"
102 "formatted : %3s\n"
103 "writable : %3s\n"
104 "QIC spec. : QIC-%s\n"
105 "fmt-code : %1d\n",
106 ft_segments_per_track,
107 ft_tracks_per_tape,
108 ftape_tape_len,
109 (ft_formatted == 1) ? "yes" : "no",
110 (ft_write_protected == 1) ? "no" : "yes",
111 ((ft_qic_std == QIC_TAPE_QIC40) ? "40" :
112 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
113 ((ft_qic_std == QIC_TAPE_QIC3010) ? "3010" :
114 ((ft_qic_std == QIC_TAPE_QIC3020) ? "3020" :
115 "???")))),
116 ft_format_code);
119 static size_t get_controller_info(char *buf)
121 const char *fdc_name[] = { "no fdc",
122 "i8272",
123 "i82077",
124 "i82077AA",
125 "Colorado FC-10 or FC-20",
126 "i82078",
127 "i82078_1" };
129 return sprintf(buf,
130 "FDC type : %s\n"
131 "FDC base : 0x%03x\n"
132 "FDC irq : %d\n"
133 "FDC dma : %d\n"
134 "FDC thr. : %d\n"
135 "max. rate : %d kbit/sec\n",
136 ft_mach2 ? "Mountain MACH-2" : fdc_name[fdc.type],
137 fdc.sra, fdc.irq, fdc.dma,
138 ft_fdc_threshold, ft_fdc_max_rate);
141 static size_t get_history_info(char *buf)
143 size_t len;
145 len = sprintf(buf,
146 "\nFDC isr statistics\n"
147 " id_am_errors : %3d\n"
148 " id_crc_errors : %3d\n"
149 " data_am_errors : %3d\n"
150 " data_crc_errors : %3d\n"
151 " overrun_errors : %3d\n"
152 " no_data_errors : %3d\n"
153 " retries : %3d\n",
154 ft_history.id_am_errors, ft_history.id_crc_errors,
155 ft_history.data_am_errors, ft_history.data_crc_errors,
156 ft_history.overrun_errors, ft_history.no_data_errors,
157 ft_history.retries);
158 len += sprintf(buf + len,
159 "\nECC statistics\n"
160 " crc_errors : %3d\n"
161 " crc_failures : %3d\n"
162 " ecc_failures : %3d\n"
163 " sectors corrected: %3d\n",
164 ft_history.crc_errors, ft_history.crc_failures,
165 ft_history.ecc_failures, ft_history.corrected);
166 len += sprintf(buf + len,
167 "\ntape quality statistics\n"
168 " media defects : %3d\n",
169 ft_history.defects);
170 len += sprintf(buf + len,
171 "\ntape motion statistics\n"
172 " repositions : %3d\n",
173 ft_history.rewinds);
174 return len;
177 static int ftape_read_proc(char *page, char **start, off_t off,
178 int count, int *eof, void *data)
180 char *ptr = page;
181 size_t len;
183 ptr += sprintf(ptr, "Kernel Driver\n\n");
184 ptr += get_driver_info(ptr);
185 ptr += sprintf(ptr, "\nTape Drive\n\n");
186 ptr += get_tapedrive_info(ptr);
187 ptr += sprintf(ptr, "\nFDC Controller\n\n");
188 ptr += get_controller_info(ptr);
189 ptr += sprintf(ptr, "\nTape Cartridge\n\n");
190 ptr += get_cartridge_info(ptr);
191 ptr += sprintf(ptr, "\nHistory Record\n\n");
192 ptr += get_history_info(ptr);
194 len = strlen(page);
195 *start = NULL;
196 if (off+count >= len) {
197 *eof = 1;
198 } else {
199 *eof = 0;
201 return len;
204 int __init ftape_proc_init(void)
206 return create_proc_read_entry("ftape", 0, &proc_root,
207 ftape_read_proc, NULL) != NULL;
210 void ftape_proc_destroy(void)
212 remove_proc_entry("ftape", &proc_root);
215 #endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) */