This source file includes following definitions.
- scsi_unregister
- scsi_register
- scsi_register_device
- scsi_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 if(j > 0xffff) panic("Too many extra bytes requested\n");
231 retval->extra_bytes = j;
232 retval->loaded_as_module = scsi_loadable_module_flag;
233 retval->host_no = next_host++;
234 retval->host_queue = NULL;
235 retval->host_wait = NULL;
236 retval->last_reset = 0;
237 retval->irq = 0;
238 retval->hostt = tpnt;
239 retval->next = NULL;
240 #ifdef DEBUG
241 printk("Register %x %x: %d\n", retval, retval->hostt, j);
242 #endif
243
244
245
246 retval->this_id = tpnt->this_id;
247 retval->can_queue = tpnt->can_queue;
248 retval->sg_tablesize = tpnt->sg_tablesize;
249 retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
250
251 if(!scsi_hostlist)
252 scsi_hostlist = retval;
253 else
254 {
255 shpnt = scsi_hostlist;
256 while(shpnt->next) shpnt = shpnt->next;
257 shpnt->next = retval;
258 }
259
260 return retval;
261 }
262
263 int
264 scsi_register_device(struct Scsi_Device_Template * sdpnt)
265 {
266 if(sdpnt->next) panic("Device already registered");
267 sdpnt->next = scsi_devicelist;
268 scsi_devicelist = sdpnt;
269 return 0;
270 }
271
272 unsigned int scsi_init()
273 {
274 static int called = 0;
275 int i, j, count, pcount;
276 Scsi_Host_Template * tpnt;
277 count = 0;
278
279 if(called) return 0;
280
281 called = 1;
282 for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
283 {
284
285
286
287
288
289 pcount = next_host;
290 if ((tpnt->detect) &&
291 (tpnt->present =
292 tpnt->detect(tpnt)))
293 {
294
295
296 if(pcount == next_host) {
297 if(tpnt->present > 1)
298 panic("Failure to register low-level scsi driver");
299
300
301 scsi_register(tpnt,0);
302 };
303 tpnt->next = scsi_hosts;
304 scsi_hosts = tpnt;
305 for(j = 0; j < tpnt->present; j++)
306 printk ("scsi%d : %s\n",
307 count++, tpnt->name);
308 }
309 }
310 printk ("scsi : %d hosts.\n", count);
311
312
313 #ifdef CONFIG_BLK_DEV_SD
314 scsi_register_device(&sd_template);
315 #endif
316 #ifdef CONFIG_BLK_DEV_SR
317 scsi_register_device(&sr_template);
318 #endif
319 #ifdef CONFIG_CHR_DEV_ST
320 scsi_register_device(&st_template);
321 #endif
322 #ifdef CONFIG_CHR_DEV_SG
323 scsi_register_device(&sg_template);
324 #endif
325
326 max_scsi_hosts = count;
327 return 0;
328 }