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.
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" ,
58 "used data rate: %d kbit/sec\n"
59 "dma memory : %d kb\n"
60 "debug messages: %s\n",
63 FT_BUFF_SIZE
* ft_nr_buffers
>> 10,
64 debug_level
[TRACE_LEVEL
]);
67 static size_t get_tapedrive_info(char *buf
)
70 "vendor id : 0x%04x\n"
72 "wind speed: %d ips\n"
74 "max. rate : %d kbit/sec\n",
75 ft_drive_type
.vendor_id
,
78 ((ft_drive_type
.wake_up
== no_wake_up
)
79 ? "No wakeup needed" :
80 ((ft_drive_type
.wake_up
== wake_up_colorado
)
82 ((ft_drive_type
.wake_up
== wake_up_mountain
)
84 ((ft_drive_type
.wake_up
== wake_up_insight
)
90 static size_t get_cartridge_info(char *buf
)
92 if (ftape_init_drive_needed
) {
93 return sprintf(buf
, "uninitialized\n");
96 return sprintf(buf
, "no cartridge inserted\n");
104 "QIC spec. : QIC-%s\n"
106 ft_segments_per_track
,
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" :
119 static size_t get_controller_info(char *buf
)
121 const char *fdc_name
[] = { "no fdc",
125 "Colorado FC-10 or FC-20",
131 "FDC base : 0x%03x\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
)
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"
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
,
158 len
+= sprintf(buf
+ len
,
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",
170 len
+= sprintf(buf
+ len
,
171 "\ntape motion statistics\n"
172 " repositions : %3d\n",
177 static int ftape_read_proc(char *page
, char **start
, off_t off
,
178 int count
, int *eof
, void *data
)
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
);
196 if (off
+count
>= 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) */