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