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