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