ftape-init.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (C) 1993-1996 Bas Laarhoven,
  3. * (C) 1996-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.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  15. *
  16. * This file contains the code that interfaces the kernel
  17. * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
  18. */
  19. #include <linux/config.h>
  20. #include <linux/module.h>
  21. #include <linux/errno.h>
  22. #include <linux/fs.h>
  23. #include <linux/kernel.h>
  24. #include <linux/signal.h>
  25. #include <linux/major.h>
  26. #include <linux/ftape.h>
  27. #include <linux/init.h>
  28. #include <linux/qic117.h>
  29. #ifdef CONFIG_ZFTAPE
  30. #include <linux/zftape.h>
  31. #endif
  32. #include "../lowlevel/ftape-init.h"
  33. #include "../lowlevel/ftape-io.h"
  34. #include "../lowlevel/ftape-read.h"
  35. #include "../lowlevel/ftape-write.h"
  36. #include "../lowlevel/ftape-ctl.h"
  37. #include "../lowlevel/ftape-rw.h"
  38. #include "../lowlevel/fdc-io.h"
  39. #include "../lowlevel/ftape-buffer.h"
  40. #include "../lowlevel/ftape-proc.h"
  41. #include "../lowlevel/ftape-tracing.h"
  42. #if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
  43. static int ft_tracing = -1;
  44. #endif
  45. /* Called by modules package when installing the driver
  46. * or by kernel during the initialization phase
  47. */
  48. static int __init ftape_init(void)
  49. {
  50. TRACE_FUN(ft_t_flow);
  51. #ifdef MODULE
  52. #ifndef CONFIG_FT_NO_TRACE_AT_ALL
  53. if (ft_tracing != -1) {
  54. ftape_tracing = ft_tracing;
  55. }
  56. #endif
  57. printk(KERN_INFO FTAPE_VERSION "\n");
  58. if (TRACE_LEVEL >= ft_t_info) {
  59. printk(
  60. KERN_INFO "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl)\n"
  61. KERN_INFO "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no)\n"
  62. KERN_INFO "(c) 1996-1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
  63. KERN_INFO "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives\n");
  64. }
  65. #else /* !MODULE */
  66. /* print a short no-nonsense boot message */
  67. printk(KERN_INFO FTAPE_VERSION "\n");
  68. #endif /* MODULE */
  69. TRACE(ft_t_info, "installing QIC-117 floppy tape hardware drive ... ");
  70. TRACE(ft_t_info, "ftape_init @ 0x%p", ftape_init);
  71. /* Allocate the DMA buffers. They are deallocated at cleanup() time.
  72. */
  73. #ifdef TESTING
  74. #ifdef MODULE
  75. while (ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS) < 0) {
  76. ftape_sleep(FT_SECOND/20);
  77. if (signal_pending(current)) {
  78. (void)ftape_set_nr_buffers(0);
  79. TRACE(ft_t_bug,
  80. "Killed by signal while allocating buffers.");
  81. TRACE_ABORT(-EINTR,
  82. ft_t_bug, "Free up memory and retry");
  83. }
  84. }
  85. #else
  86. TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
  87. (void)ftape_set_nr_buffers(0));
  88. #endif
  89. #else
  90. TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
  91. (void)ftape_set_nr_buffers(0));
  92. #endif
  93. ft_drive_sel = -1;
  94. ft_failure = 1; /* inhibit any operation but open */
  95. ftape_udelay_calibrate(); /* must be before fdc_wait_calibrate ! */
  96. fdc_wait_calibrate();
  97. #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
  98. (void)ftape_proc_init();
  99. #endif
  100. #ifdef CONFIG_ZFTAPE
  101. (void)zft_init();
  102. #endif
  103. TRACE_EXIT 0;
  104. }
  105. module_param(ft_fdc_base, uint, 0);
  106. MODULE_PARM_DESC(ft_fdc_base, "Base address of FDC controller.");
  107. module_param(ft_fdc_irq, uint, 0);
  108. MODULE_PARM_DESC(ft_fdc_irq, "IRQ (interrupt channel) to use.");
  109. module_param(ft_fdc_dma, uint, 0);
  110. MODULE_PARM_DESC(ft_fdc_dma, "DMA channel to use.");
  111. module_param(ft_fdc_threshold, uint, 0);
  112. MODULE_PARM_DESC(ft_fdc_threshold, "Threshold of the FDC Fifo.");
  113. module_param(ft_fdc_rate_limit, uint, 0);
  114. MODULE_PARM_DESC(ft_fdc_rate_limit, "Maximal data rate for FDC.");
  115. module_param(ft_probe_fc10, bool, 0);
  116. MODULE_PARM_DESC(ft_probe_fc10,
  117. "If non-zero, probe for a Colorado FC-10/FC-20 controller.");
  118. module_param(ft_mach2, bool, 0);
  119. MODULE_PARM_DESC(ft_mach2,
  120. "If non-zero, probe for a Mountain MACH-2 controller.");
  121. #if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
  122. module_param(ft_tracing, int, 0644);
  123. MODULE_PARM_DESC(ft_tracing,
  124. "Amount of debugging output, 0 <= tracing <= 8, default 3.");
  125. #endif
  126. MODULE_AUTHOR(
  127. "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl), "
  128. "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no), "
  129. "(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)");
  130. MODULE_DESCRIPTION(
  131. "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives.");
  132. MODULE_LICENSE("GPL");
  133. static void __exit ftape_exit(void)
  134. {
  135. TRACE_FUN(ft_t_flow);
  136. #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
  137. ftape_proc_destroy();
  138. #endif
  139. (void)ftape_set_nr_buffers(0);
  140. printk(KERN_INFO "ftape: unloaded.\n");
  141. TRACE_EXIT;
  142. }
  143. module_init(ftape_init);
  144. module_exit(ftape_exit);