ftape-init.c 5.0 KB

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