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