diff options
Diffstat (limited to 'drivers/char/ftape/lowlevel/ftape-proc.c')
-rw-r--r-- | drivers/char/ftape/lowlevel/ftape-proc.c | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/drivers/char/ftape/lowlevel/ftape-proc.c b/drivers/char/ftape/lowlevel/ftape-proc.c new file mode 100644 index 000000000000..c66251e997ed --- /dev/null +++ b/drivers/char/ftape/lowlevel/ftape-proc.c | |||
@@ -0,0 +1,215 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1997 Claus-Justus Heine | ||
3 | |||
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. | ||
8 | |||
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. | ||
13 | |||
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. | ||
17 | |||
18 | * | ||
19 | * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-proc.c,v $ | ||
20 | * $Revision: 1.11 $ | ||
21 | * $Date: 1997/10/24 14:47:37 $ | ||
22 | * | ||
23 | * This file contains the procfs interface for the | ||
24 | * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux. | ||
25 | |||
26 | * Old code removed, switched to dynamic proc entry. | ||
27 | */ | ||
28 | |||
29 | #include <linux/config.h> | ||
30 | |||
31 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) | ||
32 | |||
33 | #include <linux/proc_fs.h> | ||
34 | |||
35 | #include <linux/ftape.h> | ||
36 | #include <linux/init.h> | ||
37 | #include <linux/qic117.h> | ||
38 | |||
39 | #include "../lowlevel/ftape-io.h" | ||
40 | #include "../lowlevel/ftape-ctl.h" | ||
41 | #include "../lowlevel/ftape-proc.h" | ||
42 | #include "../lowlevel/ftape-tracing.h" | ||
43 | |||
44 | static size_t get_driver_info(char *buf) | ||
45 | { | ||
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" }; | ||
55 | |||
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]); | ||
65 | } | ||
66 | |||
67 | static size_t get_tapedrive_info(char *buf) | ||
68 | { | ||
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); | ||
88 | } | ||
89 | |||
90 | static size_t get_cartridge_info(char *buf) | ||
91 | { | ||
92 | if (ftape_init_drive_needed) { | ||
93 | return sprintf(buf, "uninitialized\n"); | ||
94 | } | ||
95 | if (ft_no_tape) { | ||
96 | return sprintf(buf, "no cartridge inserted\n"); | ||
97 | } | ||
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); | ||
117 | } | ||
118 | |||
119 | static size_t get_controller_info(char *buf) | ||
120 | { | ||
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" }; | ||
128 | |||
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); | ||
139 | } | ||
140 | |||
141 | static size_t get_history_info(char *buf) | ||
142 | { | ||
143 | size_t len; | ||
144 | |||
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; | ||
175 | } | ||
176 | |||
177 | static int ftape_read_proc(char *page, char **start, off_t off, | ||
178 | int count, int *eof, void *data) | ||
179 | { | ||
180 | char *ptr = page; | ||
181 | size_t len; | ||
182 | |||
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); | ||
193 | |||
194 | len = strlen(page); | ||
195 | *start = NULL; | ||
196 | if (off+count >= len) { | ||
197 | *eof = 1; | ||
198 | } else { | ||
199 | *eof = 0; | ||
200 | } | ||
201 | return len; | ||
202 | } | ||
203 | |||
204 | int __init ftape_proc_init(void) | ||
205 | { | ||
206 | return create_proc_read_entry("ftape", 0, &proc_root, | ||
207 | ftape_read_proc, NULL) != NULL; | ||
208 | } | ||
209 | |||
210 | void ftape_proc_destroy(void) | ||
211 | { | ||
212 | remove_proc_entry("ftape", &proc_root); | ||
213 | } | ||
214 | |||
215 | #endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) */ | ||