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_SEAGATE
71 #include "seagate.h"
72 #endif
73
74 #ifdef CONFIG_SCSI_T128
75 #include "t128.h"
76 #endif
77
78 #ifdef CONFIG_SCSI_NCR53C7xx
79 #include "53c7,8xx.h"
80 #endif
81
82 #ifdef CONFIG_SCSI_ULTRASTOR
83 #include "ultrastor.h"
84 #endif
85
86 #ifdef CONFIG_SCSI_7000FASST
87 #include "wd7000.h"
88 #endif
89
90 #ifdef CONFIG_SCSI_EATA
91 #include "eata.h"
92 #endif
93
94 #ifdef CONFIG_SCSI_DEBUG
95 #include "scsi_debug.h"
96 #endif
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117 #define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
118 NULL, NULL, 0, 0, 0, 0, 0, 0}
119
120
121
122
123
124
125
126
127 Scsi_Host_Template * scsi_hosts = NULL;
128
129 static Scsi_Host_Template builtin_scsi_hosts[] =
130 {
131 #ifdef CONFIG_SCSI_U14_34F
132 ULTRASTOR_14_34F,
133 #endif
134 #ifdef CONFIG_SCSI_ULTRASTOR
135 ULTRASTOR_14F,
136 #endif
137 #ifdef CONFIG_SCSI_AHA152X
138 AHA152X,
139 #endif
140
141 #ifdef CONFIG_SCSI_BUSLOGIC
142 BUSLOGIC,
143 #endif
144 #ifdef CONFIG_SCSI_AHA1542
145 AHA1542,
146 #endif
147 #ifdef CONFIG_SCSI_AHA1740
148 AHA1740,
149 #endif
150 #ifdef CONFIG_SCSI_AHA274X
151 AHA274X,
152 #endif
153 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
154 FDOMAIN_16X0,
155 #endif
156 #ifdef CONFIG_SCSI_IN2000
157 IN2000,
158 #endif
159 #ifdef CONFIG_SCSI_GENERIC_NCR5380
160 GENERIC_NCR5380,
161 #endif
162 #ifdef CONFIG_SCSI_PAS16
163 MV_PAS16,
164 #endif
165 #ifdef CONFIG_SCSI_SEAGATE
166 SEAGATE_ST0X,
167 #endif
168 #ifdef CONFIG_SCSI_T128
169 TRANTOR_T128,
170 #endif
171 #ifdef CONFIG_SCSI_NCR53C7xx
172 NCR53c7xx,
173 #endif
174 #ifdef CONFIG_SCSI_7000FASST
175 WD7000,
176 #endif
177 #ifdef CONFIG_SCSI_EATA
178 EATA,
179 #endif
180 #ifdef CONFIG_SCSI_DEBUG
181 SCSI_DEBUG,
182 #endif
183 };
184
185 #define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
186
187
188
189
190
191 struct Scsi_Host * scsi_hostlist = NULL;
192 struct Scsi_Device_Template * scsi_devicelist;
193
194 int max_scsi_hosts = 0;
195 static int next_host = 0;
196
197 void
198 scsi_unregister(struct Scsi_Host * sh){
199 struct Scsi_Host * shpnt;
200 int j;
201
202 j = sh->extra_bytes;
203
204 if(scsi_hostlist == sh)
205 scsi_hostlist = NULL;
206 else {
207 shpnt = scsi_hostlist;
208 while(shpnt->next != sh) shpnt = shpnt->next;
209 shpnt->next = shpnt->next->next;
210 };
211 next_host--;
212 scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + j);
213 }
214
215
216
217
218
219 struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
220 struct Scsi_Host * retval, *shpnt;
221 retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j);
222 retval->host_busy = 0;
223 if(j > 0xffff) panic("Too many extra bytes requested\n");
224 retval->extra_bytes = j;
225 retval->loaded_as_module = scsi_loadable_module_flag;
226 retval->host_no = next_host++;
227 retval->host_queue = NULL;
228 retval->host_wait = NULL;
229 retval->last_reset = 0;
230 retval->irq = 0;
231 retval->hostt = tpnt;
232 retval->next = NULL;
233 #ifdef DEBUG
234 printk("Register %x %x: %d\n", retval, retval->hostt, j);
235 #endif
236
237
238
239 retval->this_id = tpnt->this_id;
240 retval->can_queue = tpnt->can_queue;
241 retval->sg_tablesize = tpnt->sg_tablesize;
242 retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
243
244 if(!scsi_hostlist)
245 scsi_hostlist = retval;
246 else
247 {
248 shpnt = scsi_hostlist;
249 while(shpnt->next) shpnt = shpnt->next;
250 shpnt->next = retval;
251 }
252
253 return retval;
254 }
255
256 int
257 scsi_register_device(struct Scsi_Device_Template * sdpnt)
258 {
259 if(sdpnt->next) panic("Device already registered");
260 sdpnt->next = scsi_devicelist;
261 scsi_devicelist = sdpnt;
262 return 0;
263 }
264
265 unsigned int scsi_init()
266 {
267 static int called = 0;
268 int i, j, count, pcount;
269 Scsi_Host_Template * tpnt;
270 count = 0;
271
272 if(called) return 0;
273
274 called = 1;
275 for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
276 {
277
278
279
280
281
282 pcount = next_host;
283 if ((tpnt->detect) &&
284 (tpnt->present =
285 tpnt->detect(tpnt)))
286 {
287
288
289 if(pcount == next_host) {
290 if(tpnt->present > 1)
291 panic("Failure to register low-level scsi driver");
292
293
294 scsi_register(tpnt,0);
295 };
296 tpnt->next = scsi_hosts;
297 scsi_hosts = tpnt;
298 for(j = 0; j < tpnt->present; j++)
299 printk ("scsi%d : %s\n",
300 count++, tpnt->name);
301 }
302 }
303 printk ("scsi : %d hosts.\n", count);
304
305
306 #ifdef CONFIG_BLK_DEV_SD
307 scsi_register_device(&sd_template);
308 #endif
309 #ifdef CONFIG_BLK_DEV_SR
310 scsi_register_device(&sr_template);
311 #endif
312 #ifdef CONFIG_CHR_DEV_ST
313 scsi_register_device(&st_template);
314 #endif
315 #ifdef CONFIG_CHR_DEV_SG
316 scsi_register_device(&sg_template);
317 #endif
318
319 max_scsi_hosts = count;
320 return 0;
321 }