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