File: /usr/src/linux/drivers/char/ftape/lowlevel/ftape-init.c

1     /*
2      *      Copyright (C) 1993-1996 Bas Laarhoven,
3      *                (C) 1996-1997 Claus-Justus Heine.
4     
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)
8      any later version.
9     
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.
14     
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.
18     
19      *
20      *      This file contains the code that interfaces the kernel
21      *      for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
22      */
23     
24     #include <linux/config.h>
25     #include <linux/module.h>
26     #include <linux/version.h>
27     #include <linux/errno.h>
28     #include <linux/fs.h>
29     #include <linux/kernel.h>
30     #include <linux/signal.h>
31     #include <linux/major.h>
32     
33     #include <linux/ftape.h>
34     #if LINUX_VERSION_CODE >= KERNEL_VER(2,1,16)
35     #include <linux/init.h>
36     #else
37     #define __initdata
38     #define __initfunc(__arg) __arg
39     #endif
40     #include <linux/qic117.h>
41     #ifdef CONFIG_ZFTAPE
42     #include <linux/zftape.h>
43     #endif
44     
45     #include "../lowlevel/ftape-init.h"
46     #include "../lowlevel/ftape_syms.h"
47     #include "../lowlevel/ftape-io.h"
48     #include "../lowlevel/ftape-read.h"
49     #include "../lowlevel/ftape-write.h"
50     #include "../lowlevel/ftape-ctl.h"
51     #include "../lowlevel/ftape-rw.h"
52     #include "../lowlevel/fdc-io.h"
53     #include "../lowlevel/ftape-buffer.h"
54     #include "../lowlevel/ftape-proc.h"
55     #include "../lowlevel/ftape-tracing.h"
56     
57     /*      Global vars.
58      */
59     char ft_src[] __initdata = "$Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-init.c,v $";
60     char ft_rev[] __initdata = "$Revision: 1.8 $";
61     char ft_dat[] __initdata = "$Date: 1997/11/06 00:38:08 $";
62     
63     
64     /*  Called by modules package when installing the driver
65      *  or by kernel during the initialization phase
66      */
67     int __init ftape_init(void)
68     {
69     	TRACE_FUN(ft_t_flow);
70     
71     #ifdef MODULE
72     	printk(KERN_INFO FTAPE_VERSION "\n");
73             if (TRACE_LEVEL >= ft_t_info) {
74     		printk(
75     KERN_INFO "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl)\n"
76     KERN_INFO "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no)\n"
77     KERN_INFO "(c) 1996-1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
78     KERN_INFO "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives\n"
79     KERN_INFO "Compiled for Linux version %s"
80     #ifdef MODVERSIONS
81     	       " with versioned symbols"
82     #endif
83     	       "\n", UTS_RELEASE);
84             }
85     #else /* !MODULE */
86     	/* print a short no-nonsense boot message */
87     	printk(KERN_INFO FTAPE_VERSION " for Linux " UTS_RELEASE "\n");
88     #endif /* MODULE */
89     	TRACE(ft_t_info, "installing QIC-117 floppy tape hardware drive ... ");
90     	TRACE(ft_t_info, "ftape_init @ 0x%p", ftape_init);
91     	/*  Allocate the DMA buffers. They are deallocated at cleanup() time.
92     	 */
93     #if TESTING
94     #ifdef MODULE
95     	while (ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS) < 0) {
96     		ftape_sleep(FT_SECOND/20);
97     		if (signal_pending(current)) {
98     			(void)ftape_set_nr_buffers(0);
99     			TRACE(ft_t_bug,
100     			      "Killed by signal while allocating buffers.");
101     			TRACE_ABORT(-EINTR, 
102     				    ft_t_bug, "Free up memory and retry");
103     		}
104     	}
105     #else
106     	TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
107     		    (void)ftape_set_nr_buffers(0));
108     #endif
109     #else
110     	TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
111     		    (void)ftape_set_nr_buffers(0));
112     #endif
113     	ft_drive_sel = -1;
114     	ft_failure   = 1;         /* inhibit any operation but open */
115     	ftape_udelay_calibrate(); /* must be before fdc_wait_calibrate ! */
116     	fdc_wait_calibrate();
117     #if LINUX_VERSION_CODE < KERNEL_VER(2,1,18)
118     	register_symtab(&ftape_symbol_table); /* add global ftape symbols */
119     #endif
120     #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
121     	(void)ftape_proc_init();
122     #endif
123     #ifdef CONFIG_ZFTAPE
124     	(void)zft_init();
125     #endif
126     	TRACE_EXIT 0;
127     }
128     
129     #ifdef MODULE
130     
131     #ifndef CONFIG_FT_NO_TRACE_AT_ALL
132     static int ft_tracing = -1;
133     #endif
134     
135     #if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18)
136     #define FT_MOD_PARM(var,type,desc) \
137     	MODULE_PARM(var,type); MODULE_PARM_DESC(var,desc)
138     
139     FT_MOD_PARM(ft_fdc_base,       "i", "Base address of FDC controller.");
140     FT_MOD_PARM(ft_fdc_irq,        "i", "IRQ (interrupt channel) to use.");
141     FT_MOD_PARM(ft_fdc_dma,        "i", "DMA channel to use.");
142     FT_MOD_PARM(ft_fdc_threshold,  "i", "Threshold of the FDC Fifo.");
143     FT_MOD_PARM(ft_fdc_rate_limit, "i", "Maximal data rate for FDC.");
144     FT_MOD_PARM(ft_probe_fc10,     "i", 
145     	    "If non-zero, probe for a Colorado FC-10/FC-20 controller.");
146     FT_MOD_PARM(ft_mach2,          "i",
147     	    "If non-zero, probe for a Mountain MACH-2 controller.");
148     FT_MOD_PARM(ft_tracing,        "i", 
149     	    "Amount of debugging output, 0 <= tracing <= 8, default 3.");
150     MODULE_AUTHOR(
151     	"(c) 1993-1996 Bas Laarhoven (bas@vimec.nl), "
152     	"(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no), "
153     	"(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)");
154     MODULE_DESCRIPTION(
155     	"QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives.");
156     MODULE_LICENSE("GPL");
157     #endif
158     
159     /*  Called by modules package when installing the driver
160      */
161     int init_module(void)
162     {
163     #ifndef CONFIG_FT_NO_TRACE_AT_ALL
164     	if (ft_tracing != -1) {
165     		ftape_tracing = ft_tracing;
166     	}
167     #endif
168     	return ftape_init();
169     }
170     
171     /*  Called by modules package when removing the driver
172      */
173     void cleanup_module(void)
174     {
175     	TRACE_FUN(ft_t_flow);
176     
177     #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
178     	ftape_proc_destroy();
179     #endif
180     	(void)ftape_set_nr_buffers(0);
181             printk(KERN_INFO "ftape: unloaded.\n");
182     	TRACE_EXIT;
183     }
184     #endif /* MODULE */
185