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_DTC3280
109 #include "dtc.h"
110 #endif
111
112 #ifdef CONFIG_SCSI_NCR53C7xx
113 #include "53c7,8xx.h"
114 #endif
115
116 #ifdef CONFIG_SCSI_ULTRASTOR
117 #include "ultrastor.h"
118 #endif
119
120 #ifdef CONFIG_SCSI_7000FASST
121 #include "wd7000.h"
122 #endif
123
124 #ifdef CONFIG_SCSI_EATA
125 #include "eata.h"
126 #endif
127
128 #ifdef CONFIG_SCSI_NCR53C406A
129 #include "NCR53c406a.h"
130 #endif
131
132 #ifdef CONFIG_SCSI_AM53C974
133 #include "AM53C974.h"
134 #endif
135
136 #ifdef CONFIG_SCSI_PPA
137 #include "ppa.h"
138 #endif
139
140 #ifdef CONFIG_SCSI_SUNESP
141 #include "esp.h"
142 #endif
143
144 #ifdef CONFIG_SCSI_DEBUG
145 #include "scsi_debug.h"
146 #endif
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 #define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
169 NULL, NULL, 0, 0, 0, 0, 0, 0}
170
171
172
173
174
175
176
177
178 Scsi_Host_Template * scsi_hosts = NULL;
179
180 static Scsi_Host_Template builtin_scsi_hosts[] =
181 {
182 #ifdef CONFIG_SCSI_ADVANSYS
183 ADVANSYS,
184 #endif
185
186 #ifdef CONFIG_SCSI_BUSLOGIC
187 BUSLOGIC,
188 #endif
189 #ifdef CONFIG_SCSI_U14_34F
190 ULTRASTOR_14_34F,
191 #endif
192 #ifdef CONFIG_SCSI_ULTRASTOR
193 ULTRASTOR_14F,
194 #endif
195 #ifdef CONFIG_SCSI_AHA152X
196 AHA152X,
197 #endif
198 #ifdef CONFIG_SCSI_AHA1542
199 AHA1542,
200 #endif
201 #ifdef CONFIG_SCSI_AHA1740
202 AHA1740,
203 #endif
204 #ifdef CONFIG_SCSI_AIC7XXX
205 AIC7XXX,
206 #endif
207 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
208 FDOMAIN_16X0,
209 #endif
210 #ifdef CONFIG_SCSI_IN2000
211 IN2000,
212 #endif
213 #ifdef CONFIG_SCSI_GENERIC_NCR5380
214 GENERIC_NCR5380,
215 #endif
216 #ifdef CONFIG_SCSI_NCR53C406A
217 NCR53c406a,
218 #endif
219 #ifdef CONFIG_SCSI_QLOGIC
220 QLOGIC,
221 #endif
222 #ifdef CONFIG_SCSI_PAS16
223 MV_PAS16,
224 #endif
225 #ifdef CONFIG_SCSI_SEAGATE
226 SEAGATE_ST0X,
227 #endif
228 #ifdef CONFIG_SCSI_T128
229 TRANTOR_T128,
230 #endif
231 #ifdef CONFIG_SCSI_DTC3280
232 DTC3x80,
233 #endif
234 #ifdef CONFIG_SCSI_NCR53C7xx
235 NCR53c7xx,
236 #endif
237 #ifdef CONFIG_SCSI_EATA_DMA
238 EATA_DMA,
239 #endif
240 #ifdef CONFIG_SCSI_EATA_PIO
241 EATA_PIO,
242 #endif
243 #ifdef CONFIG_SCSI_7000FASST
244 WD7000,
245 #endif
246 #ifdef CONFIG_SCSI_EATA
247 EATA,
248 #endif
249 #ifdef CONFIG_SCSI_AM53C974
250 AM53C974,
251 #endif
252 #ifdef CONFIG_SCSI_PPA
253 PPA,
254 #endif
255 #ifdef CONFIG_SCSI_SUNESP
256 SCSI_SPARC_ESP,
257 #endif
258 #ifdef CONFIG_SCSI_DEBUG
259 SCSI_DEBUG,
260 #endif
261 };
262
263 #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
264
265
266
267
268
269
270
271 struct Scsi_Host * scsi_hostlist = NULL;
272 struct Scsi_Device_Template * scsi_devicelist = NULL;
273
274 int max_scsi_hosts = 0;
275 int next_scsi_host = 0;
276
277 void
278 scsi_unregister(struct Scsi_Host * sh){
279 struct Scsi_Host * shpnt;
280
281 if(scsi_hostlist == sh)
282 scsi_hostlist = sh->next;
283 else {
284 shpnt = scsi_hostlist;
285 while(shpnt->next != sh) shpnt = shpnt->next;
286 shpnt->next = shpnt->next->next;
287 }
288
289
290
291
292 if (max_scsi_hosts == next_scsi_host && !scsi_loadable_module_flag)
293 max_scsi_hosts--;
294
295 next_scsi_host--;
296 scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + sh->extra_bytes);
297 }
298
299
300
301
302
303
304 struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
305 struct Scsi_Host * retval, *shpnt;
306 retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j,
307 (tpnt->unchecked_isa_dma && j ? GFP_DMA : 0) | GFP_ATOMIC);
308 retval->host_busy = 0;
309 retval->block = NULL;
310 retval->wish_block = 0;
311 if(j > 0xffff) panic("Too many extra bytes requested\n");
312 retval->extra_bytes = j;
313 retval->loaded_as_module = scsi_loadable_module_flag;
314 retval->host_no = max_scsi_hosts++;
315 next_scsi_host++;
316 retval->host_queue = NULL;
317 retval->host_wait = NULL;
318 retval->last_reset = 0;
319 retval->irq = 0;
320 retval->dma_channel = 0xff;
321
322
323 retval->max_channel = 0;
324 retval->max_id = 8;
325 retval->max_lun = 8;
326
327 retval->unique_id = 0;
328 retval->io_port = 0;
329 retval->hostt = tpnt;
330 retval->next = NULL;
331 #ifdef DEBUG
332 printk("Register %x %x: %d\n", (int)retval, (int)retval->hostt, j);
333 #endif
334
335
336
337 retval->this_id = tpnt->this_id;
338 retval->can_queue = tpnt->can_queue;
339 retval->sg_tablesize = tpnt->sg_tablesize;
340 retval->cmd_per_lun = tpnt->cmd_per_lun;
341 retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
342 retval->use_clustering = tpnt->use_clustering;
343
344 retval->select_queue_depths = NULL;
345
346 if(!scsi_hostlist)
347 scsi_hostlist = retval;
348 else
349 {
350 shpnt = scsi_hostlist;
351 while(shpnt->next) shpnt = shpnt->next;
352 shpnt->next = retval;
353 }
354
355 return retval;
356 }
357
358 int
359 scsi_register_device(struct Scsi_Device_Template * sdpnt)
360 {
361 if(sdpnt->next) panic("Device already registered");
362 sdpnt->next = scsi_devicelist;
363 scsi_devicelist = sdpnt;
364 return 0;
365 }
366
367 unsigned int scsi_init()
368 {
369 static int called = 0;
370 int i, pcount;
371 Scsi_Host_Template * tpnt;
372 struct Scsi_Host * shpnt;
373 const char * name;
374
375 if(called) return 0;
376
377 called = 1;
378 for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
379 {
380
381
382
383
384
385 pcount = next_scsi_host;
386 if ((tpnt->detect) &&
387 (tpnt->present =
388 tpnt->detect(tpnt)))
389 {
390
391
392 if(pcount == next_scsi_host) {
393 if(tpnt->present > 1)
394 panic("Failure to register low-level scsi driver");
395
396
397 scsi_register(tpnt,0);
398 }
399 tpnt->next = scsi_hosts;
400 scsi_hosts = tpnt;
401
402
403 #if CONFIG_PROC_FS
404 build_proc_dir_entries(tpnt);
405 #endif
406 }
407 }
408
409 for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
410 {
411 if(shpnt->hostt->info)
412 name = shpnt->hostt->info(shpnt);
413 else
414 name = shpnt->hostt->name;
415 printk ("scsi%d : %s\n",
416 shpnt->host_no, name);
417 }
418
419 printk ("scsi : %d host%s.\n", next_scsi_host,
420 (next_scsi_host == 1) ? "" : "s");
421
422 scsi_make_blocked_list();
423
424
425 #ifdef CONFIG_BLK_DEV_SD
426 scsi_register_device(&sd_template);
427 #endif
428 #ifdef CONFIG_BLK_DEV_SR
429 scsi_register_device(&sr_template);
430 #endif
431 #ifdef CONFIG_CHR_DEV_ST
432 scsi_register_device(&st_template);
433 #endif
434 #ifdef CONFIG_CHR_DEV_SG
435 scsi_register_device(&sg_template);
436 #endif
437
438 #if 0
439 max_scsi_hosts = next_scsi_host;
440 #endif
441 return 0;
442 }
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461