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