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