2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * 1996-1997 Claus-Justus Heine.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ctl.c,v $
22 * $Date: 1997/11/11 14:37:44 $
24 * This file contains the non-read/write ftape functions for the
25 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
28 #include <linux/config.h>
29 #include <linux/errno.h>
31 #include <linux/mman.h>
33 #include <linux/ftape.h>
34 #include <linux/qic117.h>
35 #include <asm/uaccess.h>
38 /* ease porting between pre-2.4.x and later kernels */
39 #define vma_get_pgoff(v) ((v)->vm_pgoff)
41 #include "../lowlevel/ftape-tracing.h"
42 #include "../lowlevel/ftape-io.h"
43 #include "../lowlevel/ftape-ctl.h"
44 #include "../lowlevel/ftape-write.h"
45 #include "../lowlevel/ftape-read.h"
46 #include "../lowlevel/ftape-rw.h"
47 #include "../lowlevel/ftape-bsm.h"
51 ftape_info ftape_status = {
52 /* vendor information */
53 { 0, }, /* drive type */
55 500, /* used data rate */
56 500, /* drive max rate */
57 500, /* fdc max rate */
58 /* drive selection, either FTAPE_SEL_A/B/C/D */
59 -1, /* drive selection */
60 /* flags set after decode the drive and tape status */
63 1, /* write protected */
65 /* values of last queried drive/tape status and error */
66 {{0,}}, /* last error code */
67 {{0,}}, /* drive status, configuration, tape status */
68 /* cartridge geometry */
69 20, /* tracks_per_tape */
70 102, /* segments_per_track */
71 /* location of header segments, etc. */
72 -1, /* used_header_segment */
73 -1, /* header_segment_1 */
74 -1, /* header_segment_2 */
75 -1, /* first_data_segment */
76 -1, /* last_data_segment */
77 /* the format code as stored in the header segment */
78 fmt_normal, /* format code */
79 /* the default for the qic std: unknown */
81 /* is tape running? */
82 idle, /* runner_state */
83 /* is tape reading/writing/verifying/formatting/deleting */
84 idle, /* driver state */
85 /* flags fatal hardware error */
88 { 0, } /* history record */
91 int ftape_segments_per_head = 1020;
92 int ftape_segments_per_cylinder = 4;
93 int ftape_init_drive_needed = 1; /* need to be global for ftape_reset_drive()
99 static const vendor_struct vendors[] = QIC117_VENDORS;
100 static const wakeup_method methods[] = WAKEUP_METHODS;
102 const ftape_info *ftape_get_status(void)
104 #if defined(STATUS_PARANOYA)
105 static ftape_info get_status;
107 get_status = ftape_status;
110 return &ftape_status; /* maybe return only a copy of it to assure
116 void ftape_set_status(const ftape_info *status)
118 ftape_status = *status;
121 static int ftape_not_operational(int status)
123 /* return true if status indicates tape can not be used.
125 return ((status ^ QIC_STATUS_CARTRIDGE_PRESENT) &
127 QIC_STATUS_CARTRIDGE_PRESENT |
128 QIC_STATUS_NEW_CARTRIDGE));
131 int ftape_seek_to_eot(void)
136 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
137 while ((status & QIC_STATUS_AT_EOT) == 0) {
138 if (ftape_not_operational(status)) {
141 TRACE_CATCH(ftape_command_wait(QIC_PHYSICAL_FORWARD,
142 ftape_timeout.rewind,&status),);
147 int ftape_seek_to_bot(void)
152 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
153 while ((status & QIC_STATUS_AT_BOT) == 0) {
154 if (ftape_not_operational(status)) {
157 TRACE_CATCH(ftape_command_wait(QIC_PHYSICAL_REVERSE,
158 ftape_timeout.rewind,&status),);
163 static int ftape_new_cartridge(void)
165 ft_location.track = -1; /* force seek on first access */
166 ftape_zap_read_buffers();
167 ftape_zap_write_buffers();
171 int ftape_abort_operation(void)
175 TRACE_FUN(ft_t_flow);
177 if (ft_runner_status == running) {
178 TRACE(ft_t_noise, "aborting runner, waiting");
180 ft_runner_status = do_abort;
181 /* set timeout so that the tape will run to logical EOT
182 * if we missed the last sector and there are no queue pulses.
184 result = ftape_dumb_stop();
186 if (ft_runner_status != idle) {
187 if (ft_runner_status == do_abort) {
188 TRACE(ft_t_noise, "forcing runner abort");
190 TRACE(ft_t_noise, "stopping tape");
191 result = ftape_stop_tape(&status);
192 ft_location.known = 0;
193 ft_runner_status = idle;
195 ftape_reset_buffer();
196 ftape_zap_read_buffers();
197 ftape_set_state(idle);
201 static int lookup_vendor_id(unsigned int vendor_id)
205 while (vendors[i].vendor_id != vendor_id) {
206 if (++i >= NR_ITEMS(vendors)) {
213 void ftape_detach_drive(void)
217 TRACE(ft_t_flow, "disabling tape drive and fdc");
218 ftape_put_drive_to_sleep(ft_drive_type.wake_up);
219 fdc_catch_stray_interrupts(1); /* one always comes */
221 fdc_release_irq_and_dma();
222 fdc_release_regions();
226 static void clear_history(void)
229 ft_history.id_am_errors =
230 ft_history.id_crc_errors =
231 ft_history.data_am_errors =
232 ft_history.data_crc_errors =
233 ft_history.overrun_errors =
234 ft_history.no_data_errors =
236 ft_history.crc_errors =
237 ft_history.crc_failures =
238 ft_history.ecc_failures =
239 ft_history.corrected =
241 ft_history.rewinds = 0;
244 int ftape_activate_drive(vendor_struct * drive_type)
247 TRACE_FUN(ft_t_flow);
249 /* If we already know the drive type, wake it up.
250 * Else try to find out what kind of drive is attached.
252 if (drive_type->wake_up != unknown_wake_up) {
253 TRACE(ft_t_flow, "enabling tape drive and fdc");
254 result = ftape_wakeup_drive(drive_type->wake_up);
256 TRACE(ft_t_err, "known wakeup method failed");
259 wake_up_types method;
260 const ft_trace_t old_tracing = TRACE_LEVEL;
261 if (TRACE_LEVEL < ft_t_flow) {
262 SET_TRACE_LEVEL(ft_t_bug);
265 /* Try to awaken the drive using all known methods.
266 * Lower tracing for a while.
268 for (method=no_wake_up; method < NR_ITEMS(methods); ++method) {
269 drive_type->wake_up = method;
270 #ifdef CONFIG_FT_TWO_DRIVES
271 /* Test setup for dual drive configuration.
272 * /dev/rft2 uses mountain wakeup
273 * /dev/rft3 uses colorado wakeup
274 * Other systems will use the normal scheme.
276 if ((ft_drive_sel < 2) ||
277 (ft_drive_sel == 2 && method == FT_WAKE_UP_1) ||
278 (ft_drive_sel == 3 && method == FT_WAKE_UP_2)) {
279 result=ftape_wakeup_drive(drive_type->wake_up);
284 result = ftape_wakeup_drive(drive_type->wake_up);
287 TRACE(ft_t_warn, "drive wakeup method: %s",
288 methods[drive_type->wake_up].name);
292 SET_TRACE_LEVEL(old_tracing);
294 if (method >= NR_ITEMS(methods)) {
295 /* no response at all, cannot open this drive */
296 drive_type->wake_up = unknown_wake_up;
297 TRACE(ft_t_err, "no tape drive found !");
304 int ftape_get_drive_status(void)
308 TRACE_FUN(ft_t_flow);
310 ft_no_tape = ft_write_protected = 0;
311 /* Tape drive is activated now.
312 * First clear error status if present.
315 result = ftape_ready_wait(ftape_timeout.reset, &status);
317 if (result == -ETIME) {
318 TRACE(ft_t_err, "ftape_ready_wait timeout");
319 } else if (result == -EINTR) {
320 TRACE(ft_t_err, "ftape_ready_wait aborted");
322 TRACE(ft_t_err, "ftape_ready_wait failed");
326 /* Clear error condition (drive is ready !)
328 if (status & QIC_STATUS_ERROR) {
330 qic117_cmd_t command;
332 TRACE(ft_t_err, "error status set");
333 result = ftape_report_error(&error, &command, 1);
336 "report_error_code failed: %d", result);
337 /* hope it's working next time */
340 } else if (error != 0) {
341 TRACE(ft_t_noise, "error code : %d", error);
342 TRACE(ft_t_noise, "error command: %d", command);
345 if (status & QIC_STATUS_NEW_CARTRIDGE) {
347 qic117_cmd_t command;
348 const ft_trace_t old_tracing = TRACE_LEVEL;
349 SET_TRACE_LEVEL(ft_t_bug);
351 /* Undocumented feature: Must clear (not present!)
352 * error here or we'll fail later.
354 ftape_report_error(&error, &command, 1);
356 SET_TRACE_LEVEL(old_tracing);
357 TRACE(ft_t_info, "status: new cartridge");
362 FT_SIGNAL_EXIT(_DONT_BLOCK);
363 } while (status & QIC_STATUS_ERROR);
365 ft_no_tape = !(status & QIC_STATUS_CARTRIDGE_PRESENT);
366 ft_write_protected = (status & QIC_STATUS_WRITE_PROTECT) != 0;
368 TRACE(ft_t_warn, "no cartridge present");
370 if (ft_write_protected) {
371 TRACE(ft_t_noise, "Write protected cartridge");
377 void ftape_log_vendor_id(void)
380 TRACE_FUN(ft_t_flow);
382 ftape_report_vendor_id(&ft_drive_type.vendor_id);
383 vendor_index = lookup_vendor_id(ft_drive_type.vendor_id);
384 if (ft_drive_type.vendor_id == UNKNOWN_VENDOR &&
385 ft_drive_type.wake_up == wake_up_colorado) {
387 /* hack to get rid of all this mail */
388 ft_drive_type.vendor_id = 0;
390 if (vendor_index < 0) {
391 /* Unknown vendor id, first time opening device. The
392 * drive_type remains set to type found at wakeup
393 * time, this will probably keep the driver operating
394 * for this new vendor.
396 TRACE(ft_t_warn, "\n"
397 KERN_INFO "============ unknown vendor id ===========\n"
398 KERN_INFO "A new, yet unsupported tape drive is found\n"
399 KERN_INFO "Please report the following values:\n"
400 KERN_INFO " Vendor id : 0x%04x\n"
401 KERN_INFO " Wakeup method : %s\n"
402 KERN_INFO "And a description of your tape drive\n"
403 KERN_INFO "to "THE_FTAPE_MAINTAINER"\n"
404 KERN_INFO "==========================================",
405 ft_drive_type.vendor_id,
406 methods[ft_drive_type.wake_up].name);
407 ft_drive_type.speed = 0; /* unknown */
409 ft_drive_type.name = vendors[vendor_index].name;
410 ft_drive_type.speed = vendors[vendor_index].speed;
411 TRACE(ft_t_info, "tape drive type: %s", ft_drive_type.name);
412 /* scan all methods for this vendor_id in table */
413 while(ft_drive_type.wake_up != vendors[vendor_index].wake_up) {
414 if (vendor_index < NR_ITEMS(vendors) - 1 &&
415 vendors[vendor_index + 1].vendor_id
417 ft_drive_type.vendor_id) {
423 if (ft_drive_type.wake_up != vendors[vendor_index].wake_up) {
424 TRACE(ft_t_warn, "\n"
425 KERN_INFO "==========================================\n"
426 KERN_INFO "wakeup type mismatch:\n"
427 KERN_INFO "found: %s, expected: %s\n"
428 KERN_INFO "please report this to "THE_FTAPE_MAINTAINER"\n"
429 KERN_INFO "==========================================",
430 methods[ft_drive_type.wake_up].name,
431 methods[vendors[vendor_index].wake_up].name);
437 void ftape_calc_timeouts(unsigned int qic_std,
438 unsigned int data_rate,
439 unsigned int tape_len)
441 int speed; /* deci-ips ! */
446 /* tape transport speed
447 * data rate: QIC-40 QIC-80 QIC-3010 QIC-3020
449 * 250 Kbps 25 ips n/a n/a n/a
450 * 500 Kbps 50 ips 34 ips 22.6 ips n/a
451 * 1 Mbps n/a 68 ips 45.2 ips 22.6 ips
452 * 2 Mbps n/a n/a n/a 45.2 ips
454 * fast tape transport speed is at least 68 ips.
458 speed = (data_rate == 250) ? 250 : 500;
461 speed = (data_rate == 500) ? 340 : 680;
463 case QIC_TAPE_QIC3010:
464 speed = (data_rate == 500) ? 226 : 452;
466 case QIC_TAPE_QIC3020:
467 speed = (data_rate == 1000) ? 226 : 452;
470 TRACE(ft_t_bug, "Unknown qic_std (bug) ?");
474 if (ft_drive_type.speed == 0) {
476 static int dt = 0; /* keep gcc from complaining */
477 static int first_time = 1;
479 /* Measure the time it takes to wind to EOT and back to BOT.
480 * If the tape length is known, calculate the rewind speed.
481 * Else keep the time value for calculation of the rewind
482 * speed later on, when the length _is_ known.
483 * Ask for a report only when length and speed are both known.
490 dt = (int) (((jiffies - t0) * FT_USPT) / 1000);
492 dt = 1; /* prevent div by zero on failures */
496 "trying to determine seek timeout, got %d msec",
500 ft_drive_type.speed =
501 (2 * 12 * tape_len * 1000) / dt;
502 TRACE(ft_t_warn, "\n"
503 KERN_INFO "==========================================\n"
504 KERN_INFO "drive type: %s\n"
505 KERN_INFO "delta time = %d ms, length = %d ft\n"
506 KERN_INFO "has a maximum tape speed of %d ips\n"
507 KERN_INFO "please report this to "THE_FTAPE_MAINTAINER"\n"
508 KERN_INFO "==========================================",
509 ft_drive_type.name, dt, tape_len,
510 ft_drive_type.speed);
513 /* Handle unknown length tapes as very long ones. We'll
514 * determine the actual length from a header segment later.
515 * This is normal for all modern (Wide,TR1/2/3) formats.
519 "Unknown tape length, using maximal timeouts");
520 length = QIC_TOP_TAPE_LEN; /* use worst case values */
522 length = tape_len; /* use actual values */
524 if (ft_drive_type.speed == 0) {
527 ff_speed = ft_drive_type.speed;
529 /* time to go from bot to eot at normal speed (data rate):
530 * time = (1+delta) * length (ft) * 12 (inch/ft) / speed (ips)
531 * delta = 10 % for seek speed, 20 % for rewind speed.
533 ftape_timeout.seek = (length * 132 * FT_SECOND) / speed;
534 ftape_timeout.rewind = (length * 144 * FT_SECOND) / (10 * ff_speed);
535 ftape_timeout.reset = 20 * FT_SECOND + ftape_timeout.rewind;
536 TRACE(ft_t_noise, "timeouts for speed = %d, length = %d\n"
537 KERN_INFO "seek timeout : %d sec\n"
538 KERN_INFO "rewind timeout: %d sec\n"
539 KERN_INFO "reset timeout : %d sec",
541 (ftape_timeout.seek + 500) / 1000,
542 (ftape_timeout.rewind + 500) / 1000,
543 (ftape_timeout.reset + 500) / 1000);
547 /* This function calibrates the datarate (i.e. determines the maximal
548 * usable data rate) and sets the global variable ft_qic_std to qic_std
551 int ftape_calibrate_data_rate(unsigned int qic_std)
553 int rate = ft_fdc_rate_limit;
555 TRACE_FUN(ft_t_flow);
557 ft_qic_std = qic_std;
559 if (ft_qic_std == -1) {
560 TRACE_ABORT(-EIO, ft_t_err,
561 "Unable to determine data rate if QIC standard is unknown");
564 /* Select highest rate supported by both fdc and drive.
565 * Start with highest rate supported by the fdc.
567 while (fdc_set_data_rate(rate) < 0 && rate > 250) {
571 "Highest FDC supported data rate: %d Kbps", rate);
572 ft_fdc_max_rate = rate;
574 result = ftape_set_data_rate(rate, ft_qic_std);
575 } while (result == -EINVAL && (rate /= 2) > 250);
577 TRACE_ABORT(-EIO, ft_t_err, "set datarate failed");
583 int ftape_init_drive(void)
587 unsigned int qic_std;
588 unsigned int data_rate;
589 TRACE_FUN(ft_t_flow);
591 ftape_init_drive_needed = 0; /* don't retry if this fails ? */
592 TRACE_CATCH(ftape_report_raw_drive_status(&status),);
593 if (status & QIC_STATUS_CARTRIDGE_PRESENT) {
594 if (!(status & QIC_STATUS_AT_BOT)) {
595 /* Antique drives will get here after a soft reset,
596 * modern ones only if the driver is loaded when the
597 * tape wasn't rewound properly.
599 /* Tape should be at bot if new cartridge ! */
602 if (!(status & QIC_STATUS_REFERENCED)) {
603 TRACE(ft_t_flow, "starting seek_load_point");
604 TRACE_CATCH(ftape_command_wait(QIC_SEEK_LOAD_POINT,
609 ft_formatted = (status & QIC_STATUS_REFERENCED) != 0;
611 TRACE(ft_t_warn, "Warning: tape is not formatted !");
614 /* report configuration aborts when ftape_tape_len == -1
615 * unknown qic_std is okay if not formatted.
617 TRACE_CATCH(ftape_report_configuration(&model,
622 /* Maybe add the following to the /proc entry
624 TRACE(ft_t_info, "%s drive @ %d Kbps",
625 (model == prehistoric) ? "prehistoric" :
626 ((model == pre_qic117c) ? "pre QIC-117C" :
627 ((model == post_qic117b) ? "post QIC-117B" :
628 "post QIC-117D")), data_rate);
631 /* initialize ft_used_data_rate to maximum value
634 TRACE_CATCH(ftape_calibrate_data_rate(qic_std),);
635 if (ftape_tape_len == 0) {
636 TRACE(ft_t_info, "unknown length QIC-%s tape",
637 (ft_qic_std == QIC_TAPE_QIC40) ? "40" :
638 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
639 ((ft_qic_std == QIC_TAPE_QIC3010)
640 ? "3010" : "3020")));
642 TRACE(ft_t_info, "%d ft. QIC-%s tape", ftape_tape_len,
643 (ft_qic_std == QIC_TAPE_QIC40) ? "40" :
644 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
645 ((ft_qic_std == QIC_TAPE_QIC3010)
646 ? "3010" : "3020")));
648 ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
649 /* soft write-protect QIC-40/QIC-80 cartridges used with a
650 * Colorado T3000 drive. Buggy hardware!
652 if ((ft_drive_type.vendor_id == 0x011c6) &&
653 ((ft_qic_std == QIC_TAPE_QIC40 ||
654 ft_qic_std == QIC_TAPE_QIC80) &&
655 !ft_write_protected)) {
656 TRACE(ft_t_warn, "\n"
657 KERN_INFO "The famous Colorado T3000 bug:\n"
658 KERN_INFO "%s drives can't write QIC40 and QIC80\n"
659 KERN_INFO "cartridges but don't set the write-protect flag!",
661 ft_write_protected = 1;
664 /* Doesn't make too much sense to set the data rate
665 * because we don't know what to use for the write
667 * Need to do this again when formatting the cartridge.
669 ft_data_rate = data_rate;
670 ftape_calc_timeouts(QIC_TAPE_QIC40,
674 ftape_new_cartridge();
678 static void ftape_munmap(void)
681 TRACE_FUN(ft_t_flow);
683 for (i = 0; i < ft_nr_buffers; i++) {
684 ft_buffer[i]->mmapped = 0;
689 /* Map the dma buffers into the virtual address range given by vma.
690 * We only check the caller doesn't map non-existent buffers. We
691 * don't check for multiple mappings.
693 int ftape_mmap(struct vm_area_struct *vma)
697 TRACE_FUN(ft_t_flow);
702 if (!(vma->vm_flags & (VM_READ|VM_WRITE))) {
703 TRACE_ABORT(-EINVAL, ft_t_err, "Undefined mmap() access");
705 if (vma_get_pgoff(vma) != 0) {
706 TRACE_ABORT(-EINVAL, ft_t_err, "page offset must be 0");
708 if ((vma->vm_end - vma->vm_start) % FT_BUFF_SIZE != 0) {
709 TRACE_ABORT(-EINVAL, ft_t_err,
710 "size = %ld, should be a multiple of %d",
711 vma->vm_end - vma->vm_start,
714 num_buffers = (vma->vm_end - vma->vm_start) / FT_BUFF_SIZE;
715 if (num_buffers > ft_nr_buffers) {
717 ft_t_err, "size = %ld, should be less than %d",
718 vma->vm_end - vma->vm_start,
719 ft_nr_buffers * FT_BUFF_SIZE);
721 if (ft_driver_state != idle) {
722 /* this also clears the buffer states
724 ftape_abort_operation();
726 ftape_reset_buffer();
728 for (i = 0; i < num_buffers; i++) {
731 pfn = virt_to_phys(ft_buffer[i]->address) >> PAGE_SHIFT;
732 TRACE_CATCH(remap_pfn_range(vma, vma->vm_start +
738 TRACE(ft_t_noise, "remapped dma buffer @ %p to location @ %p",
739 ft_buffer[i]->address,
740 (void *)(vma->vm_start + i * FT_BUFF_SIZE));
742 for (i = 0; i < num_buffers; i++) {
743 memset(ft_buffer[i]->address, 0xAA, FT_BUFF_SIZE);
744 ft_buffer[i]->mmapped++;
749 static void ftape_init_driver(void); /* forward declaration */
751 /* OPEN routine called by kernel-interface code
753 int ftape_enable(int drive_selection)
757 if (ft_drive_sel == -1 || ft_drive_sel != drive_selection) {
758 /* Other selection than last time
762 ft_drive_sel = FTAPE_SEL(drive_selection);
764 TRACE_CATCH(fdc_init(),); /* init & detect fdc */
765 TRACE_CATCH(ftape_activate_drive(&ft_drive_type),
767 fdc_release_irq_and_dma();
768 fdc_release_regions());
769 TRACE_CATCH(ftape_get_drive_status(), ftape_detach_drive());
770 if (ft_drive_type.vendor_id == UNKNOWN_VENDOR) {
771 ftape_log_vendor_id();
774 ftape_init_drive_needed = 1;
776 if (!ft_no_tape && ftape_init_drive_needed) {
777 TRACE_CATCH(ftape_init_drive(), ftape_detach_drive());
779 ftape_munmap(); /* clear the mmap flag */
784 /* release routine called by the high level interface modules
787 void ftape_disable(void)
792 for (i = 0; i < ft_nr_buffers; i++) {
793 if (ft_buffer[i]->mmapped) {
794 TRACE(ft_t_noise, "first byte of buffer %d: 0x%02x",
795 i, *ft_buffer[i]->address);
798 if (sigtestsetmask(¤t->pending.signal, _DONT_BLOCK) &&
799 !(sigtestsetmask(¤t->pending.signal, _NEVER_BLOCK)) &&
800 ftape_tape_running) {
802 "Interrupted by fatal signal and tape still running");
804 ftape_abort_operation(); /* it's annoying */
806 ftape_set_state(idle);
808 ftape_detach_drive();
809 if (ft_history.used) {
810 TRACE(ft_t_info, "== Non-fatal errors this run: ==");
811 TRACE(ft_t_info, "fdc isr statistics:\n"
812 KERN_INFO " id_am_errors : %3d\n"
813 KERN_INFO " id_crc_errors : %3d\n"
814 KERN_INFO " data_am_errors : %3d\n"
815 KERN_INFO " data_crc_errors : %3d\n"
816 KERN_INFO " overrun_errors : %3d\n"
817 KERN_INFO " no_data_errors : %3d\n"
818 KERN_INFO " retries : %3d",
819 ft_history.id_am_errors, ft_history.id_crc_errors,
820 ft_history.data_am_errors, ft_history.data_crc_errors,
821 ft_history.overrun_errors, ft_history.no_data_errors,
823 if (ft_history.used & 1) {
824 TRACE(ft_t_info, "ecc statistics:\n"
825 KERN_INFO " crc_errors : %3d\n"
826 KERN_INFO " crc_failures : %3d\n"
827 KERN_INFO " ecc_failures : %3d\n"
828 KERN_INFO " sectors corrected: %3d",
829 ft_history.crc_errors, ft_history.crc_failures,
830 ft_history.ecc_failures, ft_history.corrected);
832 if (ft_history.defects > 0) {
833 TRACE(ft_t_warn, "Warning: %d media defects!",
836 if (ft_history.rewinds > 0) {
837 TRACE(ft_t_info, "tape motion statistics:\n"
838 KERN_INFO "repositions : %3d",
846 static void ftape_init_driver(void)
848 TRACE_FUN(ft_t_flow);
850 ft_drive_type.vendor_id = UNKNOWN_VENDOR;
851 ft_drive_type.speed = 0;
852 ft_drive_type.wake_up = unknown_wake_up;
853 ft_drive_type.name = "Unknown";
855 ftape_timeout.seek = 650 * FT_SECOND;
856 ftape_timeout.reset = 670 * FT_SECOND;
857 ftape_timeout.rewind = 650 * FT_SECOND;
858 ftape_timeout.head_seek = 15 * FT_SECOND;
859 ftape_timeout.stop = 5 * FT_SECOND;
860 ftape_timeout.pause = 16 * FT_SECOND;
863 ftape_tape_len = 0; /* unknown */
864 ftape_current_command = 0;
865 ftape_current_cylinder = -1;
867 ft_segments_per_track = 102;
868 ftape_segments_per_head = 1020;
869 ftape_segments_per_cylinder = 4;
870 ft_tracks_per_tape = 20;
876 ft_write_protected = 1;
879 ft_driver_state = idle;
882 ft_fdc_max_rate = 500;
883 ft_drive_max_rate = 0; /* triggers set_rate_test() */
885 ftape_init_drive_needed = 1;
887 ft_header_segment_1 = -1;
888 ft_header_segment_2 = -1;
889 ft_used_header_segment = -1;
890 ft_first_data_segment = -1;
891 ft_last_data_segment = -1;
893 ft_location.track = -1;
894 ft_location.known = 0;
896 ftape_tape_running = 0;
897 ftape_might_be_off_track = 1;
899 ftape_new_cartridge(); /* init some tape related variables */