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