This source file includes following definitions.
- scsi_unregister
- scsi_register
- scsi_register_device
- scsi_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #define _SCSI_SYMS_VER_
24 #define __NO_VERSION__
25 #include <linux/module.h>
26
27 #include <linux/config.h>
28 #include <linux/blk.h>
29 #include <linux/kernel.h>
30 #include <linux/string.h>
31 #include <linux/mm.h>
32 #include <linux/proc_fs.h>
33
34 #include "scsi.h"
35
36 #ifndef NULL
37 #define NULL 0L
38 #endif
39
40 #define HOSTS_C
41
42 #include "hosts.h"
43
44 #ifdef CONFIG_SCSI_ADVANSYS
45 #include "advansys.h"
46 #endif
47
48 #ifdef CONFIG_SCSI_AHA152X
49 #include "aha152x.h"
50 #endif
51
52 #ifdef CONFIG_SCSI_AHA1542
53 #include "aha1542.h"
54 #endif
55
56 #ifdef CONFIG_SCSI_AHA1740
57 #include "aha1740.h"
58 #endif
59
60 #ifdef CONFIG_SCSI_AIC7XXX
61 #include "aic7xxx.h"
62 #endif
63
64 #ifdef CONFIG_SCSI_BUSLOGIC
65 #include "BusLogic.h"
66 #endif
67
68 #ifdef CONFIG_SCSI_EATA_DMA
69 #include "eata_dma.h"
70 #endif
71
72 #ifdef CONFIG_SCSI_EATA_PIO
73 #include "eata_pio.h"
74 #endif
75
76 #ifdef CONFIG_SCSI_U14_34F
77 #include "u14-34f.h"
78 #endif
79
80 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
81 #include "fdomain.h"
82 #endif
83
84 #ifdef CONFIG_SCSI_GENERIC_NCR5380
85 #include "g_NCR5380.h"
86 #endif
87
88 #ifdef CONFIG_SCSI_IN2000
89 #include "in2000.h"
90 #endif
91
92 #ifdef CONFIG_SCSI_PAS16
93 #include "pas16.h"
94 #endif
95
96 #ifdef CONFIG_SCSI_QLOGIC
97 #include "qlogic.h"
98 #endif
99
100 #ifdef CONFIG_SCSI_SEAGATE
101 #include "seagate.h"
102 #endif
103
104 #ifdef CONFIG_SCSI_T128
105 #include "t128.h"
106 #endif
107
108 #ifdef CONFIG_SCSI_NCR53C7xx
109 #include "53c7,8xx.h"
110 #endif
111
112 #ifdef CONFIG_SCSI_ULTRASTOR
113 #include "ultrastor.h"
114 #endif
115
116 #ifdef CONFIG_SCSI_7000FASST
117 #include "wd7000.h"
118 #endif
119
120 #ifdef CONFIG_SCSI_EATA
121 #include "eata.h"
122 #endif
123
124 #ifdef CONFIG_SCSI_NCR53C406A
125 #include "NCR53c406a.h"
126 #endif
127
128 #ifdef CONFIG_SCSI_AM53C974
129 #include "AM53C974.h"
130 #endif
131
132 #ifdef CONFIG_SCSI_PPA
133 #include "ppa.h"
134 #endif
135
136 #ifdef CONFIG_SCSI_DEBUG
137 #include "scsi_debug.h"
138 #endif
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 #define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
160 NULL, NULL, 0, 0, 0, 0, 0, 0}
161
162
163
164
165
166
167
168
169 Scsi_Host_Template * scsi_hosts = NULL;
170
171 static Scsi_Host_Template builtin_scsi_hosts[] =
172 {
173 #ifdef CONFIG_SCSI_ADVANSYS
174 ADVANSYS,
175 #endif
176
177 #ifdef CONFIG_SCSI_BUSLOGIC
178 BUSLOGIC,
179 #endif
180 #ifdef CONFIG_SCSI_U14_34F
181 ULTRASTOR_14_34F,
182 #endif
183 #ifdef CONFIG_SCSI_ULTRASTOR
184 ULTRASTOR_14F,
185 #endif
186 #ifdef CONFIG_SCSI_AHA152X
187 AHA152X,
188 #endif
189 #ifdef CONFIG_SCSI_AHA1542
190 AHA1542,
191 #endif
192 #ifdef CONFIG_SCSI_AHA1740
193 AHA1740,
194 #endif
195 #ifdef CONFIG_SCSI_AIC7XXX
196 AIC7XXX,
197 #endif
198 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
199 FDOMAIN_16X0,
200 #endif
201 #ifdef CONFIG_SCSI_IN2000
202 IN2000,
203 #endif
204 #ifdef CONFIG_SCSI_GENERIC_NCR5380
205 GENERIC_NCR5380,
206 #endif
207 #ifdef CONFIG_SCSI_NCR53C406A
208 NCR53c406a,
209 #endif
210 #ifdef CONFIG_SCSI_QLOGIC
211 QLOGIC,
212 #endif
213 #ifdef CONFIG_SCSI_PAS16
214 MV_PAS16,
215 #endif
216 #ifdef CONFIG_SCSI_SEAGATE
217 SEAGATE_ST0X,
218 #endif
219 #ifdef CONFIG_SCSI_T128
220 TRANTOR_T128,
221 #endif
222 #ifdef CONFIG_SCSI_NCR53C7xx
223 NCR53c7xx,
224 #endif
225 #ifdef CONFIG_SCSI_EATA_DMA
226 EATA_DMA,
227 #endif
228 #ifdef CONFIG_SCSI_EATA_PIO
229 EATA_PIO,
230 #endif
231 #ifdef CONFIG_SCSI_7000FASST
232 WD7000,
233 #endif
234 #ifdef CONFIG_SCSI_EATA
235 EATA,
236 #endif
237 #ifdef CONFIG_SCSI_AM53C974
238 AM53C974,
239 #endif
240 #ifdef CONFIG_SCSI_PPA
241 PPA,
242 #endif
243 #ifdef CONFIG_SCSI_DEBUG
244 SCSI_DEBUG,
245 #endif
246 };
247
248 #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
249
250
251
252
253
254
255
256 struct Scsi_Host * scsi_hostlist = NULL;
257 struct Scsi_Device_Template * scsi_devicelist = NULL;
258
259 int max_scsi_hosts = 0;
260 int next_scsi_host = 0;
261
262 void
263 scsi_unregister(struct Scsi_Host * sh){
264 struct Scsi_Host * shpnt;
265
266 if(scsi_hostlist == sh)
267 scsi_hostlist = sh->next;
268 else {
269 shpnt = scsi_hostlist;
270 while(shpnt->next != sh) shpnt = shpnt->next;
271 shpnt->next = shpnt->next->next;
272 }
273
274
275
276
277 if (max_scsi_hosts == next_scsi_host && !scsi_loadable_module_flag)
278 max_scsi_hosts--;
279
280 next_scsi_host--;
281 scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + sh->extra_bytes);
282 }
283
284
285
286
287
288
289 struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
290 struct Scsi_Host * retval, *shpnt;
291 retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j,
292 (tpnt->unchecked_isa_dma && j ? GFP_DMA : 0) | GFP_ATOMIC);
293 retval->host_busy = 0;
294 retval->block = NULL;
295 retval->wish_block = 0;
296 if(j > 0xffff) panic("Too many extra bytes requested\n");
297 retval->extra_bytes = j;
298 retval->loaded_as_module = scsi_loadable_module_flag;
299 retval->host_no = max_scsi_hosts++;
300 next_scsi_host++;
301 retval->host_queue = NULL;
302 retval->host_wait = NULL;
303 retval->last_reset = 0;
304 retval->irq = 0;
305 retval->dma_channel = 0xff;
306
307
308 retval->max_channel = 0;
309 retval->max_id = 8;
310 retval->max_lun = 8;
311
312 retval->unique_id = 0;
313 retval->io_port = 0;
314 retval->hostt = tpnt;
315 retval->next = NULL;
316 #ifdef DEBUG
317 printk("Register %x %x: %d\n", (int)retval, (int)retval->hostt, j);
318 #endif
319
320
321
322 retval->this_id = tpnt->this_id;
323 retval->can_queue = tpnt->can_queue;
324 retval->sg_tablesize = tpnt->sg_tablesize;
325 retval->cmd_per_lun = tpnt->cmd_per_lun;
326 retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
327 retval->use_clustering = tpnt->use_clustering;
328 if(!scsi_hostlist)
329 scsi_hostlist = retval;
330 else
331 {
332 shpnt = scsi_hostlist;
333 while(shpnt->next) shpnt = shpnt->next;
334 shpnt->next = retval;
335 }
336
337 return retval;
338 }
339
340 int
341 scsi_register_device(struct Scsi_Device_Template * sdpnt)
342 {
343 if(sdpnt->next) panic("Device already registered");
344 sdpnt->next = scsi_devicelist;
345 scsi_devicelist = sdpnt;
346 return 0;
347 }
348
349 unsigned int scsi_init()
350 {
351 static int called = 0;
352 int i, pcount;
353 Scsi_Host_Template * tpnt;
354 struct Scsi_Host * shpnt;
355 const char * name;
356
357 if(called) return 0;
358
359 called = 1;
360 for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
361 {
362
363
364
365
366
367 pcount = next_scsi_host;
368 if ((tpnt->detect) &&
369 (tpnt->present =
370 tpnt->detect(tpnt)))
371 {
372
373
374 if(pcount == next_scsi_host) {
375 if(tpnt->present > 1)
376 panic("Failure to register low-level scsi driver");
377
378
379 scsi_register(tpnt,0);
380 }
381 tpnt->next = scsi_hosts;
382 scsi_hosts = tpnt;
383
384
385 #if CONFIG_PROC_FS
386 build_proc_dir_entries(tpnt);
387 #endif
388 }
389 }
390
391 for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
392 {
393 if(shpnt->hostt->info)
394 name = shpnt->hostt->info(shpnt);
395 else
396 name = shpnt->hostt->name;
397 printk ("scsi%d : %s\n",
398 shpnt->host_no, name);
399 }
400
401 printk ("scsi : %d host%s.\n", next_scsi_host,
402 (next_scsi_host == 1) ? "" : "s");
403
404 scsi_make_blocked_list();
405
406
407 #ifdef CONFIG_BLK_DEV_SD
408 scsi_register_device(&sd_template);
409 #endif
410 #ifdef CONFIG_BLK_DEV_SR
411 scsi_register_device(&sr_template);
412 #endif
413 #ifdef CONFIG_CHR_DEV_ST
414 scsi_register_device(&st_template);
415 #endif
416 #ifdef CONFIG_CHR_DEV_SG
417 scsi_register_device(&sg_template);
418 #endif
419
420 #if 0
421 max_scsi_hosts = next_scsi_host;
422 #endif
423 return 0;
424 }
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443