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