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
220 if(scsi_hostlist == sh)
221 scsi_hostlist = sh->next;
222 else {
223 shpnt = scsi_hostlist;
224 while(shpnt->next != sh) shpnt = shpnt->next;
225 shpnt->next = shpnt->next->next;
226 };
227
228
229
230 if (max_scsi_hosts == next_scsi_host && !scsi_loadable_module_flag)
231 max_scsi_hosts--;
232
233 next_scsi_host--;
234 scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + sh->extra_bytes);
235 }
236
237
238
239
240
241 struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
242 struct Scsi_Host * retval, *shpnt;
243 retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j,
244 (tpnt->unchecked_isa_dma && j ? GFP_DMA : 0) | GFP_ATOMIC);
245 retval->host_busy = 0;
246 retval->block = NULL;
247 retval->wish_block = 0;
248 if(j > 0xffff) panic("Too many extra bytes requested\n");
249 retval->extra_bytes = j;
250 retval->loaded_as_module = scsi_loadable_module_flag;
251 retval->host_no = max_scsi_hosts++;
252 next_scsi_host++;
253 retval->host_queue = NULL;
254 retval->host_wait = NULL;
255 retval->last_reset = 0;
256 retval->irq = 0;
257 retval->dma_channel = 0xff;
258 retval->io_port = 0;
259 retval->forbidden_addr = 0;
260 retval->forbidden_size = 0;
261 retval->hostt = tpnt;
262 retval->next = NULL;
263 #ifdef DEBUG
264 printk("Register %x %x: %d\n", (int)retval, (int)retval->hostt, j);
265 #endif
266
267
268
269 retval->this_id = tpnt->this_id;
270 retval->can_queue = tpnt->can_queue;
271 retval->sg_tablesize = tpnt->sg_tablesize;
272 retval->cmd_per_lun = tpnt->cmd_per_lun;
273 retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
274
275 if(!scsi_hostlist)
276 scsi_hostlist = retval;
277 else
278 {
279 shpnt = scsi_hostlist;
280 while(shpnt->next) shpnt = shpnt->next;
281 shpnt->next = retval;
282 }
283
284 return retval;
285 }
286
287 int
288 scsi_register_device(struct Scsi_Device_Template * sdpnt)
289 {
290 if(sdpnt->next) panic("Device already registered");
291 sdpnt->next = scsi_devicelist;
292 scsi_devicelist = sdpnt;
293 return 0;
294 }
295
296 unsigned int scsi_init()
297 {
298 static int called = 0;
299 int i, pcount;
300 Scsi_Host_Template * tpnt;
301 struct Scsi_Host * shpnt;
302 const char * name;
303
304 if(called) return 0;
305
306 called = 1;
307 for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
308 {
309
310
311
312
313
314 pcount = next_scsi_host;
315 if ((tpnt->detect) &&
316 (tpnt->present =
317 tpnt->detect(tpnt)))
318 {
319
320
321 if(pcount == next_scsi_host) {
322 if(tpnt->present > 1)
323 panic("Failure to register low-level scsi driver");
324
325
326 scsi_register(tpnt,0);
327 };
328 tpnt->next = scsi_hosts;
329 scsi_hosts = tpnt;
330 }
331 }
332
333
334 for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
335 {
336 if(shpnt->hostt->info)
337 name = shpnt->hostt->info(shpnt);
338 else
339 name = shpnt->hostt->name;
340 printk ("scsi%d : %s\n",
341 shpnt->host_no, name);
342 }
343
344 printk ("scsi : %d host%s.\n", next_scsi_host,
345 (next_scsi_host == 1) ? "" : "s");
346
347 scsi_make_blocked_list();
348
349
350 #ifdef CONFIG_BLK_DEV_SD
351 scsi_register_device(&sd_template);
352 #endif
353 #ifdef CONFIG_BLK_DEV_SR
354 scsi_register_device(&sr_template);
355 #endif
356 #ifdef CONFIG_CHR_DEV_ST
357 scsi_register_device(&st_template);
358 #endif
359 #ifdef CONFIG_CHR_DEV_SG
360 scsi_register_device(&sg_template);
361 #endif
362
363 #if 0
364 max_scsi_hosts = next_scsi_host;
365 #endif
366 return 0;
367 }
368
369
370 void scsi_mem_init(unsigned long memory_end)
371 {
372 struct Scsi_Host *Host;
373 long High8, Low24;
374 for (Host = scsi_hostlist; Host != NULL; Host = Host->next) {
375 if (Host->forbidden_addr > 0 && Host->forbidden_size > 0) {
376 for (High8 = 1<<24; High8 < memory_end; High8 += 1<<24) {
377 for (Low24 = Host->forbidden_addr;
378 Low24 < Host->forbidden_addr + Host->forbidden_size;
379 Low24 += PAGE_SIZE) {
380 unsigned long ForbiddenAddress = High8 + Low24;
381 if (ForbiddenAddress >= memory_end) goto next_host;
382 mem_map[MAP_NR(ForbiddenAddress)] = MAP_PAGE_RESERVED;
383 }
384 }
385 }
386 next_host:
387 continue;
388 }
389 }
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406